Doks Theme Overview
Install Doks theme with the default configuration.
うまく使いさえすれば、時間はいつも十分にある
Install Doks theme with the default configuration.
Install Congo theme with the default configuration and the example site. Congo theme is built with TailwindCSS 3.2.
Install Book theme with the default configuration and the example site.
Install Geekdoc theme with the default configuration.
Hugo is a static site generator made by Go. It’s the fastest SSG to embrace JAMstack.
Although we can place all layouts into the layouts
folder, we can also place these layouts into the themes
folder to build our theme.
Since home page has a different look than other content page, Hugo uses a separate layout layouts/index.html
for the home page to generate.
Archetype is the template to create a markdown file. We can add more page variables for our convenience.
When using hugo new
to create many markdown files for a section, Hugo uses layouts/_default/list.html
as the default list page layout to generate.
Hugo is great for JAMstack, but we have to use vanilla JavaScript and CSS to create templates. With Alpine and TailwindCSS, we can create layouts by declarative style directly in HTML.
Hugo doesn’t clean up the public
folder. If you were to remove some pages or rename them, you would need to delete the generated versions from the public
folder as well.
When using hugo new
to create a markdown file, Hugo uses layouts/_default/single.html
as the default single page layout to generate.
Since Hugo uses Go template language, we can install the Go Template plugin developed by JetBrains for layout.
Not only using Hugo’s variables with Go template language, but also Alpine’s directive.
Minimizing HTML is provided by Hugo. We can minimize HTML under production.
Petite-vue is great for JAMstack, but we have to integrate Petite-vue with Hugo manually.
Alpine is great for JAMstack, but we have to integrate Alpine with Hugo manually.
TailwindCSS is great for JAMstack, but we have to integrate TailwindCSS with Hugo manually.
There are scope
and context
concepts in the Go template language. This post explains why we have to use .
to access site variables and page variables.
The Go Templates make heavy use of range
to iterate over a Map, Array, or Slice.
We can use range
to iterate over an array to render HTML.
For site-level custom data, we can store them on the .json
file in the data
folder.
For site-level custom data, we can store them on the params
section of config.json
.
We can define site variables in config.json
and access them by Go template language.
We can use .Content
page variable to access Markdown content.
We can use relref
to get the relative permalink to a page for the href
attribute of <a>
.
We can use ref
to get the absolute permalink to a page for the href
attribute of <a>
.
We can use the |
operator to compose multiple functions for Function Pipeline.
If we use Markdown to define a variable, we can use markdownify
to transform Markdown to HTML.
Hugo provides humanize
function to make a String with the first letter capitalized.
We can use with
to change the context and .
as the context variable.
For user-defined variable, we can either define it as site variable or page variable. $.Param
reads page variable first. If it doesn’t exist, then read site variable.
We can use default
to provide the default value of the template variable instead of using if else
.
We can use :=
to declare a template variable and =
to re-assign it.
We can use if else
for truthy/falsy value in Go template language.
One strength of Hugo is a clear separation of concerns between data (Markdown) and layout (HTML).
resources
folder is not created by default. It is created only when hugo server
command is issued. Should I delete or git ignore this folder?
After using hugo new site
to create a new Hugo site, Hugo CLI create the default folder structure for us. This post will explain the folder structure.
Since Hugo is developed by Go, it uses TOML as Hugo config file. But we can still use JSON as Hugo Config.
As for using Git for Hugo, some files don’t need to be controlled by Git. We can create .gitignore
to ignore them.