Code Monkey home page Code Monkey logo

Comments (6)

martinsjek avatar martinsjek commented on June 1, 2024 2

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.

BobbieGoede avatar BobbieGoede commented on June 1, 2024

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.

martinsjek avatar martinsjek commented on June 1, 2024

@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.

martinsjek avatar martinsjek commented on June 1, 2024

@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.

BobbieGoede avatar BobbieGoede commented on June 1, 2024

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.

martinsjek avatar martinsjek commented on June 1, 2024

@BobbieGoede Yes, it would be great if we could do that. I will wait for any updates regarding this :)

from i18n.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.