Added tool to update Frontmatter of Jekyll entries for redirection
This commit is contained in:
13
add_redirect_to_jekyll.layout.html
Normal file
13
add_redirect_to_jekyll.layout.html
Normal 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
22
add_redirect_to_jekyll.py
Executable 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))
|
||||
Reference in New Issue
Block a user