Which @angular/* package(s) are the source of the bug?
Don't known / other
Is this a regression?
No
Description
I'm not entirely sure if this should be considered a bug, feature request or if there is an existing solution to this problem that's unrelated to Angular itself, but I have gotten nowhere on this problem for months so it would be good to at least get an official statement on this.
Basically, when using hydration, any http requests made will have their response added inside <script type="application/json"> tags in the HTML returned by the server. In our case, we get JSON data from a CMS and this data contains relative links such as { "foo": "/bar" }.
The problem is, Google seems to think these should be indexed as https://oursite.com/bar, which leads to big problems for us since we have localized routes with i18n, meaning this example link should be https://oursite.com/sv/bar but Google doesn't understand this even with a base href set to /sv/.
It also indexes urls that doesn't exist as long as the text starts with a slash like /month which is common when displaying prices for example.
Since these script tags are created by Angular itself, I feel like I have no control over this behaviour. Even if I did, I wouldn't know how to make Google ignore these script tags used for hydration purposes.
One suggestion that was given to me by an SEO person was to extract the inline JSON into a JSON-file and mark that file as noindex, but this doesn't seem possible either when reading the docs for hydration.
Please provide a link to a minimal reproduction of the bug
No response
Please provide the exception or error you saw
Please provide the environment you discovered this bug in (run ng version)
Angular CLI: 20.3.8
Node: 22.12.0
Package Manager: npm 10.9.0
OS: darwin x64
Angular: 20.3.9
... common, compiler, compiler-cli, core, forms
... language-service, localize, platform-browser
... platform-browser-dynamic, platform-server, router
Package Version
---------------------------------------
@angular-devkit/architect 0.2003.8
@angular-devkit/build-angular 20.3.8
@angular-devkit/core 20.3.8
@angular-devkit/schematics 20.3.8
@angular/build 20.3.8
@angular/cli 20.3.8
@angular/ssr 20.3.8
@schematics/angular 20.3.8
rxjs 7.8.2
typescript 5.9.3
Anything else?
No response
Which @angular/* package(s) are the source of the bug?
Don't known / other
Is this a regression?
No
Description
I'm not entirely sure if this should be considered a bug, feature request or if there is an existing solution to this problem that's unrelated to Angular itself, but I have gotten nowhere on this problem for months so it would be good to at least get an official statement on this.
Basically, when using hydration, any http requests made will have their response added inside
<script type="application/json">tags in the HTML returned by the server. In our case, we get JSON data from a CMS and this data contains relative links such as{ "foo": "/bar" }.The problem is, Google seems to think these should be indexed as
https://oursite.com/bar, which leads to big problems for us since we have localized routes with i18n, meaning this example link should behttps://oursite.com/sv/barbut Google doesn't understand this even with a base href set to/sv/.It also indexes urls that doesn't exist as long as the text starts with a slash like
/monthwhich is common when displaying prices for example.Since these script tags are created by Angular itself, I feel like I have no control over this behaviour. Even if I did, I wouldn't know how to make Google ignore these script tags used for hydration purposes.
One suggestion that was given to me by an SEO person was to extract the inline JSON into a JSON-file and mark that file as
noindex, but this doesn't seem possible either when reading the docs for hydration.Please provide a link to a minimal reproduction of the bug
No response
Please provide the exception or error you saw
Please provide the environment you discovered this bug in (run
ng version)Anything else?
No response