Since hugo is so fast, it is easy to write and develop your site on a local machine. However, when it comes to deploying, I am still uploading the files to my VPS by hand.
So, do you guys have some tips and tricks for a fast and easy deployment strategy? Do you use rsync, bittorent sync, git, something else?
I apologize for the roughness of it; consider it a first draft. I’d appreciate your comments or questions, so that I can clarify the rough points. I did run through these directions myself just now and they seemed to work fine, for the most part.
The only major stumbling point is in step 1, setting up a Hugo site. I couldn’t figure out how to include themes via submodule in the bare remote on my server (my site was first built before Hugo had themes). If anybody can help me with what to do at that point, I’d appreciate it. The workaround is to create your own layout files and not use a theme.
When I am ready to publish for public consumption I use an alternative launch of hugo from a “production” bash script to direct the Hugo rendering to an alternate directory that is set to automatically sync (goodsync) to an S3 bucket that is referecened by my domain url.
Although I wish my script could also change the baseurl in the config file for the production run. So at this time I edit that first and the edit it back. There were other discussions about getting Hugo CL to accept alternate config files. To me that would work nicely with the way I do things.
What has been decided on development/producntion workflows?
Why do you need to change the baseurl for production? When running locally, hugo will automatically swap out your baseurl’s domain for localhost:1313, so you shouldn’t need a different baseurl at all.
I’ve been using Grunt for things and love it. So I can run “grunt dev” and “grunt deploy” and so on. Of course this requires Node.js (but only on your machine, not your server). You also easily gain the ability to run various commands on things, like minifying CSS, JS, etc. The other cool thing is I pop open a web browser when I type “grunt dev” so it starts Hugo and opens up to my site (see the “open:devserver” command).
Here’s my package.json so if anyone wants, they could basically copy this and run npm install. Then have The same grunt commands to use. Ensure this goes alongside your Hugo site. Or in other words, “public” and “themes” and “layouts” should all be sitting next to your Gruntfile.js and package.json.
For people who use gh-pages on GitHub, I highly sugges using the approach/script below instead of the subtree method. This creates much less comit-noise (avoide the double commit …):
@spf13 first post here - first, thank you for Hugo. It seems like a great environment, with a vibrant community.
That rsync deploy makes sense to me, but, are you keeping any part of your site’s source tree in a git repo as well? How are you getting around the theme submodule issue mentioned in this thread.
Can anyone tell me what I’m doing wrong? Seems canonical links are in the demo code, but not my headers. I’ve followed these instructions exactly, so many times. It must be something simple I’m missing, thanks.
You are using the Lanyon theme that you fetched from https://github.com/spf13/hugoThemes, right? If so, please take a look inside themes/lanyon/layouts/partials/head.html and see how the links to the stylesheets are defined?
Yes, you got it. The current Hugo port of Lanyon theme assumes that your website is placed in the root directory of your domain. Since you have placed your blog under the /hblog subdirectory, that theme does not work out of the box.
How to fix it? Try using the hyde or herring-cove themes instead. These were ported by Hugo’s author @spf13 himself, so this subdirectory issue has been taken care of.
Both hyde and herring-cove work great, right? Good! Now, as an exercise for you, please examine the partials in hyde and herring-cove, and figure out what you need to do to get the Lanyon theme to do the same, i.e. to be able to load your CSS properly.
So, no, I don’t think the CSS-fails-to-load issue has anything to do with http://gohugo.io/tutorials/github-pages-blog/ . Your blog has been deployed correctly. It is just that you’ll need to tweak your “partials” to generate the desired HTML output to load the CSS files properly.
I don’t think the demo makes it obvious in any way this needs to be done, and it very much appears that the site will be served to a subdirectory of your github account.
I’ve seen lots of discussion about how to make Hugo approachable to ‘normals’ and this is where I’d start! If I can I’ll try to fork and edit myself.
Thank you for discovering these issues with our tutorials! You are absolutely right that we need to make Hugo approachable to newcomers, and fixing such problems our tutorials should be a top priority for our community indeed.
I am sorry that I spoke before I read—I did not read through the whole Host on GitHub Pages | Hugo tutorial myself, and did not know it specifically mentions the use of the Lanyon theme.
Anyhow, moving forward, we have a few action items to work on:
Fix issues in Host on GitHub Pages | Hugo especially caveats when hosting in a subdirectory and how the {{ .Site.BaseUrl }} needs to be added to layouts/partials/*.html or layouts/chrome/head_includes.html as necessary. Also, if possible, update to Hugo v0.12 conventions.
Looking yet deeper into this, it seems that the real reason @cloudunicorn ran into problem was not because @spencerlyon2 forgot to put in {{ .Site.BaseUrl }}, but rather, it was not necessary to add {{ .Site.BaseUrl }} with Hugo v0.9 or Hugo v0.10, the latest stable version when @spencerlyon2 wrote his tutorial, because Hugo v0.10 by default “canonify”, i.e. automatically add the baseurl to all relative URLs!
Hugo v0.9 (2013-11-15): “Canonify” or “canonicalize” all relative URLs. Not configurable.
Hugo v0.10 (2014-03-01): Added canonifyurls option to keep URLs relative. The default is canonifyurls = true as documented, i.e. same as Hugo v0.9.
commit 438c2198923022a3e4d299b06a7df18268041dd8
Author: Phil Pennock pdp@spodhuis.org
Date: Fri Jan 3 18:36:53 2014 -0500
Add canonifyurls config option.
Be able to inhibit AbsURL canonicalization of content, on a site configuration basis. Advantages of being able to inhibit this include making it easier to rendering on other hostnames, and being able to include resources on http or https depending on how this page was retrieved, avoiding mixed-mode client complaints without adding latency for plain http.
Hugo v0.11 (2014-05-29): Somehow, the default seems to have become canonifyurls = false without anyone noticing, and without documentation change. Bug?
Hugo v0.12 and v0.13-DEV as of today: Ditto.
I wonder what happened… Hmm… More investigation needed, to find out which commit between v0.11 and v0.12 is responsible for the undocumented behaviour change, i.e. bug.
So, yet another possible answer to your question, @cloudunicorn, is simpler: Rather than adding {{ .Site.BaseUrl }} manually, you may alternatively add canonifyurls: true to your config.yaml, which will result in a correct and identical HTML with the correct URLs to your stylesheets.