Skip to content

Commit

Permalink
Redirect blogs to the Ghostery homepage (#352)
Browse files Browse the repository at this point in the history
  • Loading branch information
philipp-classen authored Mar 6, 2024
1 parent 13af6b7 commit cb8bcb2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions blog/what_is_a_tracker.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ publish: True
date: 2017-07-22
tags: primer, tracking
header_img: blog/blog-trackers.jpg
redirect_url: https://www.ghostery.com/blog/what-are-trackers
+++


Expand Down
5 changes: 5 additions & 0 deletions templates/blog-page.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
{% block title %}
<title>Blog | {{blog_post.title}}</title>
<meta name="description" content="{{ blog_post.description }}">

{% if blog_post.redirect_url %}
<meta http-equiv="refresh" content="0; url={{ blog_post.redirect_url }}">
<link rel="canonical" href="{{ blog_post.redirect_url }}" />
{% endif %}
{% endblock %}

{% block og_params %}
Expand Down
8 changes: 7 additions & 1 deletion whotracksme/website/build/blog.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"date",
"tags",
"header_img",
"redirect_url",
]

def parse_blogpost(filepath):
Expand All @@ -39,9 +40,14 @@ def parse_blogpost(filepath):
print(f'WARN: {filepath}: "description" not defined; falling back to "subtitle")')
meta["description"] = meta.get("subtitle", "")

filename = filepath.split("/")[-1].replace(".md", "")
# Note: uncomment to redirect all blogs by their filename
# if "redirect_url" not in meta:
# meta["redirect_url"] = f'https://www.ghostery.com/blog/{filename}'
return {
"filename": filepath.split("/")[-1].replace(".md", ""),
"filename": filename,
"title": meta["title"],
"redirect_url": meta.get("redirect_url", ""),
"subtitle": meta.get("subtitle", ""),
"description": meta.get("description", ""),
"author": meta.get("author", "").capitalize(),
Expand Down

0 comments on commit cb8bcb2

Please sign in to comment.