useLocaleSeo
Generate hreflang, x-default, and og:locale tags for localized pages.
useLocaleSeo() only takes effect when @nuxtjs/i18n is enabled with at least two valid locales; otherwise it returns without injecting anything.
Usage
app/app.vue
<script setup lang="ts">
await useDocsShell()
useLocaleSeo()
</script>
Signature
function useLocaleSeo(): void
Injected Tags
| Tag | Value |
|---|---|
<link rel="alternate" hreflang="{code}"> | One per valid locale; href is site.url plus the current page's path in that locale |
<link rel="alternate" hreflang="x-default"> | Points to the current page in the configured default locale |
<meta property="og:locale"> | Locale in language-region form, such as zh_CN, when a region is available |
Notes
- Links are absolute, so
site.urlmust be set innuxt.config. - No alternate is generated for a locale where the page does not exist (
switchLocalePathreturns an empty string).
Related
Changelog
No recent changes