Skip to main content
GOHUGO
Functions

Functions

This documentation is work in progress. Please check back later.

A GoHugo theme component with helper functions for other projects.

Some things you need to know

These are notes about conventions in this README.md. You might want to make yourself acquainted with them if this is your first visit.

The following documentation will refer to all configuration parameters in TOML format and with the assumption of a configuration file for your project at /config.toml. There are various formats of configurations (TOML/YAML/JSON) and multiple locations your configuration can reside (config file or config directory). Note that in the case of a config directory the section headers of all samples need to have the respective section title removed. So [params.dnb.something] will become [dnb.something] if the configuration is done in the file /config/$CONFIGNAME/params.toml.

Installing

First enable modules in your own repository if you did not already have done so:

1hugo mod init github.com/username/reponame

Then add this module to your required modules in config.toml.

1[module]
2[[module.imports]]
3    disable = false
4    ignoreConfig = false
5    ignoreImports = false
6    path = 'github.com/davidsneighbour/hugo-functions'
1module:
2  imports:
3  - disable: false
4    ignoreConfig: false
5    ignoreImports: false
6    path: github.com/davidsneighbour/hugo-functions
 1{
 2   "module": {
 3      "imports": [
 4         {
 5            "disable": false,
 6            "ignoreConfig": false,
 7            "ignoreImports": false,
 8            "path": "github.com/davidsneighbour/hugo-functions"
 9         }
10      ]
11   }
12}

The next time you run hugo it will download the latest version of the module.

Updating

1# update this module
2hugo mod get -u github.com/davidsneighbour/hugo-functions
3# update to a specific version
4hugo mod get -u github.com/davidsneighbour/[email protected]
5# update all modules recursively over the whole project
6hugo mod get -u ./...

Working principle

While being named functions this component adds merely partials that return values. In these partials calculations are done, so we might un-nerdily call them functions. The reason for this is that Hugo does not allow for functions to be added to a theme component. So we are using partials instead.

Back to top
Back Forward