Documenting the blogging process.
Simple Concept & Cheat sheet
Directory Structure
.
├── archetypes // default template
├── config.toml // configuration
├── content // post folder, home, ...
├── data // store other config data (yaml,toml, json)
├── layouts // custom template (html), overwrite themes
├── static // styles (css,js)
└── themes . // structure as above
├── archetypes
├── config.toml
├── content
├── data
├── layouts
├── static
└── themes
Basic Command
hugo new site SITE_NAME// create the above structured directoryhugo new PAGE_NAME.md// generate new pagehugo serve -D// preview in localhost:1313,-D: view draftshugo version// check the version, or if it exists.
Resource
Dev. Notes
Theme
- Candidates:
| Theme | Pros(+) | Cons(-) | Comments |
|---|---|---|---|
| ✔️ hugo-bootstrap-premium | - Good looking - support Bootstrap(?) |
messy/complex structure | - link from: this blog - free Bootstrap theme: Bootswatch |
| hugo-bootstrap | - clear structure - support Bootstrap |
above styles are better (fonts, icons) | build my own! |
| minos | - simple & clear - flooting smart toc |
- too plain… - do not like the fonts |
link from: this blog |
ToC (Table of Content)
- in
.html:- Add:
{{ .TableOfContents }} - Ref. https://www.codeooze.com/webdesign/hugo-toc/
- Add:
- for hugo-bootstrap-premium:
/theme/layouts/_default/single.html> partial/theme/layouts/partial/bloc/content/sidebar.html
- @TODO:
- Change to smart toc
- Taxonomies order: Topics, tags
- Floating/Fixed toc (sliding?), how about axonomies??
Image Path
- Place in
/SITE_FOLDER/statics/images - Source
 - Ref. https://discourse.gohugo.io/t/image-path/1721
Count Taxonomies (tags & Topics)
- Some sample code: (in
/sidebar.html)
<ul>
<!-- Get all posts-->
{{ $posts := where .Site.Pages "Type" "post" }}
<!-- loop all tags that you've used -->
{{ range $name, $taxonomy := .Site.Taxonomies.tags }}
<!-- (re)set the counter to 0 -->
{{ $.Scratch.Set "tagCounter" 0 }}
<!-- increment counter if post contains the current tag-->
{{ range $posts}}
{{ if in .Params.tags $name }}
{{ $.Scratch.Add "tagCounter" 1 }}
{{ end }}
{{ end }}
<li>{{ $.Scratch.Get "tagCounter" }} articles in {{ $name }}</li>
{{end}}
</ul>
Credits: https://discourse.gohugo.io/t/show-count-of-handpicked-categories-or-tags/2369
Problems:
- codes in
sidebar.html(not exactly as above), there are some lower cases and upper cases problems, which make it hard to filter/display taxonomy.
- codes in
Hugo built-in functions related to ths problem:
Usage:{{FunctionName ObjectItem}}or{{"ObjectItem" | FunctionName}}@TODO: two types of taxonomies:
tags: for small keywords, eg. #hashtag, or categorize by programming languagesTopics: for general categories, maybe «one Post one Topic»- Create multicolor tags