Comments (6)
Found a workaround with @BobbieGoede help.
You can modify canonical link in a page when using setI18nParams
.
You just need to define useHead
AFTER setI18nParams
.
Example:
setI18nParams({
en: {
slug: 'tests1',
},
lv: {
slug: 'tests',
},
});
useHead({
link: [
{
rel: 'canonical',
href: 'https://example.com/anything-i-want',
},
],
});
StackBlitz with example: https://stackblitz.com/edit/github-orzjqc-bntta4?file=pages%2Findex.vue,pages%2F[productCategory]%2F[id].vue
from i18n.
Can you give an example of when and why it would be desirable to be able to remove route parameters from the canonical tag? As far as I know canonicals should point to duplicate/identical resources.
from i18n.
@BobbieGoede Well It seems that this package already does what i desire. and you can close this issue.
But I will describe this with an example for next person to stumble upon this.
So you have an e-commerce site with products and variations.
So product url: /product/test-product
Product variation url: /product/test-product/variation-one
I would like to say "hey google, this variation url is the same as product url, because barely anything changes (tabs opened or anything like that)". And that's why I would like to remove "/variation-one" from canonical.
But it seems that if your component under pages is named as optional page: [[variation]].vue, then canonical automatically removes it.
from i18n.
@BobbieGoede It seems that actually if the page is [[variation]].vue, it does not automatically remove it. What would be the workaround to what I have described in previous comment?
from i18n.
I wasn't sure what you meant previously as parameters (optional or not) are not removed in the canonical links as you found out.
At the moment there's no workaround for this, Google suggests using query parameters for product variants (see their recommendations here), but if using url parameters is a common pattern we could think of a way to omit parameters somehow.
from i18n.
@BobbieGoede Yes, it would be great if we could do that. I will wait for any updates regarding this :)
from i18n.
Related Issues (20)
- `setI18nParams` automatically adds `<link rel="alternate" />`
- `useSetI18nParams` add `og:locale:alternate` also if false HOT 5
- Remove the auto-complete alternate langs HOT 1
- Strategy prefix with detectBrowserLanguage not redirecting correctly on root in Static Site Generation
- Object literal may only specify known properties, and 'i18n' does not exist in type 'NuxtConfig' HOT 5
- Memory Leak - crashes out HOT 1
- How to add langs/locales list in nuxtjs-i18n configuration dynamically. HOT 1
- useLocaleHead prerenders properly. useSwitchLocalePath does not HOT 7
- Language Switcher with SSR not working HOT 3
- Playground mergeLayerLocales is broken
- Chosen locale is loading a different locale file that is set in object HOT 3
- Extending local pages doesn't work HOT 3
- cdn deployment issues
- @nuxtjs/i18n not picking up vueI18n config when installed via Nuxt Kits `installModule` HOT 3
- Lazy loading localeMessages fetches several times when the page changes HOT 1
- Messages in the console when using global translations instead of local ones. HOT 1
- Support typed routes inside localePath() HOT 1
- Lazy-loading translations fetching both on server and client. HOT 1
- input.replace is not a function HOT 2
- Translations are loaded for all layers to the client HOT 10
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from i18n.