useLocaleSeo
Inject hreflang alternate links, x-default and og:locale on multilingual sites so search engines can tell the language versions apart. The layer's app.vue already calls it globally; call it yourself only when you rewrite app.vue.
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 first locale of the list |
<meta property="og:locale"> | Current locale code with - replaced by _, such as zh_CN |
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
useMovkI18n
A single i18n entry point that works the same whether or not @nuxtjs/i18n is enabled. Read the current locale, translate built-in strings, build locale-prefixed links, and get the content collection and docs root for the current locale.
useFetchComponentMeta
Read the component metadata generated by nuxt-component-meta, including the types and descriptions of props, slots and events. ComponentProps and the other component docs components are built on it; call it directly to render your own API tables. Available only with component docs enabled.