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

[SEO] Alternate links shouldn't include GET parameters #3296

Open
divine opened this issue Jan 7, 2025 · 9 comments · May be fixed by #3320
Open

[SEO] Alternate links shouldn't include GET parameters #3296

divine opened this issue Jan 7, 2025 · 9 comments · May be fixed by #3320
Assignees

Comments

@divine
Copy link

divine commented Jan 7, 2025

Environment

Reproduction

https://stackblitz.com/edit/bobbiegoede-nuxt-i18n-starter-wyqxn9h2?file=nuxt.config.ts

Describe the bug

Hello,

Currently alternate links are broken. It's harming SEO as search engines marks this as duplicate pages. Also harmful sites could use this to boost their SEO.

Visiting:
https://example.com/en

Generates:

<link id="i18n-can" rel="canonical" href="/en">
<meta id="i18n-og-url" content="/en" property="og:url">

Visiting:
https://example.com/en?link=harmful.com

Generates:

<link id="i18n-xd" rel="alternate" href="/en?link=harmful.com" hreflang="x-default">
<link id="i18n-can" rel="canonical" href="/en">
<meta id="i18n-og-url" content="/en" property="og:url">

This should be optional and disabled by default like canonicalQueries options that we currently have.

Thanks!

Additional context

No response

Logs

@divine
Copy link
Author

divine commented Jan 8, 2025

Update: this bug was introduced in v8 so it's undocumented breaking change from v7 and should be reverted back.

@divine
Copy link
Author

divine commented Jan 15, 2025

@BobbieGoede can this be fixed, please?

@BobbieGoede BobbieGoede self-assigned this Jan 16, 2025
@BobbieGoede
Copy link
Collaborator

@divine
Been a bit busy lately but hopefully have some time to look at this in the coming days

@BobbieGoede
Copy link
Collaborator

Currently alternate links are broken. It's harming SEO as search engines marks this as duplicate pages. Also harmful sites could use this to boost their SEO.

@divine
Do you have links to resources which suggest alternate links are interpreted by search engines that way?

@divine
Copy link
Author

divine commented Jan 17, 2025

Currently alternate links are broken. It's harming SEO as search engines marks this as duplicate pages. Also harmful sites could use this to boost their SEO.

@divine Do you have links to resources which suggest alternate links are interpreted by search engines that way?

Hello,

It was working fine prior with v7 but currently it's creating a duplicate content:

See this Google article: https://developers.google.com/search/docs/specialty/international/localized-versions and there is a link Merkle SEO hreflang tag testing tool.

You can check by typing a nuxt site like http://example.com/en/?site=isharmful.com and it'll give you bunch of errors.

Also, see @ https://ahrefs.com/blog/hreflang-tags/ . No article mentions that alternate links should include get parameters - it's simply a duplicate content. You can't say to search engines: "Hey, give me a new get parameters and there is a more zillion duplicate pages!". Search engines will just sanction such site.

I don't know why and who decided this to be a good idea to include the GET parameters.
There were no SEO optimization a few years back in this library. It has been improved a lot with my contributions and the thing is that this shouldn't be touched a miles away as every wrong decision harms SEO.

Also, I don't know why my contributions are empty now, @kazupon any idea?

Thanks!

@BobbieGoede
Copy link
Collaborator

Also, I don't know why my contributions are empty now -

It looks like your contributions can still be seen on the v7 branch (https://github.com/nuxt-modules/i18n/commits/v7/?author=divine), I didn't know Github doesn't credit commits which are no longer included in the current main branch 🤔

This is not intentional but I think it's due to v8 having been built from scratch for Nuxt 3, the routing code was separated into https://github.com/intlify/routing and later reimplemented (and refactored) back into this repo again, unfortunately it is entirely possible something broke along the way.

... the thing is that this shouldn't be touched a miles away as every wrong decision harms SEO.

I understand the importance of not messing up SEO, which is why I'm trying to figure out what is the correct approach though it doesn't seem to be documented in clear language..

It doesn't help that the video included in the Google article shows an example of alternate links that do include query parameters video at example timestamp.

I don't know why and who decided this to be a good idea to include the GET parameters.

From what I can tell by looking at the tests on the v7 branch the alternate links did include query parameters in that version as well and you actually added parts of those tests 😅 I may be misunderstanding the test fixture/setup, maybe the query parameters there are intentional, just checking if the behavior actually differs from v7.

@divine
Copy link
Author

divine commented Jan 18, 2025

Hello @BobbieGoede,

I understand the importance of not messing up SEO, which is why I'm trying to figure out what is the correct approach though it doesn't seem to be documented in clear language..
It doesn't help that the video included in the Google article shows an example of alternate links that do include query parameters video at example timestamp.

It's similar to canonical links. Let me try to explain. This is a screenshot from a video:

Image

URL Alternate
http://example.com/en/page?item=1&sid123 http://example.com/en/page?item=1
http://example.com/de/page?item=1&trackingid=789 http://example.com/de/page?item=1

Google suggests stripping out all unrelated parameters so &sid123 & &trackingid=789 are removed from alternate links. GET parameters ?item=1 is kept because it's an actual query parameter that page is dependent on.

Basically, in my opinion this should be based on canonicalQueries option. If there is a canonicalQueries parameter then this should be applied to alternate links as well and if there is none then all GET parameters should be stripped out completely.

I don't know why and who decided this to be a good idea to include the GET parameters.

From what I can tell by looking at the tests on the v7 branch the alternate links did include query parameters in that version as well and you actually added parts of those tests 😅 I may be misunderstanding the test fixture/setup, maybe the query parameters there are intentional, just checking if the behavior actually differs from v7.

It's intentional there so this should be stripped out. I've a running v7 and it's stripping out GET parameters from alternate links.

Thanks!

@divine divine linked a pull request Jan 21, 2025 that will close this issue
9 tasks
@BobbieGoede
Copy link
Collaborator

It's intentional there so this should be stripped out. I've a running v7 and it's stripping out GET parameters from alternate links.

I made a reproduction to confirm whether your description matches the behavior in v7, but it doesn't appear to be the case, see https://stackblitz.com/edit/nuxt-starter-2oufh4of?file=nuxt.config.js,pages%2Findex.vue.

Update: this bug was introduced in v8 so it's undocumented breaking change from v7 and should be reverted back.

Did you patch v7 in your project to achieve this functionality or is there no change in behavior? 🤔

@divine
Copy link
Author

divine commented Jan 24, 2025

It's intentional there so this should be stripped out. I've a running v7 and it's stripping out GET parameters from alternate links.

I made a reproduction to confirm whether your description matches the behavior in v7, but it doesn't appear to be the case, see https://stackblitz.com/edit/nuxt-starter-2oufh4of?file=nuxt.config.js,pages%2Findex.vue.

Update: this bug was introduced in v8 so it's undocumented breaking change from v7 and should be reverted back.

Did you patch v7 in your project to achieve this functionality or is there no change in behavior? 🤔

Well, I've just checked it now. I was using static build (Cloudflare Pages) so that's reason why it looked like it was working correctly.

See @ https://github.com/divine/nuxt-starter-avn2janf

pnpm install && pnpm build && pnpm generate && pnpm start

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants