Hugo - static site generator
- 2 minutes read - 329 wordsHugo is one of the most popular open-source static site generators. With its amazing speed and flexibility, Hugo makes building websites fun again.
And this is how this web site was built - Hugo + Ananke.
Learning
Installation and setup
Install Hugo
Debian Linux or Google ChromeOS
sudo dpkg -i /mnt/chromeos/MyFiles/Downloads/hugo_extended_0.140.1_linux-amd64.debbinaries are from hugo/releases- Unfortunately Debian package repo has very old version, but
sudo apt install hugostill works (installs 0.111 as of now).
MacOS
- Download binaries for Derwin OS hugo_extended_0.140.1_darwin-universal.tar.gz, unpack, enjoy.
Site creation and configuration
- Create new site
hugo new site belablotski - Install theme
git submodule add https://github.com/theNewDynamic/gohugo-theme-ananke.git themes/anankeand addtheme = 'ananke'in hugo.md - Commenting systems
- Syntax highlighting
- Links and cross references
Hosting
Code
Content creation
Pages
- Create page
hugo new content content/posts/my-first-post.md - Page bundles and _index.md
- List pages
hugo list publishedorhugo list drafts
Context organization
- Taxonomies. Taxonomy, term, value.
- Default taxonomimes. Hugo automatically creates taxonomies for
tagsandcategories(unlessdisableKindsturns it off). - Configure taxonomies
- Assign terms to content:
categories = ['Category A', 'Category B'] tags = ['Tag A', 'Tag B']. Taxonomic weight - ordering.
| Kind | Description | Example |
|---|---|---|
| home | The landing page for the home page | /index.html |
| page | The landing page for a given page | my-post page (/posts/my-post/index.html) |
| section | The landing page of a given section | posts section (/posts/index.html) |
| taxonomy | The landing page for a taxonomy | tags taxonomy (/tags/index.html) |
| term | The landing page for one taxonomy’s term | term awesome in tags taxonomy (/tags/awesome/index.html) |
Templates
- Page kings: home, page (=single), section, taxonomy, and term. Single
layouts/_default/single.html, list page (section listings, home page, taxonomy lists, taxonomy terms)layouts/_default/list.html - Template types (base, home, single, section, taxonomy) and Lookup order
type(page type) - this is a sub-folder inlayoutsfolder,layoutis a sub-folder underlayouts/page_type.
Preview and publish
Preview
- Local site
hugo server - Preview your work before publishing
hugo server --buildDrafts --buildFuture --buildExpiredor simplehugo server -DEF hugo server --navigateToChanged