Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jmooring/hugo-module-example
An example of a Hugo module that provides partial and shortcode templates
https://github.com/jmooring/hugo-module-example
hugo hugo-module
Last synced: 4 months ago
JSON representation
An example of a Hugo module that provides partial and shortcode templates
- Host: GitHub
- URL: https://github.com/jmooring/hugo-module-example
- Owner: jmooring
- License: apache-2.0
- Created: 2024-03-20T13:08:01.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2024-09-14T22:12:28.000Z (4 months ago)
- Last Synced: 2024-09-27T17:20:12.362Z (4 months ago)
- Topics: hugo, hugo-module
- Language: HTML
- Homepage:
- Size: 9.77 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Hugo Module – Example
This is an example of a Hugo module that provides partial and shortcode templates, as well as some miscellaneous files.
```text
layouts/
├── partials/
│ └── hme/
│ └── greeting.html
└── shortcodes/
└── hme/
└── greeting.html
miscellaneous/
└── sass/
└── bar/
└── _index.scss
```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:
```sh
hugo mod init foo
```In the above, `foo` is typically something like `github.com/user/project`.
Then add this to your site configuration:
```toml
[[module.imports]]
path = 'github.com/jmooring/hugo-module-example'
```## Usage
To use the greeting partial:
```go-html-template
{{ partial "hme/greeting.html" "John" }}
```To use the greeting shortcode:
```go-html-template
{{< hme/greeting John >}}
```## Inspection
To inspect the module components:
```sh
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:
```sh
hugo mod get -u github.com/jmooring/hugo-module-example
```To update the module to a specific version:
```sh
hugo mod get -u github.com/jmooring/[email protected]
```To update all modules to the latest version:
```sh
hugo mod get -u ./...
```