How to upload my hugo blog from localhost to my server?

If I understood correctly, the “public” folder contains the required files for upload. When I upload them into my server, all I see is just plain text, no graphics, no colors nothing, like the CSS is not loading or something.

My workflow:

hugo new site myblog
cd myblog
hugo new
git clone --recursive themes
hugo server --theme=hyde --buildDrafts

At the point, I have a local server, that renders the blog perfectly. All graphics, colors, fonts are absolutely fine.

the question is, how can I upload this blog on my server? I’ve tried by uploading the “public” folder, but no luck…

Hi @drpaneas,

After you have tested your site with hugo server, and removing draft = true from the *.md files you really want to publish, please make sure you make an extra hugo run like this:

hugo --theme=hyde

before you actually upload the contents inside your public/ to your web server. Otherwise, the HTML files would be left with references to http://localhost:1313/ which work great for the local hugo server, but no go for a public web server.

Issue 622 discusses creating content without any absolute paths. When this is fixed, it will solve your problem.

This needs to be made sticky or something, this question keeps popping up.

Excellent @michael_henderson :slight_smile:

What michael_henderson said ^^

…or, the TL;DR; version –you forgot to turn the ‘server’ switch off:

  • hugo server --watch to generate the preview version for developing
  • hugo to generate the production version for uploading to your server

T’is an easy mistake to make. I do it quite often –especially if I’ve just uploaded a post and spotted an annoying typo that I missed while previewing. I’ll fix the typo and then quickly upload again… only to see my site fall to bits coz [in my rush] I forgot to rebuild the production version again and just uploaded the preview version to the web.

My git-based workflow is as folows:

  • I keep my site project in a git repo, ‘pull’ it to my local machine for adding new material, then push it back to the repo.
  • Then, on my webserver I use ‘Sparse Checkout’ to pull only the “public” folder from the repo to update the ‘live’ site.

More long-winded and “non-techie” explanation here

1 Like