TIL: Redirecting Github Pages to Your Website
As I mentioned in my post yesterday, I needed to update my github pages blog to start pointing traffic over to this site instead. I didn’t want to just have a static link sitting on the page that would require someone to click it to be redirected. So I went searching for a solution that would allow me to automatically redirect without any interaction.
As I don’t host the github pages site on my own, there’s nothing server side that I couldn’t do with forcing the redirect. So I went looking for a way to handle it with just HTML code that could appear within the generated jekyll code.
My searches let me to finding two options for handling the redirects.
The first option is to use a header
meta tag to do the redirect. This method allows you to set a timer for when the page will be reloaded, and reload over to a different site:
In this example, the page will refresh automatically after 2 seconds of visiting the page, and then reload the browser to this blog. Neat.
timeout function to cause the redirect to trigger after n seconds:
This works very similar to the
meta tag way, kicking off the redirect after 2 seconds of loading the page.
I chose to do three things with my approach:
- Use the
- Add a static link just in case the redirect doesn’t take place.
If you want to see how it turned out, you can visit back to the old blog at https://fuzzylimes.github.io/