1
0

Added tool to update Frontmatter of Jekyll entries for redirection

This commit is contained in:
2022-01-23 16:52:03 +01:00
parent de02c13890
commit 63249e882b
2 changed files with 35 additions and 0 deletions

View File

@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8' />
<meta http-equiv="refresh" content="0; url={{ page.redirect_to }}" />
<title>CONTENT MOVED: {{ page.title }} :: {{ site.name }}</title>
</head>
<body>
<h1>The page <em>{{ page.title }}</em> moved.</h1>
If you are not being redirected automatically, please <a href="{{ page.redirect_to }}">click here</a>.
</body>
</html>

22
add_redirect_to_jekyll.py Executable file
View File

@@ -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))