Skip to content
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

Build output has canonical link linking to the same URL as another alternate link, leading to SEO issues #3099

Open
WaldemarEnns opened this issue Sep 13, 2024 · 10 comments
Assignees
Labels
❗ p4-important Priority 4: bugs that violate documented behavior, or significantly impact perf SEO Related to SEO features such as head tags

Comments

@WaldemarEnns
Copy link

WaldemarEnns commented Sep 13, 2024

Environment

❯ npx nuxi info
Working directory: /home/projects/github-q5ddsy                                17:08:17
Nuxt project info:                                                             17:08:17

------------------------------
- Operating System: Linux
- Node Version:     v18.20.3
- Nuxt Version:     3.13.1
- CLI Version:      3.13.1
- Nitro Version:    2.9.7
- Package Manager:  [email protected]
- Builder:          -
- User Config:      compatibilityDate, devtools, modules, pages, routeRules, i18n
- Runtime Modules:  @nuxtjs/[email protected]
- Build Modules:    -
------------------------------

                                                                               17:08:17
👉 Report an issue: https://github.com/nuxt/nuxt/issues/new?template=bug-report.yml
👉 Suggest an improvement: https://github.com/nuxt/nuxt/discussions/new
👉 Read documentation: https://nuxt.com

Reproduction

Reproduction here:

https://stackblitz.com/edit/github-q5ddsy-62oh2a?file=.output%2Fpublic%2Findex.html

Summary: Using nuxt-i18n with a default language and a translated language

Describe the bug

Please check the output index.html at

  • either live in your browser
  • build the project with npx nuxt build --preset github_pages

Take a look at the auto-generated <link> elements, especially the rel="alternate" & red="canonical":

<link id="i18n-alt-en" rel="alternate" href="https://example.com/en" hreflang="en">
<link id="i18n-alt-en-US" rel="alternate" href="https://example.com/en" hreflang="en-US">
<link id="i18n-alt-de" rel="alternate" href="https://example.com" hreflang="de">
<link id="i18n-alt-de-DE" rel="alternate" href="https://example.com" hreflang="de-DE">
<link id="i18n-xd" rel="alternate" href="https://example.com" hreflang="x-default">
<link id="i18n-can" rel="canonical" href="https://example.com">

Notice, that the same URL https://example.com is being referred to, from:

<link id="i18n-xd" rel="alternate" href="https://example.com" hreflang="x-default">
<link id="i18n-can" rel="canonical" href="https://example.com">
<link id="i18n-alt-de" rel="alternate" href="https://example.com" hreflang="de">

That leads in SEO indexing/crawling, to an issue:

  • Bing Webmaster tools are complaining about the canonical link, referring to a link that is already marked as an alternative translation
  • Google Search Console is complaining about the same issue

URL that I requested indexing for: https://waldemarenns.de/

Bing Webmaster Tools:

URL cannot be indexed by Bing
The URL is not indexable as the page is an alternate version of the similar page which you have specified as canonical version using a <link rel="canonical"> tag. Bing does not index the alternate version.
Canonical URL :https://waldemarenns.de/en

Screenshot:

canonical issue

Google Page Speed Insights:

Document does not have a valid rel=canonicalPoints to another `hreflang` location (https://waldemarenns.de/)

Screenshot:

canonical issue google page speed insights

Take a look: https://pagespeed.web.dev/analysis/https-waldemarenns-de/30jj8518lg?form_factor=desktop

ℹ️ Feel free to inspect my site that is mentioned.

Additional context

Refers to #2925

Logs

No response

@memic84
Copy link

memic84 commented Sep 17, 2024

We have the same issue. Just check the head of https://orakel.com/ and you'll see duplicate alternate link for the i18n Link.

@memic84
Copy link

memic84 commented Sep 25, 2024

@WaldemarEnns Why the confused emoji? Aren't you getting the same alternate links (href) on all the locales?

image

@BobbieGoede BobbieGoede added ❗ p4-important Priority 4: bugs that violate documented behavior, or significantly impact perf SEO Related to SEO features such as head tags and removed pending triage labels Sep 25, 2024
@BobbieGoede BobbieGoede self-assigned this Sep 25, 2024
@BobbieGoede
Copy link
Collaborator

Sorry for the late response, was a bit swamped with other things, I'll be investigating this issue in the coming days.

@WaldemarEnns
Copy link
Author

@memic84 I just wanted to express that I am struggling with the same issue 😀 Yes, I get the same results.

@BobbieGoede thanks!

@BobbieGoede
Copy link
Collaborator

@memic84
In your case I can see (based on the compiled code) that you're not using the latest release, so I can't exclude it already having been fixed.

Your issue differs from the that of @WaldemarEnns, and I can't reproduce your issue with their provided reproduction, could you open a new issue with a minimal reproduction preferably using the latest version? 🙏

@memic84
Copy link

memic84 commented Sep 25, 2024

@BobbieGoede Thank you for the quick check, and indeed i see that i have missed some releases from the last 2 weeks. If this still occurs, i'll open a new issue.

@WaldemarEnns Ah, didn't get the emoji :) seems after all a different issue.

@BobbieGoede
Copy link
Collaborator

@memic84
Also, make sure you have a baseUrl configured https://i18n.nuxtjs.org/docs/guide/seo#requirements, it seems to be unset currently.

@BobbieGoede
Copy link
Collaborator

@WaldemarEnns
I'm getting the impression the issue is caused by the Bing/Google crawlers being redirected to .de/en while trying to view .de/ 🤔

@WaldemarEnns
Copy link
Author

@WaldemarEnns I'm getting the impression the issue is caused by the Bing/Google crawlers being redirected to .de/en while trying to view .de/ 🤔

Are you sure? IMO the canonical and alternate link should both not exist at the same time and point to the same URL e.g. https://waldemarenns.de - or am I wrong?

@BobbieGoede
Copy link
Collaborator

The rules for meta tags are quite complex and the documentation is fragmented (I get lost every time I need to refresh my memory).

From what I understand the canonical link should point to the preferred (duplicate/original) URL for the current page, while alternate link should point to all alternates of the current page including the current page itself (see google video for reference at timestamp https://www.youtube.com/watch?v=8ce9jv91beQ&t=588s).

Relevant docs:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
❗ p4-important Priority 4: bugs that violate documented behavior, or significantly impact perf SEO Related to SEO features such as head tags
Projects
None yet
Development

No branches or pull requests

3 participants