wads.docs_redirects¶
Redirect stubs for GitHub Pages sites whose project moved to another owner (i2mint/wads#248).
GitHub redirects repository URLs after a transfer, but not Pages: the old
<old-owner>.github.io/<project>/ returns 404. A user site serves /<project>/ only
where no project site of that name exists, so a user-site folder with one stub per moved
project is inert until each transfer and takes over the moment the old Pages site goes.
redirect_site() returns the files (relative path -> text), write_redirect_site()
writes them:
write_redirect_site({"wads": "https://i2mint.github.io/wads/"}, "old-owner.github.io")
Each project gets <name>/index.html (meta refresh + canonical link), the root gets an
index listing them, and 404.html forwards deep links (/<name>/some/page.html) for the
moved names only.
>>> files = redirect_site({"pkg": "https://new.github.io/pkg/"})
>>> sorted(files)
['404.html', 'index.html', 'pkg/index.html']
>>> 'rel="canonical" href="https://new.github.io/pkg/"' in files["pkg/index.html"]
True
Functions
|
The files of a user site that redirects each |
|
Write |
- wads.docs_redirects.redirect_site(moved)[source]¶
The files of a user site that redirects each
nameto its newurl.
- wads.docs_redirects.write_redirect_site(moved, out_dir)[source]¶
Write
redirect_site()underout_dir; return the paths written.