Skip to content

5. Shortcodes

Will Holmes edited this page Aug 7, 2023 · 7 revisions

Built-in Shortcodes

Hugo has built-in shortcodes that you can use to customize your markdown content. Please see the docs for detailed instructions.

Additional custom shortcodes will be added in a future release. If you have any requests please open an issue.

Homepage shortcodes

The theme includes two custom shortcodes that are primarily intended for use on the homepage: recent-posts and projects. Recent posts is similar to normal post lists but includes a dropdown select filter for filtering posts by section, and a view more CTA. Projects is essentially identical to the projects list page but includes a CTA to view all projects in case you only include a subset.

To include these after the hero section on your homepage, add the shortcodes to the content of your _index.md file.

Example of including the 5 most recent posts before the 5 most recent projects after the hero section:

---
frontmatter goes here...
---

{{< recent-posts 5 >}}
{{< projects 5 >}}

The first positional parameter can be adjusted to limit how many of each resource (posts/projects) to include.

These shortcodes should also work elsewhere in your project, but haven't been fully tested in this manner.

Clone this wiki locally