Skip to content

Conversation

okainov
Copy link

@okainov okainov commented Sep 3, 2025

  • Add clarification about language with example of the same value as code
  • Remove seemingly Nuxt 2 example
  • Add usages of useSeoMeta and indicate it's the primary way

🔗 Linked issue

#3803

📚 Description

Summary by CodeRabbit

  • Documentation
    • Updated SEO guide to introduce the unified useSeoMeta composable for per-page and layout metadata, replacing older patterns.
    • Added examples showing reactive titles, titleTemplate usage, and explicit Open Graph fields (ogTitle, ogType, ogSiteName).
    • Simplified layout/head setup using useLocaleHead merged with useHead, plus global SEO defaults via useSeoMeta.
    • Clarified language-tag guidance (prefer “en” over “en-US”) and code vs language distinctions.
    • Updated sample layouts and pages to reflect the new approach.

- Remove seemingly Nuxt 2 example
- Add usages of useSeoMeta and indicate it's the primary way
@okainov okainov requested a review from BobbieGoede as a code owner September 3, 2025 09:08
Copy link
Contributor

coderabbitai bot commented Sep 3, 2025

Walkthrough

The docs replace definePageMeta and manual useHead/meta patterns with a new SEO composable useSeoMeta for per-page and layout metadata (title, description, ogTitle, ogType, ogSiteName, titleTemplate, etc.). Layouts now show useLocaleHead merged with useHead and a simplified markup structure. Page examples (index, about) demonstrate useSeoMeta with reactive values (computed) and titleTemplate. Language tag examples changed (en-US → en) with an explicit distinction between displayed language and language code.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (5)
docs/content/docs/02.guide/06.seo.md (5)

19-21: Tighten wording and fix grammar around the language property.

Clarifies BCP 47 requirement and fixes “an language”/flow.

