Notes
Hugo Modules
what Hugo modules are, what can be mounted as one, and getting started with hugo mod init and hugo mod vendor
Hugo
2 minutes
- Hugo modules are read-only.
- You can mount any folder from any public remote or local location, including GitHub repos and local folders on your system
- What sort of a module it is determined by the
targetpath where it is mounted - What can be a module? One or more of the 7 component types defined in Hugo:
static,content,layouts,data,assets,i18n, andarchetypes.
Getting started
- You should be using versions of Go and Hugo that support modules
- Your Hugo site itself needs to be initialized as a module in order for this to work
- Import a module by mentioning its
path. By default all modules are assumed to be themes. - Mount a module (or a folder) in a particular location by mention
sourceandtargetlocations hugo serveautomatically fetches the modules if neededhugo mod vendorshows the mounted modules in a directory called_vendorinside your project root instead of loading them incacheDir
1hugo mod init github.com/aamnah/aamnah.com
2
3# this will create a file called: go.mod
1hugo mod vendor
What can i mount as a module?
- Any form of assets. For example: Icon libraries like Heroicons or Remix Icons
- Any form of shared content. For example: documentation for a project
- Any theme or UI framework
- Branding assets
archetypesfor creating new content based on templates. For example: archetypes for creating blog posts with pre-filled front matter- Anything that fits the 7 content types of hugo.