next-seo icon indicating copy to clipboard operation
next-seo copied to clipboard

Open graph images from /public folder don't render

Open janoschherrmann opened this issue 1 year ago • 3 comments

Describe the bug When using the next-seo to add open graph images to pages, everything works completely fine with images hosted on external CDNs (our CMS, etc.), but for images from the /public folder, it doesn't work at all. The open graph images don't render on any platform.

Reproduction Here's an example of what I'm doing:

<NextSeo
      title='My title'
      description='My description'
      openGraph={{
        images: [
          {
            url: '/image-from-public-folder.png',
            alt: 'My image',
            type: 'image/jpeg'
          }
        ],
      }}
    />

Expected behavior Open graph images from the public folder should render correctly, like the images from external CDNs do.

janoschherrmann avatar Aug 29 '22 15:08 janoschherrmann

Hey @janoschsworkspace, open graph requires a full URL and not just a path.

garmeeh avatar Aug 29 '22 21:08 garmeeh

Oh, that makes sense. How would I use the full path to images in the /public folder? I've tried doing it like this (which matches the current URL of images from that folder on my site), but it hasn't worked for me yet: https://mysite.com/_next/image?url=%2Fname-of-the-image-file.png&w=1200&q=100

Is that not the correct way to do it? @garmeeh

janoschherrmann avatar Aug 31 '22 07:08 janoschherrmann

Hey @garmeeh, what would be the correct way to do this?

janoschherrmann avatar Sep 09 '22 10:09 janoschherrmann

Hey @janoschsworkspace, yes that should be correct. If you look on page and take the src="" value and add your site domain to the start of it. One thing to verify is that url when entered into a browser opens the image as expected. It is strange that CDN images are working and not your one.

garmeeh avatar Oct 15 '22 12:10 garmeeh