created on | March 18, 2022 |
this is a kitchen sink for stuff that I throw in, before I forget it and to redistribute it later. The stuff in here will get redistributed to the proper pages in the near future.
setup new web project with scaffolding, with project root dir name
Archetypes define the frontmatter of a markdown content file, with the frontmatter enclosed in two lines of three hyphens like in the example below:
The default archetype for a directory is defined in the archetype markdown yaml file in the directory ‘archetype’. In the example below there is a archetype ‘blog’ defined in archetypes. Creating a new markdown file with
creates the file blog/whatever.md with the blog archetype.
By deafult, Hugo has two taxonomies:
taxonomies are listed in the frontmatter as arrays:
Hugo automatically creates pages for taxonimies under
i.e. localhost:1313/tags/banana
Custom categories are defined in the config.toml. If custom taxonomies are defined in the config.toml, the standard Hugo taxonomies have to be included as well, otherwise the two default taxonomies are no longer available.
There are two different types of pages in Hugo:
Hugo generates list pages automatically. The automatically generated pages can be replaced with an list.html in the ‘_layouts’ folder of the template directory.
By default, the home page template is a list page template. It can be overwritten with a file ‘index.html’ in the _layouts folder
Section templates are defined in a subfolder of ‘_layouts’, with the folder named the same as the section. Section folders can include list page templates and single page templates
The ‘master template’ baseof template is defined the file baseof.html in the ‘_layouts’ folder that is located directly under the web page root, that is, not the theme layouts folder.
Define a block in a template
Use the block in a page template
Define the partial template in _layouts/partials/whatever.html
Use the partial in a template:
The dot represents the scope of vars the partial has access to.
Shortcode templates a partial templates that can be used in markdown files, that is, content files.
Define the shortcode in a file named like the shortcode that is going to be used, i.e. whatever.html for the ‘whatever’ shortcode.
Shortcodes are accessed with
Define the shortcode:
Note that inside css the double parenthesis do not work, but backticks do the trick.
The parameter can also be accessed with its position:
Use the shortcode in a markdown file:
Shortcodes can also be used with opening and closing ‘tag’ of the shortcode:
The content between the opening and closing tag can be accessed within the shortcode:
By default, markdown between the opening and closing tag of the shortcode is not processed, i.e. marking a text as bold like
does not work. To change this behaviour define the shortcode with the percent sign instead of angle brackets:
As the name suggests, template vars can only be used within templates.
insert content
define the custom var in the front matter:
Access the custom var in a template with
define the custom var
or
Access the custom var with