Skip to content

Conversation

thesmiler
Copy link
Contributor

In the past we had a static canonical link to material.angular.dev/ for all pages that got dynamically updated to the correct URL.

However Search engines sometimes don't seem to parse the JS and in this case having the canonical point to material.angular.dev/ seems worse than having it not present as it prevents pages from being indexed.

@thesmiler thesmiler requested a review from a team as a code owner September 5, 2025 10:00
@thesmiler thesmiler requested review from JeanMeche, crisbeto and ok7sai and removed request for a team September 5, 2025 10:00
@angular-robot angular-robot bot added the area: docs Related to the documentation label Sep 5, 2025
@thesmiler thesmiler removed the request for review from ok7sai September 5, 2025 10:01
@thesmiler thesmiler added the target: patch This PR is targeted for the next patch release label Sep 5, 2025
canonicalLink.setAttribute('rel', 'canonical');
canonicalLink.setAttribute('href', fullPath);

const title = this._document.head.querySelector('title');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems a bit convoluted. We can just do document.head.appendChild(canonicalLink).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had that first but then thought that the search engine might not process the canonical (with the same priority) if it's at the very end of the long even below the long <script> tag. But given that this would be only for a search engine that runs JS - this is probably silly.

@thesmiler thesmiler added the action: merge The PR is ready for merge by the caretaker label Sep 8, 2025
@crisbeto crisbeto merged commit 45f7f49 into angular:main Sep 8, 2025
25 checks passed
crisbeto pushed a commit to crisbeto/material2 that referenced this pull request Sep 8, 2025
* docs: delete static canonical link

* docs: insert, not update dynamic canonical link

* docs: always append tag when inserted
adolgachev pushed a commit that referenced this pull request Sep 8, 2025
* docs: delete static canonical link

* docs: insert, not update dynamic canonical link

* docs: always append tag when inserted
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Oct 9, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

action: merge The PR is ready for merge by the caretaker area: docs Related to the documentation target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants