Customizing head tags
Adding head tags (such as meta tags) to web pages is crucial for SEO optimization and social media sharing. For example, Open Graph is a web metadata protocol that controls how pages appear when shared on social media platforms.
Currently, Rspress automatically injects the following head tags:
If you want to add head tags, you can use the following methods:
Global head configuration
In rspress.config.ts, you can set HTML metadata (head tags) for all pages. See Basic Config - head for details.
Frontmatter configuration
You can modify the title and description fields in frontmatter to change the title and description of individual pages.
You can also use frontmatter - head to customize page metadata tags for SEO optimization.
For example, if you want to add <meta name="og:description" content="This is description"> to the <head> tag, you can use frontmatter like this:
Head component
If you need more complex head customization, you can use the Head component provided by Rspress to dynamically set head tags in pages or layout components.