Developers tend to have spare domains in excess. Some mitigate this bad buying habit by purchasing domains for a single year; if they don’t use them within a real project by then, they let them go. While I recently let my grilled cheese-related domains lapse, I still have ImprovMusical.ca, PostModernizr.com and some other equally impractical options to deal with.
I’ve been finding a way to deploy to new domains early with Surge, which we built to help front end developers easily publish and host any static files for free. Last year, Justin Jackson encouraged developers to turn one of the excess domains they had into a real side project:
…we’re paying for these domains year after year. What if we did something cool with them right now?
A great way to do this is by deploying to your unused domain as quickly as possible. We often buy domains with a side projects or simple jokes in mind, but never publish anything — suddenly, nine months have passed and we’re already getting early renewal emails.
Use your domain right away
Getting something — anything — online with your new domain name right away is key. A simple index.html file will do — depending on the project, that might be all it needs anyway.
Once deploying static files to that domain is incredibly easy, you’ll be less inclined to avoid it in the future. Adding deployment to your custom domain from the day you buy it is a powerful habit to start.
One domain I have on hand is improvmusical.ca, a site I was going to build for my sister’s theatre project. I’m sure what will come of it, but there’s nothing stopping me from getting it online right now; a simple email newsletter form is better than nothing. I might want the option to use git and GitHub later, but for now I just want an index.html file online.
Get your project online
Before I even make my email newsletter form, let’s deploy that simple index.html file. For that, I’m going to use Surge, which lets me freely deploy any static or hand-coded site right from the CLI, to a proper static CDN.
If you already have Node.js, you can install Surge using the following command:
npm install --global surge
Surge will give me the option of using a surge.sh subdomain for free, but I really want to use my own domain. So, I’ll add an CNAME record to my domain name and set it to Surge’s hostname:
(This process varies depending on your domain name provider, but there’s more specific instructions on how to add an CNAME here.)
Now, create that simple index.html file in a new folder using your text editor of choice. You can even do this right from the CLI, if you’d like:
echo "<h1>Improv Musical</h1>" > index.html
The deployment flow
Now, all that’s left is to deploy it to my domain by running the command surge inside the folder:
Running surge inside the directory you want to deploy will start the deployment. You’ll be able to create an account right from the command line, deploy, and host your site for free on Surge.
If you’re less familiar with the command line, you can even drag the folder into the terminal and then run the command.
Your project is now live on the web!
Now, I at least have something the domain is being used for, even if it’s just a headline.
Taking the project one step further
I decided to make my index file a little more useful and add a simple newsletter signup form from MailChimp and some incredibly basic styles:
Of course, depending on your project, this could be any number of things: a Gumroad embed, a Medium post, or a Bandcamp album stream. The important thing is making your site the tinniest bit more useful, and then deploying again:
surge ./ improvmusical.ca
This time, I’m passing in some shortcuts to the surge command: first, specifying the project I want to deploy (which, in my case, is the current directory or ./) and then specifying the domain I want it to go to: improvmusical.ca.
Adding a CNAME file
Now that you’re deploying more often, you probably don’t want to re-specify your custom domain name every time. Again, you can make this with your preferred text editor (there’s no file extension) or just use the command line:
echo improvmusical.ca > CNAME
Now, Surge will recognise your custom domain automatically:
Now that you’ve made use of your custom domain and actually gotten a start on your project, it will be a lot easier to make incremental improvements:
You can deploy static files anytime for free using Surge, and begin to integrate other elements of your normal workflow like git and Grunt as the project demands it. Whether you’re second-guessing a joke domain purchase from last weekend, or have been meaning to start a particular side project for years, deploying to that domain helps makes it real right away.