Published on

Setup a Blog with Hugo



In this post we will setup a blog on hugo and using the theme pickles.

What is Hugo

Hugo is a Open-Source Static Site Generator which runs on Golang.

Installing Hugo

Im using a mac so I will be installing hugo with brew, for other operating systems, you can have a look at their documentation

$ brew install hugo

Create your new site:

$ hugo new site myblog

Install a Theme

We will use a 3rd party theme, go ahead and install the pickles theme:

$ git clone -b release themes/pickles

Custom Syntax Highlighting

Generate syntax highlight css, for a list of other styles see this post

$ mkdir -p static/css
$ hugo gen chromastyles --style=colorful > static/css/syntax.css

Append this below style.css in themes/pickles/layouts/partials/head.html

<link rel="stylesheet" href="{{ .Site.BaseURL }}/css/syntax.css"/>

set pygments settings in config.toml:

baseURL = ""
languageCode = "en-us"
pygmentsCodeFences = true
pygmentsUseClasses = true
title = "My Hugo Site"

Create your First Blogpost

Create your first post:

$ hugo new posts/
/Users/ruan/myblog/content/posts/ created

Populate your page with some data:

title: "My First Post"
date: 2019-04-23T09:39:23+02:00
description: This is an introduction post to showcase Hugo.
slug: hello-world-my-first-post
- hugo
- blog
- helloworld
- hugo
- blog
draft: false


Hello world and welcome to my first post

## New Beginning

This is a new beginning on my blog on hugo and this seems pretty cool so im adding random text here because I dont know **what** to add here. So im adding a lot more random text here.

This is another test.

## Code

This is python code:

{{< highlight python >}}
from random import randint
from faker import Fake
randint(1, 2)

destFile = "largedataset-" + timestart + ".txt"
file_object = open(destFile,"a")
file_object.write("uuid" + "," + "username" + "," + "name" + "," + "country" + "\n")

def create_names(fake):
    for x in range(numberRuns):
        genUname = fake.slug()
        genName =  fake.first_name()
        genCountry =
file_object.write(genUname + "," + genName + "," + genCountry + "\n")
{{< /highlight >}}

This is bash code:

{{< highlight python >}}
#!/usr/bin/env bash
echo "Hello, ${var}"
{{< /highlight >}}

## Tweets

This is one of my tweets, see [configuration]( for more shortcodes:

{{< tweet 1118930084356853770 >}}

## Tables

This is a table:

|**id**    |**name**|**surname**|**age**| **city**     |
|20-1232091|ruan    |bekker     |32     |cape town     |
|20-2531020|stefan  |bester     |32     |kroonstad     |
|20-4835056|michael |le roux    |35     |port elizabeth|

## Lists

This is a list:

* one
* two
* [three](

This is another list:

1. one
2. two
3. [three](

## Images

This is an embedded photo:


Run the Server

You can set the flags in your main config as well. Go ahead and run the server:

$ hugo server \
  --baseURL "http://localhost/" \
  --themesDir=themes --theme=pickles \
  --bind= --port=8080 --appendPort=true \
  --buildDrafts --watch --environment production


When you access your blog on port 8080 you should see your post. Some screenshots below:


Thank You

Thanks for reading, if you like my content, feel free to check out my website, and subscrube to my newsletter or follow me at @ruanbekker on Twitter.

Buy Me A Coffee