Canonical URL
Introduction
It's common to have multiple URLs pointing to the same content. For example,
supporting a
The "main" domain is called the canonical URL. Ensuring a single canonical URL helps avoid duplicate content issues and confusion for end-users.
Learn more about canonical URLs with the Canonical Link Tag guide.
Canonical Head Tag
Nuxt SEO automatically sets a canonical URL meta tag for you. This tag is generated from the site URL and the current route path.
<head>
<!-- ... -->
<link rel="canonical" href="https://example.com/my-page" />
</head>
canonicalQueryWhitelist
The canonical URL is generated from:
site.url . Your Site Config url.$route.path : The current route path.canonicalQueryWhitelist : A list of query parameters that should be included in the canonical URL.
By default, the
page sort filter search q query
You can override this by providing your own list of query parameters that should be included in the canonical URL.
export default defineNuxtConfig({
seo: {
canonicalQueryWhitelist: ['myCustomQuery']
}
})
Redirect To Canonical
In some cases it may be preferred to redirect all non-canonical URLs to the canonical URL.
This redirect is optional and disabled by default.
export default defineNuxtConfig({
seo: {
redirectToCanonicalSiteUrl: true
}
})