Created
December 16, 2021 22:33
-
-
Save StevenClontz/bac32e094d0cf837872f027e3b415507 to your computer and use it in GitHub Desktop.
Redirecting a PreTeXt book
This file contains 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
# FIRST, copy (not move) your HTML into the desired directory you wish to redirect to using your filesystem | |
# you can delete any non-HTML files at the original location, at least, only HTML can be redirected | |
import os | |
# current path to PreTeXt-generated HTML from working directory | |
current = os.path.join("docs") | |
# relative path to redirected HTML from current, default assumes move from ./docs to ./docs/archive-2021 | |
redirect = os.path.join("archive-2021") | |
for filename in os.listdir(current): | |
if filename.endswith(".html"): | |
html = f'<html><head><meta http-equiv="refresh" content="0;url=./{filename}" /></head><body>Redirecting...</body></html>' | |
with open(os.path.join(current,filename),"w") as f: | |
f.write(html) | |
else: | |
continue |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment