vercel / next.js

The React Framework
https://nextjs.org
MIT License
123.18k stars 26.3k forks source link

Unclear if/how you can set a fallback OG image with the app router #58954

Open millansingh opened 7 months ago

millansingh commented 7 months ago

What is the improvement or update you wish to see?

I would like to be able to include an OG image which can be used as a general fallback when I don't have a more specific image for a page.

I'm not sure if this is missing functionality or if the docs are just not showing how to do this. As of now, the docs (https://nextjs.org/docs/app/api-reference/file-conventions/metadata/opengraph-image) mention only to put these files in an app route to put them on that route.

Is there any context that might help us understand?

For this case, I have a small site with 3 pages, and I had to copy my opengraph-image and twitter-image files into all three directories in order to get those OG images to show up on each of the pages. If I put the files into just the (default) folder, it would only show up on the homepage.

Does the docs page already exist? Please link to it.

https://nextjs.org/docs/app/api-reference/file-conventions/metadata/opengraph-image

altano commented 7 months ago

Opengraph images follow the same general principles as other app routing, which is to say that if a page does NOT have an opengraph image specified, but there is one in the parent directory, that will be used instead.

To take an example: the /contact page of my website (src) does NOT specify its own opengraph image, so it uses the opengraph image from the root page of my website (src)