Skip to content

An example of a Hugo module that provides partial and shortcode templates

License

Notifications You must be signed in to change notification settings

jmooring/hugo-module-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Hugo Module – Example

This is an example of a Hugo module that provides partial and shortcode templates.

layouts/
├── partials/
│   └── hme/
│       └── greeting.html
└── shortodes/
    └── hme/
        └── greeting.html

The hme subdirectory provides a namespace to avoid collisions with other modules, themes, or custom templates.

Configuration

To add this module to your project, initialize your project as a Hugo module:

hugo mod init foo

In the above, foo is typically something like github.com/user/project.

Then add this to your site configuration:

[[module.imports]]
path = 'github.com/jmooring/hugo-module-example'

Usage

To use the greeting partial:

{{ partial "hme/greeting.html" "John" }}

To use the greeting shortcode:

{{< hme/greeting John >}}

Inspection

To inspect the module components:

hugo mod vendor

This will "vendor" all of the module dependencies into a _vendor directory in the root of your project. When you build your site, Hugo looks for modules in the _vendor directory, falling back to the module cache.

When you have finished inspecting the files, remove the _vendor directory so that you can update the module as needed.

Update

To update the module to the latest version:

hugo mod get -u github.com/jmooring/hugo-module-example

To update the module to a specific version:

hugo mod get -u github.com/jmooring/hugo-module-example@v0.1.0

To update all modules to the latest version:

hugo mod get -u ./...

About

An example of a Hugo module that provides partial and shortcode templates

Topics

Resources

License

Stars

Watchers

Forks

Languages