diff --git a/add_redirect_to_jekyll.layout.html b/add_redirect_to_jekyll.layout.html new file mode 100644 index 0000000..d6ce0fa --- /dev/null +++ b/add_redirect_to_jekyll.layout.html @@ -0,0 +1,13 @@ + + + + + + CONTENT MOVED: {{ page.title }} :: {{ site.name }} + + +

The page {{ page.title }} moved.

+ + If you are not being redirected automatically, please click here. + + diff --git a/add_redirect_to_jekyll.py b/add_redirect_to_jekyll.py new file mode 100755 index 0000000..e9e5dec --- /dev/null +++ b/add_redirect_to_jekyll.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + +import csv +import frontmatter + +NEW_LAYOUT = "redirect" + + +with open("jekyll2s9y_urls.csv", "rt") as f: + for row in csv.DictReader(f): + jekyll_file = row["jekyll_path"] + print("Modifying file {}".format(jekyll_file)) + fm = frontmatter.load(jekyll_file) + if fm["layout"] == NEW_LAYOUT: + print("Already processed. Skipping.") + continue + fm["layout_old"] = str(fm["layout"]) + fm["layout"] = NEW_LAYOUT + fm["redirect_to"] = row["s9y_url"] + frontmatter.dump(fm, jekyll_file) + #print(repr(fm.metadata))