How do I host my hugo site on Digital Ocean?

Hi everyone,

I just built my small company site locally using Hugo. I don’t know very much about networking and cloud hosting but I already have a Digital Ocean account with free credits and would like to host my site there. I have my domain name on namecheap. I was about to pay for the $5 per month server but got overwhelmed with the options and cannot find a comprehensive beginners guide to hosting on Digital Ocean.

Would anyone be able to assist me with the steps to getting my site running?

Hi @LadySith Are you 100% committed to digital ocean before I give any advice? Also, is your site source currently in a hosted git service?

Hi @rdwatters

Yes I am committed to using Digital Ocean. I’m not using any git service. All my files are local. Would using a git service make this easier?

Depends on how badly you need version control. If not hosted, I assume you have it in version control locally, yes?

I asked specifically about whether you have it in GitHub or Bitbucket because I was being lazy and was going to tell you to just sign up for Netlify and have them take care of all the backend/hosting pieces you might not want to take care of. Let me look into DO’s docs…

I don’t minding hosting it on github if that would be easier. I already have a personal page hosted there anyway. Would I be able to just host this for free as a company page on github? Would this be the same procedure used to host personal sites on github but on an organisation page?

I believe so, yes:

Honestly, I’d still recommend Netlify…you can probably get away with the free tier (or spring for $9/month), and they take care of everything for you. Both GH Pages and Netlify hosting walkthroughs have been updated on the docs concept site within the past couple weeks:

I agree with @rdwatters – Digital Ocean is a great choice for many things, but isn’t a perfect fit when it comes to static site hosting (my guess your credits will dry out at one point, and then you start to pay – and there are better and cheaper options out there for this use case).

  • Netlify is the simplest and probably your best bet.
  • Amazon and Google also have good static hosting options

Alright. Thanks @rdwatters and @bep. I think I’ll just try netlify or github then. They both look way easier to set up. Glad I didn’t lose any sleep over this :slight_smile:

1 Like

@rdwatters I decided to with Netlify and Github. I followed the Netlify instructions but I seem to be getting this error.

5:58:06 PM: Build started
5:58:07 PM: Fetching cached dependencies
5:58:07 PM: Expected build cache - but failed to find it
5:58:07 PM: No cached dependencies found. Cloning fresh repo
5:58:07 PM: git clone
5:58:09 PM: git remote rm origin
5:58:09 PM: Preparing Git Reference refs/heads/master
5:58:10 PM: Building site
5:58:10 PM: Running build command
5:58:11 PM: v6.10.1 is already installed.
5:58:12 PM: Now using node v6.10.1 (npm v3.10.10)
5:58:12 PM: Using version v6.10.1 of node
5:58:12 PM: Using /opt/buildhome/.rvm/gems/ruby-2.1.2
5:58:12 PM: Started building sites ...
5:58:12 PM: Error: Error building site: No source directory found, expecting to find it at /opt/build/repo/content
5:58:13 PM: Cleaning up docker container
5:58:13 PM: Error running command: Build script returned non-zero exit code: 255
5:58:13 PM: Error running command: Build script returned non-zero exit code: 255
5:58:14 PM: Finished processing build request

When I followed the instructions as listed, it formatted my folder structure to put my site in a “data/” folder but I did follow the instructions. So I’m uncertain whether that is actually the issue

[Edit] Never mind…i can get it from the terminal above :wink:

/cc @digitalcraftsman (since he ported the theme, but maybe we can just figure this out).

So a few things…

If you are using Netlify, you don’t need to follow the convention of <username> for naming your repo. GitHub reserves this repository name for GitHub Pages websites. So, GH is looking to build your site from that repo (likely the master branch by default) and that’s why it’s pulling your for the content for your site’s index page. See what I mean here:

So the question is whether you want to a) host on Netlify or b) Host on GitHub Pages?

I’m going to assume Netlify, so the issue looks like you need to make sure that you are keeping an (empty) content directory. If you are familiar with the command line…

  1. cd path/to/MakerHut/
  2. mkdir content && cd content && touch .gitkeep

This tells git to keep that folder in the repository even though it’s empty. This fixes the problem for me when running your site locally.

  1. Now you should probably change the name of the repo so that GitHub pages stops building that weird page. You can do this in the repo’s settings as the first option.

Let me know if this works and we can take it from there!

P.S. MakerHut seems like a very cool project in Zambia. I wish you the very best of luck :smile:

Yeah it looks like it worked :smiley: Now all I have to do is point our domain there. Going through the site tutorials for that right now. Thanks so much for your help. And thanks, I’m really excited to be working on MakerHut :blush:

1 Like