skip to content
blog.metters.dev

Forwarding your GitHub Pages link to custom domain

/ 1 min read

GitHub Pages offer a free hosting service for static sites. The setup is simple and concisely described on pages.github.com. To enable this feature all you have to do is to create a public repo named ${your-github-username}, e.g. “metters”.

I am hosting my site somewhere else, so I would like to forward from metters.github.io to there. All I had to do is adding a file named CNAME containing the url to forward to, e.g. blog.metters.dev.

Requests to “metters.github.io” are now being forwarded:

Terminal window
curl metters.github.io
<html>
<head><title>301 Moved Permanently</title></head>
<body>
<center><h1>301 Moved Permanently</h1></center>
<hr><center>nginx</center>
</body>
</html>

Let’s see where the redirect leads to (not without filtering out some noise)

Terminal window
# Use "location" to follow redirects; "sed" to retrieve the title of the body of the response
# Get anything between the "<title>" tags and print it
curl --silent --location "metters.github.io" | sed -n 's/.*<title>\(.*\)<\/title>.*/\1/p'
<html>
Home • blog.metters.dev
Logo
</html>

Resources