Logo
Shinguz Home
Google
 
/ch/open

Hugo

Hugo Installation

Download the newest Hugo release.

# VERSION='0.133.0'
# cd /tmp
# wget https://github.com/gohugoio/hugo/releases/download/v${VERSION}/hugo_extended_${VERSION}_linux-amd64.deb
# apt install ./hugo_extended_${VERSION}_linux-amd64.deb
# hugo version

Some Go Cheat Sheets:

Create a new Hugo site

# hugo new site fromdual -f toml
Congratulations! Your new Hugo site was created in /home/oli/fromdual_devel/website_2.0/fromdual.

Just a few more steps...

1. Change the current directory to /home/oli/fromdual_devel/website_2.0/fromdual.
2. Create or install a theme:
   - Create a new theme with the command "hugo new theme <THEMENAME>"
   - Install a theme from https://themes.gohugo.io/
3. Edit hugo.toml, setting the "theme" property to the theme name.
4. Create new content with the command "hugo new content <SECTIONNAME>/<FILENAME>.<FORMAT>".
5. Start the embedded web server with the command "hugo server --buildDrafts".

# cd fromdual/

Create a new Hugo theme

# hugo new theme fromdual

# echo "theme = 'fromdual'" >> hugo.toml

Create a new Hugo page

# hugo new content test.md
# hugo new content foo/test.md

Render you hugo site

Currently we have serious troubles with rendering Hugo sites. This happens with version v0.133.0:

# hugo version
hugo v0.133.0-c9777473d1369f812d727a6c07dc57ad7be7bf62+extended linux/amd64 BuildDate=2024-08-17T19:57:41Z VendorInfo=gohugoio

See Hugo issue 12786

Version 0.128.2 and 0.132.2 workes like a charme at least for me. Some workarounds that helped sometimes:

# rm -rf public/*
# hugo --printUnusedTemplates --printPathWarnings --environment=production
# hugo server --buildDrafts --cleanDestinationDir --disableFastRender -cq --ignoreCache --logLevel=info --printUnusedTemplates --printPathWarnings --environment=production

To render your site:

# rm -rf public/*
# hugo server --buildDrafts --cleanDestinationDir --disableFastRender

The you can access your site as follows

Clear Firefox Cache

Checkin your changes to git

# git init .
# git add *
# git commit -m 'Inital version'

Debug Go Templates

{{ $site := page.RegularPages }}
{{ $site := .Page.RegularPages }}

{{ $site := site.RegularPages }}
{{ $site := .Site.RegularPages }}

{{ $general := site.GetPage "general" }}

{{ range $general.RegularPagesRecursive }}
{{ end }}

{{ range .Children }}

{{ range $site }}
{{ end }}
{{ $object := . }}


{{ $object := . }}
{{ $object := page.Title }}
{{ $object := page.Type }}
{{ $object := page.Weight }}
{{ $object := page.WordCount }}
{{ $object := page.Ancestors }}
{{ $object := page.Parent }}
{{ $object := page.CurrentSection.Title }}
{{ $object := page.LinkTitle }}
{{ $object := page.Prev }}
{{ $object := page.Path }}
{{ $object := .Site.Title }}
{{ $object := .Site.AllPages }}
{{ $object := .Site.Home }}
{{ $object := .Site.Menus }}
{{ $object := index .Site.Sections 2 }}
{{ $object := .Site.Title }}
{{ $object := .Site.Taxonomies }}
{{ $object := .Site.Menus }}
{{ $object := site.Menus.main }}
{{ $object := index .Site.Menus.main 3 }}

{{ range .Site.Menus.main }}
  {{ if .HasChildren }}
    {{ range .Children }}

{{ $object := . }}
{{ printf "value: %v\n" $object }}<br>
{{ printf "value: %+v\n" $object }}<br>
{{ printf "value: %#v\n" $object }}<br>
{{ printf "type: %T\n" $object }}<br>