Migrating my blog to Jekyll & Github pages
My website was down for years, and recently I decided to bring it back up using GitHub Pages
. While working on that, I bumped into Jekyll and decided to migrate my blog to this awesome SSG tool instead of Ghost.
To be able to host both my website and my blog on GitHub Pages
, I decided to move my blog URL to domain.com/blog
instead of blog.domain.com
and by using Cloudflare
redirection rules, I made sure that any request to an old blog post will get redirected ( 301 - Permanent Redirect
).
Then the Copy & paste
journey started to find out that Jekyll
is using a different URL schema than Ghost
. The old post URLs were just the post title with dashes in between. For example blog.domain.com/blog-post-title/
but Jekyll expects you to use the following format for your blog post files /_posts/YEAR-MONTH-DAY-title.MARKUP
which sets both the post date and its URL. So if your post file is /_posts/2022-01-24-hello-world
the post date would be 2022-01-24
and the URL would be /2022/01/24/hello-world.html
so I did a quick search to find this Jekyll plugin that allows you to set some redirection configurations for your posts which was enough to make some aliases for the old URLs to redirect the request to the new one.
So by combining both Cloudflare
rules and that redirection plugin if someone visits any of my old URLs like https://blog.morad-edwar.com/your-own-wireguard-vpn-server-in-5-minutes/ they would land to the new one https://www.morad-edwar.com/blog/2017/05/25/your-own-wireguard-vpn-server-in-5-minutes.html.
And now I can go and shutdown my Ghost
server ….