Add Image Support to SEO Component

InstructorLaurie Barth

Share this video with your friends

Send Tweet

Add a siteUrl field to your gatsby-config metadata. Together with an image src, generate the URL for an image. Inside your SEO component, add an additional array to your Helmet meta field that is only used when an image is available. Set the appropriate fields and the summary_large_image Twitter card type so that the images will show up when shared on social sites.

~ 4 years ago

Can we use StaticImage component in an MdX post ?

Laurie Barthinstructor
~ 4 years ago

You cannot. Under the hood there is some babel stuff going on the conflicts with the MDX build process.

~ 4 years ago

This nicely explains why I was not able to make it work then :wink: Thanks for the answer !

Gabi Jack
~ 3 years ago

How would it work for a post with more than one image?

Laurie Barthinstructor
~ 3 years ago

How would it work for a post with more than one image? SEO support is about the preview image that gets shown for a post when you share the link on a social site, etc. Therefore, only one image can be used.

This does not prevent you from using multiple images in the post itself.

Gabi Jack
~ 3 years ago

Thanks! I think I posted under the wrong segment. I meant multiple images in a post, not for SEO.

Laurie Barthinstructor
~ 3 years ago

Thanks! I think I posted under the wrong segment. I meant multiple images in a post, not for SEO.

Ah, got it. You certainly can. You can't have more than one image in the frontmatter unless you change your template. In most cases you'll want to include the images in the body of your MDX itself. Meaning you can treat it like a typical markdown image and use alt text.

Laurie Barthinstructor
~ 3 years ago

Thanks! I think I posted under the wrong segment. I meant multiple images in a post, not for SEO.

Ah, got it. You certainly can. You can't have more than one image in the frontmatter unless you change your template. In most cases you'll want to include the images in the body of your MDX itself. Meaning you can treat it like a typical markdown image and use alt text.

Sorry, about that, this comment section converts markdown it seems! This is the type of syntax you'd use. https://www.markdownguide.org/basic-syntax/#images-1