next-seo
next-seo copied to clipboard
Open graph images from /public folder don't render
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.
Hey @janoschsworkspace, open graph requires a full URL and not just a path.
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
Hey @garmeeh, what would be the correct way to do this?
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.