topside

Hugo Setup

Since this is in theory a tech blog, I figured I would write a technical article. I’ve been using hugo to publish things here and find that the environment I have set up makes it really easy to publish with an incredibly high degree of control.

Hugo is an open-source static site generator. You can get it at (https://gohugo.io/).

To start, create a file structure as follows, follow the quickstart instructions and initialize hugo in the blog_src folder:

  File Structure
    /site.com
    /site.com/public
    /site.com/public/blog
    /site.com/bin/hugo
    /site.com/blog_src

Continue to follow the instructions to download a theme. When complete set up your config.toml. Here is how I have mine setup. My config differs from the default somewhat, as I have my blog in a subdirectory.

* config.toml

baseURL = "//site.com/blog/"

RelativeURLs = true
CanonifyURLs = true
languageCode = "en-us"
title = "<blog_title>"
theme = "hugo-theme-console"
enableRobotsTXT = false
SectionPagesMenu = "main"
footnoteReturnLinkContents = "↩"
disqusShortname = "<yourdisqs>"
publishDir = "../public/blog"

[markup.goldmark.renderer]
unsafe = true

Use hugo new posts/yyyy-mm-dd-title.md to create new posts which are generated in the content/posts/yyyy-mm-dd-title.md folder. If you have any static images you want to embed in your posts, you can put them in a static/images folder, which gets mixed in. When you have your post ready, simply run hugo from your source root to publish to your publishDir folder.

Some other notes about my environment:

  • I use jetbrains IDEA as my editor. It has markdown preview.
  • To publish, I run locally and check the results in. Updating on the server is a simple git pull.