Skip to content

Instantly share code, notes, and snippets.

Created December 16, 2021 22:33
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Redirecting a PreTeXt book
# 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:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment