Hello Hugo

Installation

I’m on Mac, so I’ll share the command I used, although you should follow hugo’s installation guide as they’ll do a better job than me at explaining their software.

brew install hugo

Once you got it on your system you can simply run the following command to create your website!

hugo new site my_website
cd my_website

Themes

Hugo has a huge community of people who developed their own template and shared it with everyone else. This website it’s using a theme called Doit it’s very cool, and it’s based on other themes. If you want to use a theme from the community you can check them here. There’s lots of different themes, and I’m pretty sure there’s something for you too!

If you want to use mine you should follow the original guide as this theme has lots of cool features. Although if you’re feeling like you want your own you can get started by following this post from an ex-manager of mine Pedro Lopez. He is great at explaining things!

To keep things short this is what I did to install the do it theme

git init
git submodule add https://github.com/HEIGE-PCloud/DoIt.git themes/DoIt

Then you would need to add the minimum configuration, this is the right values at the time of writing this post, but as I said it’s better if you follow the link to the author’s documentation.

baseURL = "http://example.org/"
# [en, zh-cn, fr, ...] determines default content language
defaultContentLanguage = "en"
# language code
languageCode = "en"
title = "My New Hugo Site"

# Change the default theme to be use when building the site with Hugo
theme = "DoIt"

[params]
# DoIt theme version
version = "0.2.X"

[menu]
[[menu.main]]
identifier = "posts"
# you can add extra information before the name (HTML format is supported), such as icons
pre = ""
# you can add extra information after the name (HTML format is supported), such as icons
post = ""
name = "Posts"
url = "/posts/"
# title will be shown when you hover on this menu link
title = ""
weight = 1
[[menu.main]]
identifier = "tags"
pre = ""
post = ""
name = "Tags"
url = "/tags/"
title = ""
weight = 2
[[menu.main]]
identifier = "categories"
pre = ""
post = ""
name = "Categories"
url = "/categories/"
title = ""
weight = 3

# Markup related configuration in Hugo
[markup]
# Syntax Highlighting (https://gohugo.io/content-management/syntax-highlighting)
[markup.highlight]
# false is a necessary configuration (https://github.com/dillonzq/LoveIt/issues/158)
noClasses = false

Once you get that set up you can just create an example post with the following command/

hugo new posts/first_post.md

Once you have added some cool content you can look at it on your browser by running the “compiler”. Your website should be http://localhost:1313

hugo serve

Deploying

You’ve work on your first theme and amazing content that you want to share with the world. I’d personally recommend you publish it with github-pages. It’s free, and it’s very simple.

For this website I deploy the website automatically with a GitHub action

This is the code I’m using to do so, although you should check it on the repo for this website kevinrobayna.github.io:

# Sample workflow for building and deploying a Hugo site to GitHub Pages
name: Deploy Hugo site to Pages

on:
  # Runs on pushes targeting the default branch
  push:
    branches: [ "master" ]
  pull_request:
    branches: [ "master" ]

  # Allows you to run this workflow manually from the Actions tab
  workflow_dispatch:

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
  contents: read
  pages: write
  id-token: write

# Allow one concurrent deployment
concurrency:
  group: "pages"
  cancel-in-progress: true

# Default to bash
defaults:
  run:
    shell: bash

jobs:
  # Build job
  build:
    runs-on: ubuntu-latest
    env:
      HUGO_VERSION: 0.99.0
    steps:
      - name: Install Hugo CLI
        run: |
          wget -O ${{ runner.temp }}/hugo.deb https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_Linux-64bit.deb \
          && sudo dpkg -i ${{ runner.temp }}/hugo.deb          
      - name: Checkout
        uses: actions/checkout@v3
        with:
          submodules: recursive
      - name: Setup Pages
        id: pages
        uses: actions/configure-pages@v1
      - name: Build with Hugo
        run: |
          hugo \
            --minify \
            --baseURL ${{ steps.pages.outputs.base_url }}          
      - name: Upload artifact
        uses: actions/upload-pages-artifact@v1
        with:
          path: ./public

  # Deployment job
  deploy:
    environment:
      name: github-pages
      url: ${{ steps.deployment.outputs.page_url }}
    runs-on: ubuntu-latest
    needs: build
    steps:
      - name: Deploy to GitHub Pages
        id: deployment
        uses: actions/deploy-pages@v1
        if: github.ref_name == 'master'

Final thoughts

Hugo it’s pretty great and flexible, it’s easy to write cool content without doing too much HTML.