
How to start a blog using Hugo - flaviocopes
https://flaviocopes.com/start-blog-with-hugo/
======
ealexhudson
I recently moved my blog over from Wordpress to Hugo. I think it must be a lot
easier to start out from scratch than to migrate something existing; some
parts of Hugo are substantially less than straightforward.

I certainly don't regret the move - much happier having a static site than WP
in place - but some of this is much more complex than I had hoped it would be.
Amongst other issues;

* error messages can be extremely opaque (although usually easy to google, at least) * upgrading to new versions is not always straightforward

I deploy my site via rsync, but got bitten immediately by a very odd bug with
respect to file timestamps (#6161) where a bunch of my files were warped back
to the 1750's.

I personally am happy with hugo. I probably wouldn't recommend it at this
point though...

~~~
stiray
Similar issues from my side. Cryptic documentation, bad dissorganized forum
and configuration,... I love the hugo idea but to find one detail you will get
into chaos of strange wording and noise. I am using it but I try to configure
as small amount as possible as I always get into some undesired behaviour. It
seems like it was from begining build with idea and then continued by patch
over patch over patch. Cant recomend it either.

~~~
Moru
I decided I would make a static site the old fashioned way on neocities.org
and happily got started. And then I remembered all the double work you have to
do linking and making lists and repeating headers/footers (or use frames) and
so on. Now I'm back to looking for some simple script that can output static
sites without having to spend a month learning a new tool...

~~~
japanoise
It's a mess, and evokes abject horror in some people, but I'll continue to
defend the merit of just writing a shell script. I moved it to hugo years ago
(ironically) but my old site worked like that:
[https://github.com/japanoise/website/blob/cdf728d4ebea75cbc9...](https://github.com/japanoise/website/blob/cdf728d4ebea75cbc9a03f435d5cdfc78af8f9a5/buildsite.sh)

It's not pretty to look at, but it can be read, understood, and maintained by
one person.

~~~
Moru
I'm pretty sure my problem with everything I tried so far was that it wasn't
me building it so I guess I just have to make some simple script to do it for
me some day.

------
cyberferret
The author seems adamant that blog.domain.com is a worse setup than
domain.com/blog - I've seen this argument go back and forth a lot, with both
sides claiming advantages and disadvantages.

I am interested to hear the consensus from HN users as to which is better, and
why.

~~~
zirobi
It's not a matter of one being objectively better than the other but which
suits your needs.

The basic distinction, from a purely SEO perspective, is that blog.domain.com
will be treated as its own entity whereas domain.com/blog will be treated as
part of the main domain.com entity.

The question you have to ask yourself is whether you want to bolster the
"value" of your main domain or if you want your blog to be an asset in its own
right.

There is no right or wrong answer — there is simply what's best for your
situation.

~~~
michaelbuckbee
Objectively better for SEO - and in particular if this isn’t a personal blog,
but say a marketing site for your SAAS and then an accompanying blog. Having
them in separate domains with very similar content hurts you

This has been fairly well beaten into the ground at this point.

~~~
toddmorey
I’d say objectively safer. Google is getting better at reconciling content
split across subdomains as coming from a common source. Some Google experts
have called it pretty much a solved problem, but I don’t think the data plays
that out just yet. I do believe there will soon be a time that subdomain vs
subfolder won’t matter for SEO. Just not quite there yet.

------
ThinkBeat
I keep wanting to use Hugo, and I have made a few attempts. Moving away from
Wordpress and its problems would be good.

I do think a few features are missing that I find valuable:

* Search (you can add it as an external service I haven't found one I trust and like yet. * Comments, there are several third-party comment providers that I can use, I tried out Disqus for a while but I didnt like nor trust them. I look at using forum software for the comments but then I have to run that and I might as well stay in WP

Then there are a few plug-ins I use and like.

The worst part of using WP is of course security. I have switched to fully
managed WP hosting so I dont have to worry too much about that. I do still
worry about plugins but my provider does not allow a lot of plug-ins due to
issues and I can totally appreciate that.

~~~
stankot
I'm running my blog ([https://muffinman.io](https://muffinman.io)) on Jekyll
and GitHub pages, and I've run into the same issues.

For search I generate a JSON array, with the name and the url to each post.
Then I just client side javascript to search them. It adds a small traffic
overhead, but users said they really like the search - it is instant and uses
fuzzy matching algorithm.

Here is the code I use to generate the array:
[https://github.com/Stanko/Stanko.github.io/blob/master/_incl...](https://github.com/Stanko/Stanko.github.io/blob/master/_includes/partials/scripts.html#L1-L10)

For comments I use staticman
([https://staticman.net/](https://staticman.net/)), and it is brilliant.
Instead of having a 3rd party comment system, it will issue a pull request to
your repo. You can set it to automatically merge PRs or to merge them manually
(and moderate them).

The only problem is that because of changes to the GitHub API quotas, their
public instance gets overloaded. But you can easily setup your own instance. I
use heroku, and their free tier is more than enough for my usecase (I get more
than 100k users a year).

I even wrote a short post how to set it up on heroku:
[https://muffinman.io/running-staticman-on-
heroku/](https://muffinman.io/running-staticman-on-heroku/)

Hope that helps, happy hacking!

------
koevet
There is no lack of technical choices when it comes to starting a blog. I can
start five blogs in the next 30 minutes, each one on a different
platform/infrastructure.

What I _do lack_ is something interesting to write about, in a consistent
manner. I have been writing code for a long time. I did build some interesting
stuff. I'm currently working on a startup that does use some blog-worthy tech:
any attempt ends up with very long essay-shaped posts, which are extremely
time-consuming to write and frankly not so interesting.

Any suggestion on how to find a niche and consistently write about it?

~~~
sharcerer
This might be helpful. [https://www.perell.com/blog/my-writing-
syllabus](https://www.perell.com/blog/my-writing-syllabus)

Follow David Perell for writing inspiration.
[https://twitter.com/david_perell/status/1213894632943296516](https://twitter.com/david_perell/status/1213894632943296516)

~~~
zigzaggy
I also follow Perell and find him inspiring. Writing is a lifelong passion but
since a big part of my work is writing, the flame has gone out. These days is
all about relighting the fire.

------
bjarneh
> Don’t try to be clever by using a localized domain, don’t use .io. .com just
> gives a better impression...

[https://gohugo.io](https://gohugo.io) \- Hugo website

> My suggestion is to avoid subdomains completely.

[https://themes.gohugo.io](https://themes.gohugo.io) \- Hugo themes

[https://discourse.gohugo.io](https://discourse.gohugo.io) \- Hugo forum

Hmm

~~~
doublerabbit
It’s a shame there we are so whipped to .com

~~~
robjan
These days nobody types an address into the search bar so any TLD that's not
country based should be fine. I say that because your home country is a fluid
concept.

------
feistypharit
Anyone looking for a static blog but that wants a decent interface for
editing, check out forestry.io. once setup, it commits to GitHub for you, your
user is none the wiser. If the service ever goes away, you still have your
blog in GitHub. And you can deploy anywhere (s3, netlify, etc). I use this
setup for my non technical wife.

~~~
Tepix
I think this is just what I was looking for, thanks!

------
thomasedwards
Hugo is super, but the official docs make it look a lot scarier than it is.
It’s a solid static site builder with a lot of power under the hood.

------
Tepix
Is there a web-based editor that can be used together with these static site
generators?

This editor should be small, self-contained and secure and could be located in
a separate access-restricted area of the site.

~~~
mattlondon
I set up a small charity's site I maintain to use GitHub pages and Jekyll. The
in-browser editor for markdown is good enough for the non-technical users, and
GitHub pages takes care of rebuilding the site. The revision history is handy
in case someone does something weird and we need to undo it.

I believe that GitLab pages offers something similar that also supports Hugo,
but I opted to use GitHub+Jekyll as I personally find it significantly easier
to custom-build a website than with Hugo (I really struggled with on some
basic stuff, e.g. I had a lot of blank pages at dir roots (e.g.
/something/goes/here would have blank pages at something/ and something/goes/
etc)). Hugo feels over-complicated to me.

------
_emacsomancer_
And if you want to do it from inside Emacs/using org-mode, see: [https://ox-
hugo.scripter.co/](https://ox-hugo.scripter.co/)

------
ripley12
I've been using Hugo for a few years. I like it generally, but I have mixed
feelings about using Go for templating. Compilation and generation is blazing
fast, which is great for short edit-compile-debug cycles.

On the other hand, Go's lack of generics makes working with collections harder
than it should be... and much of templating involves working with collections.

To give a concrete example, I wanted to create a page where I group categories
by post count. Hugo has methods to group _pages_ , but not categories, so I
rolled my own imperative grouping code. It wasn't difficult, but it would have
been simpler to do declaratively in many other ecosystems (say, .NET with
LINQ).

------
stock_toaster
I used hugo for a while, but found myself struggling against it more often
than I liked. I have since moved on to using other options.

~~~
franze
What other options?

~~~
Avamander
I've been using Pelican¹ with m.css², it does math, sitemaps, RSS feeds, code,
graphs and a lot other things very nicely for me. Other blog platforms are far
from as powerful, what I've tried, with so little hassle.

[1]: [https://docs.getpelican.com/](https://docs.getpelican.com/)

[2]: [https://mcss.mosra.cz/](https://mcss.mosra.cz/)

------
Kovah
I moved from WordPress to Hugo last year and dont regret it. If you search for
some configuration examples for multi-language blogs and some shortcodes for
image generation and so on, feel free to check out the blog post about it.
[https://blog.kovah.de/en/2019/static-blog-with-
hugo/](https://blog.kovah.de/en/2019/static-blog-with-hugo/) Source is
available on Github:
[https://github.com/Kovah/blog.kovah.de](https://github.com/Kovah/blog.kovah.de)

------
jelger
I like the idea of static blogs. However, I didn't accomplish to find a great
workflow to use hugo from my android phone while traveling. Using git on a
phone is a pain

~~~
rwmj
Yes this is where I got blocked on this too. I like using the WP Android app
to upload photos when travelling. Obviously a static site by its very nature
cannot interact with a phone app, so this seems like a difficult/intractable
problem.

~~~
netsharc
I have the same use case and have been wondering about solutions too. I'm
hosting on Netlify, and when I push to my gitlab repository, Netlify's CI
fetches, builds and deploys the site. I've wondered if I can run a script
somewhere that periodically checks a private Instagram account (so not my main
one), and when it sees a new post, it would download the photo and caption,
creates a Markdown post and pushes everything into the git repo.

~~~
jl-gitlab
You could potentially use a regularly scheduled pipeline in GitLab CI to do
this. You'd need to use a user token instead of the pipeline token since you
want to push back into the repository, but this should be possible. Then, when
GitLab CI updates the repo, Netlify CI should jump in.

------
PMan74
I've a few sites on Hugo. If you're not an active developer (like me) you can
deploy a site from a Netlify template and tweak from there. So pretty much the
opposite of "zero to deployment" \- gives you something working to start with.

[https://templates.netlify.com/template/hugo-starter-blog-
the...](https://templates.netlify.com/template/hugo-starter-blog-theme-kaldi/)

------
tkainrad
Very nice and detailed tutorial! I like also other content on your page and
bookmarked your blog :)

I created a similar post a while ago, might be interesting for some who want
to use GitLab instead of GitHub + Netlify:

[https://tkainrad.dev/posts/using-hugo-gitlab-pages-and-
cloud...](https://tkainrad.dev/posts/using-hugo-gitlab-pages-and-cloudflare-
to-create-and-run-this-website/)

------
saagarjha
> It’s too easy to get trapped in making things perfectly like you want, but
> the important thing is the content.

Where's the fun in that :)

------
sacado2
I've been using Hugo for a few years now. Pretty long to set up if you want to
addapt one of the available templates to suit your needs, but then it's really
great!

I would not advise it to a non-programmer/tech savvy person though.

------
tuesday20
Those using static site generators - how do you handle search?

~~~
ripley12
Outsourcing it to a search engine is pretty easy. I do something like the
following for DuckDuckGo:

    
    
      <form id="search" method="get" action="//duckduckgo.com/">
        <input type="text" name="q"/>
        <input type="hidden" name="sites" value="mywebsite.com">
      </form>

------
throwaway0x77
When comes to static site, I found that MkDocs[1] is easier to use. I like
when I use it with Material theme[2].

[1]: [https://www.mkdocs.org/](https://www.mkdocs.org/) [2]:
[https://squidfunk.github.io/mkdocs-
material/](https://squidfunk.github.io/mkdocs-material/)

~~~
NickBusey
MkDocs is great for what it was built for, documentation. I also use the
Material theme myself.

For a blog though, it would be a terrible format. They meet very different use
cases.

------
dablweb
I use Hugo for my website too! Highly recommend.

I also put together a video tutorial of how I set up my CI/CD pipeline to
deploy to AWS using Terraform.

[https://devbrett.com/videos/2018-07-22-static-website-
terraf...](https://devbrett.com/videos/2018-07-22-static-website-terraform/)

The whole site costs me about 50c a month on S3 + Cloudfront.

------
lewis1028282
I run my blog [https://www.lewis8s.codes](https://www.lewis8s.codes) on AWS
Amplify. It connects to a GitHub repo and builds it every time there is a
commit to master. Uses CloudFront on the backend too.

Costs me around $0.01 per build which isn't bad. Just easier than writing my
own script.

------
heinrichhartman
Off-topic: Any advise on how to migrate a Jekyll blog to Hugo?

Is it practical to keep the rendered HTML as static pages, and just use
hugo/markdown for new posts?

Migrating the markdown files to hugo looks like a pain. Header files need to
be migrated. Also jekyll plugins will obviously not work.

Might be better to just leave the old stuff as-is...

~~~
concerned_user
We did that on our project were using markdown in jekyll and kept it in hugo.
Hugo has its own plugins, not that hard really.

EDIT: Hugo has a plugin to import a jekyll project, you can check maybe it
will do most of the work for you. Link
[https://gohugo.io/commands/hugo_import_jekyll/](https://gohugo.io/commands/hugo_import_jekyll/)

------
bar_de
Hugo is a great tool. I use it with my small project's websites for easily
changing the content and getting hosting for nearly free.

Just adding new posts, push the repo and let the build and deployment scripts
do their thing.

And - don't forget - the less dynamic your site is the less attractive it
becomes for the bad guys.

------
heycesr
Shameless plug: I built [https://typehut.com](https://typehut.com) as a
simpler alternative to classic blog and publishing systems. It's super easy to
get started and it has some nice things like email subscriptions built-in.

If anybody tries it out let me know!

~~~
Saturdays
FYI, I ca'n't reach your site! If it works will check out!

~~~
heycesr
Hmm, works on my side. What’s the error you’re seeing?

------
stilisstuk
Are Hugo really substantially better than say pelican or Nikola or all the
other 'established' SSG?

~~~
chrismorgan
Yes, it is, specifically in ease of use of the static site generator itself,
especially compared with a Python or Ruby one. (Node things tend to be more
amenable to easily reproducible builds.)

From experience, I say that installing Python or Ruby static site generators
(Hyde and Jekyll specifically I have in mind) starts out markedly harder, and
tends to get steadily harder over time, particularly if you don’t ride the
upgrade treadmill¹, whereas the likes of Hugo (Go) and Zola (Rust) are a
single binary that you just download and run, and it’ll continue to work
forever, and when you switch computers you can just copy or download the
binary again and it’ll still work.

This difference concretely saved substantial quantities of time for redoing
Fastmail’s website last year in Zola: once it genuinely _was_ just “download
Zola 0.8 from such-and-such a location and run `zola serve`”, a few people
that would have given up on setting up a Jekyll or Pelican or similar
environment, and instead gone with a longer “try modifying it, deploy it and
see what happens” or “ask someone else to do it” approach, instead _did_ just
download the single binary and use it, because it genuinely _did_ Just Work™.

If it’s hard (here probably meaning “takes longer than five minutes of
effort”) to get an editing environment going for your blog or website or
whatever, you _will_ abandon your website sooner or later, for a cause that
you wouldn’t if you were using one where it was easy.

So I say: prefer a single-binary for your occasionally-updated website, so
that it’s _your_ fault when you abandon it, rather than the SSG’s!

___

¹ For example: I used Hyde for the previous iteration of my personal website,
and last time I tried to spin up a fresh build environment for it, I
_genuinely failed_ —I knew what I was doing, but a couple of packages in there
would no longer build. Admittedly Hyde is abandoned and you’re not likely to
have quite such trouble on an actively-maintained project, but still:
treadmills, and processes that you can’t be _confident_ in.

------
flagpack
I am currently moving from WordPress to Hugo, so your tutorial arrived just in
time. Are your posts part of the content of your ebook series? Just asking in
admiration of your frequency of daily new posts.

~~~
flaviocopes
Great to hear! I'd say the biggest difference with WP is that you don't worry
about plugins, updates, server, etc. Maybe 50% of the posts I write are
included in an ebook, I try to write them as a series, so they have a double
purpose. One to help if you're searching specific information, the other more
organized in an ebook where I explain something from the beginning with a
clear structure. Making a series that ends up in an ebook also helps with
ideas of what to write about, because I define all the topics beforehand. The
other 50% of the posts are individual pieces, maybe an explanation of a
problem or task solved while coding, or just a description of something new
I'm learning :)