-To leverage the SEO benefits, you must configure the `locales` option as an array of objects, where each object has an `language` option set to the locale language tags.
+To leverage the SEO benefits, configure `i18n.locales` as an array of objects, each with a `language` property set to a valid BCP 47 language tag.
-**NOTE**: while `code` is used to create prefixes for URLs and to set locales and can be any arbitrary value, `language` goes to `<html lang="...">` and must be [BCP 47](https://developer.mozilla.org/en-US/docs/Glossary/BCP_47_language_tag). In most cases though both can share the same value like `en` or `es`.
+**Note**: `code` is used for URL prefixes and locale selection and can be any arbitrary value; `language` is used for `<html lang="…">` and must be a [BCP 47](https://developer.mozilla.org/en-US/docs/Glossary/BCP_47_language_tag) tag. In most cases, both can share the same value (e.g., `en`, `es`).

29-38: Make the example consistent with the note (“language can match code”).

Either use regionless tags for all three locales or regioned tags for all three. Given the PR goal, align all three with code.

       {
         code: 'en',
-        language: 'en'
+        language: 'en'
       },
       {
         code: 'es',
-        language: 'es-ES'
+        language: 'es'
       },
       {
         code: 'fr',
-        language: 'fr-FR'
+        language: 'fr'
       }

Alternatively, switch all to regioned (en-US, es-ES, fr-FR) and add a short sentence noting that matching code is optional.


122-128: Optional: also set ogTitle to match the computed page title.

Keeps social previews consistent without repeating logic elsewhere.

 useSeoMeta({
   // Only override page-specific details
   title: computed(() => `${t('index.title')} ${locale.value}`),
-  description: computed(() => t('site.index.description')),
+  description: computed(() => t('site.index.description')),
+  ogTitle: computed(() => `${t('index.title')} ${locale.value}`),
 })

159-160: Fix grammar in merge sentence.

-If you also want to add your own metadata, you have to call `useSeoMeta()`{lang="ts"}/`useHead()`{lang="ts"}. When you call it with the additional metadata, `useSeoMeta()`{lang="ts"}/`useHead()`{lang="ts"} will merge it global metadata that has already defined.
+If you also want to add your own metadata, call `useSeoMeta()`{lang="ts"}/`useHead()`{lang="ts"}. Your additional metadata will be merged with the global metadata that has already been defined.

162-170: Combine the two useSeoMeta calls and localize the title.

Also show useI18n usage so the example works as written.

 <script setup>
-// define page meta for layouts/default.vue
-useSeoMeta({
-  title: 'pages.title.about'
-})
-
-useSeoMeta({
-  ogTitle:  'this is og title for about page',
-})
+const { t } = useI18n()
+// Define page-specific SEO
+useSeoMeta({
+  title: computed(() => t('pages.title.about')),
+  ogTitle: computed(() => t('pages.title.about'))
+})
 </script>
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 28e60ac and a1dcf1a.

📒 Files selected for processing (1)
  • docs/content/docs/02.guide/06.seo.md (4 hunks)
🔇 Additional comments (1)
docs/content/docs/02.guide/06.seo.md (1)

88-103: Move titleTemplate into useHead and streamline SEO defaults
Pass a function to useHead for reactivity, remove titleTemplate from useSeoMeta, and default ogTitle to the page title.

-useHead({
-  ...localeHead.value,
-  // Add something if needed
-})
+useHead(() => ({
+  ...localeHead.value,
+  // Global title strategy
+  titleTemplate: (titleChunk) => titleChunk ? `${titleChunk} - ${t('nav.brand')}` : t('nav.brand'),
+  // Add something if needed
+}))

-// Global SEO defaults
-useSeoMeta({
-  titleTemplate: (titleChunk) => {
-    return titleChunk ? `${titleChunk} - ${t('nav.brand')}` : t('nav.brand');
-  },
-  title: computed(() => t('site.name')), // Fallback when no page title
-  description: computed(() => t('site.description')),
-  ogType: 'website',
-  ogTitle: 'Wonderful OG title',
-  ogSiteName: computed(() => t('nav.brand'))
-})
+// Global SEO defaults
+useSeoMeta({
+  // Fallbacks when no page-specific overrides
+  title: computed(() => t('site.name')),
+  description: computed(() => t('site.description')),
+  ogType: 'website',
+  ogTitle: computed(() => t('site.name')), // keep OG aligned with title by default
+  ogSiteName: computed(() => t('nav.brand'))
+})

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (6)
docs/content/docs/02.guide/06.seo.md (6)

19-21: Grammar and clarity: article/property naming

Tighten wording and fix “an language”.

-To leverage the SEO benefits, you must configure the `locales` option as an array of objects, where each object has an `language` option set to the locale language tags.
+To leverage the SEO benefits, configure the `locales` option as an array of objects, where each object has a `language` property set to a BCP 47 language tag.

66-66: Streamline guidance and wording

Minor style/clarity improvements and align phrasing with the recommended flow.

-To avoid duplicating the code, it's recommended to set globally with [Meta Components](https://nuxt.com/docs/getting-started/seo-meta#components) in `app.vue` or [layout components](https://nuxt.com/docs/guide/directory-structure/layouts) and override some values per-page Vue component like [`useSeoMeta()`{lang="ts"}](https://nuxt.com/docs/api/composables/use-seo-meta), if necessary.
+To avoid duplication, set global SEO metadata with [Meta Components](https://nuxt.com/docs/getting-started/seo-meta#components) in `app.vue` or in a [layout](https://nuxt.com/docs/guide/directory-structure/layouts), and override per page using [`useSeoMeta()`{lang="ts"}](https://nuxt.com/docs/api/composables/use-seo-meta) when needed.

77-78: Remove empty script block in app.vue example

The empty <script setup> adds noise.

-<script setup>
-</script>

159-159: Typo and tone: definePageMeta note

Fix typo and slightly tighten wording.

-**NOTE**: while you might be tempted to use [`definePageMeta`{lang="ts"}](https://nuxt.com/docs/4.x/api/utils/define-page-meta) to set page title (and it works!), `definePageMeta`{lang="ts"} is not meant for it. Its main purprose is to set page-specific metadata, such as [layout](https://nuxt.com/docs/guide/directory-structure/layouts) or `middleware`{lang="ts"} and not to manipulate SEO and/or i18n-specific metadata. Default choice should be [`useSeoMeta()`{lang="ts"}](https://nuxt.com/docs/api/composables/use-seo-meta) for fields that it supports and `useHead` for everything else.
+**NOTE**: while you might be tempted to use [`definePageMeta`{lang="ts"}](https://nuxt.com/docs/4.x/api/utils/define-page-meta) to set the page title (and it works!), it’s not meant for that. Its main purpose is page-specific metadata such as [layout](https://nuxt.com/docs/guide/directory-structure/layouts) or `middleware`{lang="ts"}, not SEO or i18n metadata. The default choice should be [`useSeoMeta()`{lang="ts"}](https://nuxt.com/docs/api/composables/use-seo-meta) for supported fields, and `useHead` for everything else.

161-161: Grammar: merging phrasing

Fix prepositions/tense.

-When you call it with the additional metadata, `useSeoMeta()`{lang="ts"} will merge it global metadata that has already defined.
+When you call it with additional metadata, `useSeoMeta()`{lang="ts"} merges it with the global metadata that has already been defined.

167-170: Localize the per-page title/OG title like other examples

Keep consistency with the index example by using t (or computed(() => t(...))), and add the missing useI18n() import.

 <script setup>
-// add/override metadata coming from layouts/default.vue
+// add/override metadata coming from layouts/default.vue
+const { t } = useI18n()
 
 useSeoMeta({
-  title: 'pages.title.about',
-  ogTitle:  'this is og title for about page',
+  title: computed(() => t('pages.title.about')),
+  ogTitle: computed(() => t('pages.about.ogTitle')),
 })
 </script>
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between a1dcf1a and a02fec6.

📒 Files selected for processing (1)
  • docs/content/docs/02.guide/06.seo.md (4 hunks)
🧰 Additional context used
🪛 LanguageTool
docs/content/docs/02.guide/06.seo.md

[grammar] ~159-~159: Ensure spelling is correct
Context: ...ang="ts"} is not meant for it. Its main purprose is to set page-specific metadata, such ...

(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)

🔇 Additional comments (1)
docs/content/docs/02.guide/06.seo.md (1)

122-128: Good use of useSeoMeta with reactive i18n values

This example correctly demonstrates reactive title/description via computed and t.

Comment on lines +88 to +92
useHead({
...localeHead.value,
// Add something if needed
})
Copy link
Contributor

@coderabbitai coderabbitai bot Sep 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix reactivity loss when passing localeHead to useHead

Spreading localeHead.value into a plain object makes the head static and it won’t update on locale changes. Wrap in a function (or pass the computed directly) to keep it reactive.

-useHead({
-  ...localeHead.value,
-  // Add something if needed
-})
+useHead(() => ({
+  ...localeHead.value,
+  // Add something if needed
+}))

Alternative:

-useHead({
-  ...localeHead.value
-})
+useHead(localeHead)
+useHead({ /* your extra static entries */ })
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
useHead({
...localeHead.value,
// Add something if needed
})
useHead(() => ({
...localeHead.value,
// Add something if needed
}))
🤖 Prompt for AI Agents
In docs/content/docs/02.guide/06.seo.md around lines 88 to 92, spreading
localeHead.value into a plain object makes the head static and loses reactivity;
instead pass a function that returns the reactive value or pass the computed
directly to useHead so it updates on locale changes — replace useHead({
...localeHead.value, /* extras */ }) with useHead(() => ({ ...localeHead.value,
/* extras */ })) or simply useHead(localeHead) as appropriate.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't seem needed for SEO (as generally there is no need to be reactive for non-title tags). So I'd ignore this comment.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@okainov, understood! You're right that for SEO metadata like hreflang links, canonical URLs, and og:locale tags, reactivity typically isn't crucial since these values are generally static per page/route. I appreciate the clarification about your specific use case requirements.

  (\   /)
 ( ._.)
o_(")(")  *nods thoughtfully*

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant