Search and sharing guides

Set image precedence when generating Open Graph tags

·

Open Graph lets a page declare a title, object type, URL and image for link sharing. A page can supply multiple images. Keep each image's dimensions and alternative text immediately after the image URL they describe.

Open Graph Generator

Generate tags for two images

Select Load example, then Generate tags. The Seed Swap & Workshop draft declares an article URL and two images. The first image is greenhouse.jpg, declared as 1,200 by 630 pixels. The second is seed-packets.png, declared as 800 by 800 pixels.

Read the export from top to bottom. Each og:image line is followed by the MIME type, dimensions and alternative text for that image. The example also declares en_GB for the primary locale and fr_FR for an alternate.

Generate tags for two images
Image in exportDeclared sizeContents described by alt text
greenhouse.jpg1,200 × 630 pxLabeled seed packets in front of a greenhouse
seed-packets.png800 × 800 pxThree seed packets with handwritten labels

The Open Graph protocol, Basic MetadataThe Open Graph protocol, Arrays

Reorder the images and compare the X Card

Choose Move image up in Open Graph image 2 and generate again. Check that seed-packets.png now comes first and that its 800 by 800 properties follow it. Open Graph gives the first entry preference when values conflict.

The example's X Card has its own title, Swap seeds this Saturday. Its image follows the first Open Graph image unless you supply a separate X Card image URL. Choose Omit X Card to export only Open Graph tags.

The Open Graph protocol, Arrays

Check the draft and saved HTML

Open a local image to see it alongside the draft title and description. Compare the measured local size with the dimensions entered for your hosted asset. The preview image never replaces the image URL in the exported markup.

Add the generated tags to the document head. Paste the saved HTML into Open Graph Validator to check declaration order, required fields and which values are present. The visual draft is one local layout. Sharing platforms use their own layouts and fetch the published image separately.

The Open Graph protocol, Basic MetadataThe Open Graph protocol, Structured Properties

Common questions

Can I add a different HTTPS address for the same image?

Enter a Secure image URL in that image's group. It is emitted as og:image:secure_url after its image declaration.

Does a second image replace the first image's dimensions?

Each og:image starts its own group. Width, height and alternative text following that tag describe that image until the next image declaration.

What should I put in image alt text?

Describe what the image shows. For the example, mention the labeled seed packets and greenhouse instead of repeating the event title.

Sources

Put it into practice.

Related guides