Skip to content

Duplicate urls with different hreflang prevented in static routes #279

@learntheropes

Description

@learntheropes

When used in conjunction with nuxt-i18n module, duplicate urls with different hreflang are prevented in static routes.

Duplicate urls may be necessary when you want to specify a region and a region-independent link

This technique is considered valid and even encouraged here (Tester suggested in Google documentation here)

As an example, this sitemap is impossible to generate:

<loc>https://mydomain.com/en</loc>
<lastmod>2022-12-05T07:28:26.630Z</lastmod>
<changefreq>daily</changefreq>
<priority>1.0</priority>
<xhtml:link rel="alternate" hreflang="en-us" href="https://mydomain.com/en"/>
<xhtml:link rel="alternate" hreflang="pt-br" href="https://mydomain.com/pt"/>
<xhtml:link rel="alternate" hreflang="en" href="https://mydomain.com/en"/>
<xhtml:link rel="alternate" hreflang="pt" href="https://mydomain.com/pt"/>
<xhtml:link rel="alternate" hreflang="x-default" href="https://mydomain.com"/>
</url>

The workaround is to exclude all the static routes with the exclude property and include them in the dynamic routes generation with routes property.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions