instant.page

load page faster via preloading

Tocbot

automatically generate toc for page

How to Learn Go and Hugo

This is the Go Template language (also called Go HTML Template), which is used by Hugo as its templating system. Hugo is a static site generator built in Go, and it uses Go’s templating engine with some additional Hugo-specific functions and variables.

  1. Hugo’s Official Template Documentation:
  2. Go Language:

Key Syntax Elements

The template language you’re seeing uses these distinctive elements:

  • {{ }} - Template directives
  • {{- }} and {{- -}} - Whitespace-trimmed directives
  • . - The current context
  • $varName - Custom variables (like $count)
  • range - Iteration over collections
  • if/else/end - Conditional logic
  • with - Context switching
  • | - Pipeline operator (used to chain functions)

Learning Path

  1. Start with Hugo’s Template Basics: Begin with Hugo’s template documentation to understand the basics of how templates work in Hugo.
  2. Learn Hugo-specific functions and variables: Hugo adds many custom functions like .Permalink, .Pages, and variables like site.Params.
  3. Understand Hugo’s Template Hierarchy: Hugo uses a specific lookup order for templates, which is important to know for overriding theme templates.
  4. Explore Go’s Template Syntax: For deeper understanding, learn about the underlying Go template language.
  • Hugo server with the --verbose flag to see error messages

If And, if or

{{ if and (conditional1) (conditional2) }}
{{ if or (conditional1) (conditional2) }}