Monadical-SAS / monadical.com

🖥️ Custom Flask + Jinja2 static site generator and content powering Monadical.com
https://monadical.com
10 stars 4 forks source link

2 urls are created for each page (with and without .html) and that hurts SEO #141

Open GorvGoyl opened 1 year ago

GorvGoyl commented 1 year ago

Currently, there are two pages generated for the same content, one with .html at the end and one without. Ideally, .html page should redirect (301) to the other one to improve SEO and content deduplication

screenshot 2022-08-08 at 22 27 51@2x

Also need to remove .html from all internal links screenshot 2022-08-10 at 22 22 19@2x

GorvGoyl commented 1 year ago

this site is using GH pages, and it looks like GH doesn't provide a way to redirect pages. improvements that can be done:

https://stackoverflow.com/questions/21244910/remove-html-extension-from-github-pages

GorvGoyl commented 1 year ago

tried 2 ways I could think of:

  1. remove .html from content.json, which is responsible for mapping URL to html pages:
--- a/content.json
+++ b/content.json
@@ -9,7 +9,7 @@
     },
     "about": {
       "title": "About",
-      "url": "/about.html",
+      "url": "/about",
       "template": "about.html"
     },
     "blog": {

issue: works in dev server but doesn't work in local prod server after building output. about page is getting generated without the .html extension. it most likely won't work after deploying to github server as pages extensions are removed.

  1. replace .html from links using jinja2 replace filter
--- a/templates/base.html
+++ b/templates/base.html
@@ -157,7 +157,7 @@
                         <li>
                             <b>Monadical</b>
                         </li>
-                        <a href="{{PAGES.blog.url}}">Blog</a>
+                        <a href="{{PAGES.blog.url|replace('.html','')}}">Blog</a>
                         <li><a href="{{PAGES.services.url}}">Services</a></li>

issues: links won't work in dev server and local prod server after building output, but it'll work after deployment as github server maps links w/o .html at end to .html files with same name. screenshot 2022-08-23 at 01 17 07@2x