John Siu Blog

Tech - Business Tool, Personal Toys

Hugo Commands and Config

☰ Table of Content

Some Hugo commands and config.

New site

1
hugo new site <site name>  # Create Hugo site folder <site name>.

New post

1
2
hugo new post/test.md
hugo new <archetypes>/<post name>.md

Add section

A new section requires:

  • An archetype file.
  • A _index.md inside section folder.
  • A [menu] entry in config.toml.

Following example creates a section call section91.

Archetype

Copy archetypes/default.md to archetypes/section9.md and modify type:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
---
author: "John Siu"
date: {{ .Date }}
description: ""
draft: true
tags: [""]
title: "{{ replace .Name "-" " " | title }}"
type: "section9"
---
<!--more-->

Value of type will be section directory name. See below.

Title

Create a test.md under section9

1
hugo new section9/test.md

That will create directory section9 under content with test.md inside. Create _index.md to set the title:

content/section9/_index.md:

1
2
3
---
Title: "Section 9 / 公安9課"
---

Add a menu entry else the new section will not be shown:

config.toml:

1
2
3
4
[menu]
[[menu.main]]
name="公安9課" # Menu item.
url="/section9" # Match the directory name under `content`.

Syntax Highlight

Enable syntax highlight in config.toml:

1
2
pygmentsCodefences=true # Enable syntax highlight.
pygmentsStyle="Chroma"  # Define highlight style.

Rsync

Ssh rsync public folder to remote server:

1
rsync -az --delete public <user@hostname>:<dir containing public>

John Siu

Update: 2022-05-12
comments powered by Disqus