-
Notifications
You must be signed in to change notification settings - Fork 474
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Canonical URL for prefixed strategy #912
Comments
Just an update. I don't think that this should be only enabled due to issue with redirection. Actually defining canonical urls are important for avoiding duplicate content. I've nuxt sitemap module as well, however Google just doesn't care as they mention it:
More information about canonical urls: https://ahrefs.com/blog/canonical-tags/ Also, I can confirm that they just don't care defined canonical urls in sitemap and the only solution it enable it by default or add option*? * Yes, I do remember adding option is not the case, maybe enable it by default then? It will only improve SEO for all. |
So this extra Since that extra, generated page is meant to redirect to a specific locale, and that locale might be different from one that the page was generated for, I think the canonical path there would also be problematic. I'm not sure what is a proper solution for static hosting in this case. Maybe some dummy page whose purpose is to redirect. But than Nuxt already generates one automatically (200.html) so maybe the hosting should just be configured to use that page by default, instead of this module generating extra pages. |
Well, after thinking about this more: Canonical URL might be enabled for all strategies since this a SEO dependent configuration (like og meta tags). The only differences would be root path dependent on each strategy. @rchl what do you think? |
Here is a draft for canonical URL feature:
* Not sure about this? Should it point to default locale or root path since it's using defaultLocale as prefixed version and for root path as well. Current implementation only works when there is a query string and after that it only adds canonical URL.
and the resulting canonical path is:
Which is incorrect, query parameters should be stripped out. Even in this draft switchLocalePath is returning query strings, how to return locale path without query string and current locale? Maybe this.$route.path is a better solution? @rchl your help is appreciated! More information about this topic: Thanks! |
Another update: According to canonicalization:
* Basically this needs to be documented that query parameters will be stripped out for canonicalization because there is no way to solve this otherwise. Maybe adding configuration parameter canonical enabled true or false will be better solution to enable it by default however since this is a SEO feature - it's already should be enabled. Thanks! |
I think that's a good idea to use
I believe there is no way to automatically know whether the query parameter should be included in canonical or not. Probably the best we could do is to allow users to specify that manually per-page somehow.
I think it makes sense to add canonical regardless if the current URL matches canonical or not. At least that's what is recommended in https://ahrefs.com/blog/canonical-tags/ ("self-referential canonical tags"). Also, I think we should enable canonical regardless of whichever strategy is used because it's also meant to disambiguate between URLs with queries and without and those can happen with any strategy. We just need to fix the query problem first. |
We could probably grab something like this as an example? const getForcedColorMode = route => route.matched[0] && route.matched[0].components.default.options.colorMode Source is here and used like this: <template>
<h1>This page is forced with light mode</h1>
</template>
<script>
export default {
colorMode: 'light',
}
</script> This was integrated recently and I also like the idea of using local storage instead of cookies as well. In this library we could use as an example (I'm not the greatest at naming 😅) <template>
<h1>This page is forced to use canonical url with parameters</h1>
</template>
<script>
export default {
canonicalQueries: true,
}
</script>
How can I help? I'm not the great at writing complicated tests but I'll try my best. |
I was thinking something more like: <script>
export default {
seo() {
return {
canonicalQueries: ['param1']
}
}
}
</script> because even if we want to include some query in canonical, we don't really want to include all but only specific ones.
Thanks but I'm on it already. |
Also don't trigger warning on using "localePath", "switchLocalePath" or "localeRoute" with default locale. We need that functionality for generating canonical tag and it doesn't really hurt to allow that. Resolves #912
Also don't trigger warning on using "localePath", "switchLocalePath" or "localeRoute" with default locale. We need that functionality for generating canonical tag and it doesn't really hurt to allow that. Resolves #912
Also don't trigger warning on using "localePath", "switchLocalePath" or "localeRoute" with default locale. We need that functionality for generating canonical tag and it doesn't really hurt to allow that. Resolves #912
Also don't trigger warning on using "localePath", "switchLocalePath" or "localeRoute" with default locale. We need that functionality for generating canonical tag and it doesn't really hurt to allow that. Resolves #912
Also don't trigger warning on using "localePath", "switchLocalePath" or "localeRoute" with default locale. We need that functionality for generating canonical tag and it doesn't really hurt to allow that. Resolves #912
Fixes released in https://github.com/nuxt-community/i18n-module/releases/tag/v6.15.2 |
@rchl so did we decide not to have |
Feel free to create a feature request for it. I think we don't have one yet, even if it was discussed here. |
Is your feature request related to a problem? Please describe.
Currently prefixed strategy generating*
index.html
for each page which is solely used for redirection does create a duplicate content. It's not possible withoutindex.html
to detect and force redirection.The problem here is that Google can't decide which is canonical URLs on it's own.
It's now detecting
/en
as duplicate of/
(root) path.See: https://support.google.com/webmasters/answer/182192?hl=en#3
Describe the solution you'd like
Canonical URL enabled for prefixed strategy as well. It's only enabled for
PREFIX_AND_DEFAULT
https://github.com/nuxt-community/i18n-module/blob/master/CHANGELOG.md#features-24Thanks!
The text was updated successfully, but these errors were encountered: