One repo, many sites

Two days ago, I learned through an ad that the .gay top-level domain is now widely available.

Against my better judgement, I went to the website of my domain provider and, who would have thought; software.gay was still available.

My initial idea was to just redirect it to my site, but after I shared the good news on Twitter, I was encouraged to take it one step further:

I recently had to deal with multiple versions of the same site that were linked using rel="canonical", and so I decided to create a non-canonical, gay headcanon mirror of my original site.

My website is built using the excellent Eleventy static site generator, and deployed automatically to Netlify whenever I push a new git commit on my main branch.

That meant all I had to do was create another Netlify project for software.gay and configure it to deploy a slightly different version of the same site.

Within the Netlify project, I created the environment variable ELEVENTY_ENV and set its value to gay to let my build script know who it was dealing with.

I then exposed my environment variable to Eleventy, which enabled me to write the following code in my Nunjucks templates:

{% if gay.environment == 'gay' %}
  <!-- Do gay things -->
{% endif %}

I think that is beautiful.

Thanks a lot to the Eleventy project for their flexible data handling, and Netlify for making setting up continuous deployment a breeze.