Related Site as Subdomain
In a previous post I explained how to use relative paths, and created a small static site to help the explanation.
Today I added that site as a subdomain of aloneinthesea.com. I like the idea of someone potentially arriving at the paths example site, and then exploring aloneinthesea from there.
Since I already shared the previous URL of the site, I want for both URLs to work but for the old one to redirect to the new one. To achieve this I added this simple script in the head of the index file:
<!-- index.html -->
<!-- ... -->
<script>
// Check if the current URL is the GitHub Pages version
if (window.location.hostname === 'lmponcio.github.io') {
// Redirect to the Render version with custom domain
window.location.href = 'https://paths.aloneinthesea.com/';
}
</script>
<!-- ... -->
Side note: the Paths site is now hosted in Render. In the future I might move all projects to the same hosting service to manage all projects from the same web app.