Add rel=canonical to most old html files. #39
Merged
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.
rel=canonical is supposed to be helpful for search engine to know
which pages a search engine should promote.
This is not a redirect.
If a file exists and is not in a versioned (x.y.z) folder; consider it
as a potential "canonical" target
If a file exist in a versioned doc of matplotlib make its rel=canonical
point to the corresponding candidate.
Example:
Special case the
examples
andgallery
folder.The
examples
folder is from old matplotlib version (2.0.2) but stillquite popular on Google; special case.
Apply the same rule as above but from withing
examples
towardgallery
:/gallery/path/to/foo.html -> candidate as being canonical
/example/path/to/foo.html > set rel=canonical to matplotlib.org/gallery/path/to/foo.html
This took care of 145 files.
Many examples were "moved" during examples -> gallery transition. If
filename is unique in gallery; use this as a potential heuristic for
detecting move:
/gallery/path/to/verryuniquename.html -> candidate as being canonical as the filename is unique !
/example/old/location/verryuniquename.html > set rel=canonical to matplotlib.org/gallery/path/to/verryuniquename.html
This took care of 185 files in example
Leaving 271 "orphan"
Resolve chain of rel-canonical. Fix links that point to example
that themselves point to gallery.
/gallery/path/to/verryuniquename.html
/example/old/location/verryuniquename.html -> matplotlib.org/gallery/path/to/verryuniquename.html
/2.0.2/example/old/location/verryuniquename.html -> should point to /example/....
make it point to /gallery/....
No files with existing rel=canonical have been touched. This will
likely only affect pre-3.0 documentation files.
Obviously scripted, but kind of ugly:
https://gist.github.com/Carreau/d2b3e36b65d4155827539ef462860444
I paid attension to avoid doing any other changes than adding a single line to target files; so can try to do changes.