How to inject Open Graph/Meta tags for Social Media to your template file? #7724
binarykitchen
started this conversation in
General
Replies: 1 comment 3 replies
-
|
For static meta tags, you can use export default {
html: {
meta: {
'og:title': {
property: 'og:title',
content: 'Example Title',
},
'og:description': {
property: 'og:description',
content: 'Example description',
},
},
},
};
But in your case, the meta content depends on the route and DB data. The recommended approach is to use SSR or SSG, so each page can return HTML that contains the correct Open Graph meta tags. |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I wonder what's the recommendation how to inject HTML meta headers for social media scrapers, best using rsbuild?
Facebook comes with this tool to check:
https://developers.facebook.com/tools/debug
It requires a static HTML file. Before, I was using this npm package react-metatags-hook which was a bad idea. Because that Facebook scraper tool requires a plain HTML file.
That's why I decided to delete that wrong npm package and to refactor it properly but not sure where to start. Asking for advice if rsbuild already supports this?
For example, on my website, I load Video X with a GET request by ID. That video comes with a title and description. This using Express.js in routes. Once loaded over DB, I want to set the
ogDescriptionmeta tag with its description, for example. But how?In the
defineConfigfunction rsbuild provides, you set the template for your SPA web application.https://rsbuild.rs/guide/basic/html-template#set-template
It's compiled into HTML, yet, in my routes I would like to alter that template further, inject it with more HTML meta tags.
Ideas welcome. Thanks :)
Beta Was this translation helpful? Give feedback.
All reactions