Add canonical links to new website#97
Open
Marcono1234 wants to merge 2 commits into
Open
Conversation
Follow-up for bbb71e0 Otherwise running `generate-html.py` will overwrite those changes.
This hopefully makes search engines prefer the new site.
Marcono1234
commented
Feb 17, 2026
| if file_name.startswith("assertj-core") or file_name.startswith("assertj-news"): | ||
| return "https://assertj.github.io/doc/" | ||
| if file_name.startswith("assertj-db"): | ||
| return "https://assertj.github.io/doc/#assertj-db" |
Author
There was a problem hiding this comment.
Not sure if using a URL fragment (e.g. #assertj-db here) has any / the desired effect here.
https://developers.google.com/search/docs/crawling-indexing/consolidate-duplicate-urls says:
Don't specify a URL fragment as canonical
(not sure if that refers to a fragment relative to the current page, or fragments in general)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This hopefully makes search engines prefer the new site, see https://developers.google.com/search/docs/crawling-indexing/consolidate-duplicate-urls
At least for me Google and Ecosia still return the old site as one of the first search results.
I have only added the canonical link to the pages which exist on the new site for now.
Note
I am not that familiar with how canonical links work, whether using them here is the best approach and whether this might have undesired side effects. So feel free to reject this pull request if you don't think it is worth it.