4 min read

Hugo CMS & Dreamhost: Build and Deploy Niche Websites Easily

Learn to create and deploy Hugo CMS niche websites on Dreamhost with a step-by-step guide, automating the process for a seamless experience."
Hugo CMS & Dreamhost: Build and Deploy Niche Websites Easily
Photo by Microsoft Edge / Unsplash

I recently abandoned WordPress (again) for Hugo CMS on Dreamhost. This is the simplest and cheapest solution I've found for deploying Hugo CMS-based sites on a reliable and affordable host. I've been a user of Dreamhost for over 15 years and here's how I hyperscale Hugo CMS based niche websites and Dreamhost for profit.

Building a Hugo CMS-based site

It can't be any simpler than installing Hugo on your local machine and then writing content. I'm not going to go over the installation and usage of Hugo, for that, you can visit the Hugo installation documentation.

Once you've installed Hugo and have written content for your static-based niche website, then you can prepare to deploy it on Dreamhost. Deploying is as simple as running a simple script but getting it to work may require some hacking.

Deploying to Dreamhost

I used the simple rsync script example of the Hugo deployment documentation. My workflow is as follows:

  1. Write new content in Markdown
  2. Run the local Hugo dev server to verify everything is good
  3. Shutdown the Hugo dev server
  4. Run the deploy.sh script
  5. Enter my FTP user password
  6. Done

Let's look at the example script in the documentation and see how we can turn it into a deploy.sh shell script for ease of use.

The command to build your Hugo CMS site and rsync it with your remote web host (Dreamhost) is something like this:

hugo && rsync -avz --delete public/ www-data@ftp.topologix.fr:~/www/

When you call the Hugo && rysnc part in the root directory of your Hugo CMS niche website, you're telling Hugo and rsync to build your site for production and prepare it for syncing to the remote web host, Dreamhost in this case.

The -avz --delete part tells rsync to delete the extraneous files on the remote destination to keep everything tidy and up today when your new site gets pushed over.

The public/ www-data@ftp.topologix.fr:~/www/ part tells rsync to go to your public folder and grab your generated site, then go to your remote destination server of www-data@ftp.topologix.fr and sync the files to the ~/www/ folder.

The ~/www/ folder is where your website will live.

But, there's always a but, this is not what works with Dreamhost. Dreamhost has a different configuration and web server software (i.e. Apache). They have their systems set up differently, so how do you "hack" this to make it work?

Simple, use the shell script example below.

Dreamhost FTP user

If you have a Dreamhost Shared Hosting or Dreamhost VPS account, you automatically get a user attached to your website. In my case I am a user, let's call it user1 attached to my neuralmarkettrends.com hosted domain.

Each user will get an SSH key so it can identify who you are and let you do all kinds of work on the server. Dreamhost will also tell you the name of the server (their name for it, not your domain) so you can log into it as user1 using your ssh key.

For me, that looks something like this:

ssh user1@my-dreamhost-server.com

Once I pass that command on my terminal, it'll check my ssh key if it's on the list and then ask for my password. If everything matches then I'm in on the server. I can then navigate to my neuralmarkettrends.com directory and upload my Hugo CMS-generated site from the public/ folder.

The problem is doing that manually can take a long time, so the solution to automate and speed things up is to pass (almost) all my login information and then the Hugo && rsync commands to build and deploy automatically.

For that, I used the sample shell script from the documentation and modified it to match my credentials.

I'm not going to paste the original shell script for the Hugo documentation rather I'm going to post my final one, modified so as not to give you any sensitive login info.

First, I create an empty file called deploy.sh.

Then I paste this into it:

USER=dh_somedreamhost_user
HOST=my_server.dreamhost.com
DIR=/home/dh_somedreamhost_user/neuralmarkettrends.com  # the directory where your web site files should go

hugo && rsync -avz --delete public/ ${USER}@${HOST}:${DIR} # this will delete everything on the server that's not in the local public folder 

exit 0

Then I save the deploy.sh file and go to the command terminal.

I type chmod +x ./deploy.sh to make it executable and then run it by simply calling it like so: ./deploy.sh

That's it.

Hugo CMS and Dreamhost Together

In summary, I explained how to deploy a Hugo CMS-based niche website on Dreamhost, the most affordable and reliable hosting service I've found. It works for me. The process involves installing Hugo CMS locally, creating content for the static-based niche website, and deploying it on Dreamhost. The deployment process uses a simple rsync script as suggested in Hugo's deployment documentation.

To deploy the site, all you need to do is the following six steps:

  1. Write new content in markdown.
  2. Run the local Hugo development server to verify the content.
  3. Shutdown the Hugo development server.
  4. Run the deploy.sh script.
  5. Enter the FTP user password and upload.
  6. Done.

The simplest thing to use is a modified shell script (example provided) to automate the deployment process on Dreamhost. The script uses the user's credentials, the server's hostname, and the destination directory to build and deploy the website automatically.


The Fine Print

Terms of Service | Disclaimer | Affiliate Disclaimer