Hugo Tips and Tricks
Cool tips
Tip 1:
Sometimes, you really don’t wish to pluralize the menu items in Hugo. How can you do that?
```bash
edit config.yml
pluralizelisttitles: “false”
OR
edit config.toml
pluralizelisttitles = false ```
Also the command can tell you whether the list is plural or not
`bash
hugo config
\
`
Tip 2:
How to enable syntax highlighting in Hugo?
To enable syntax highlighting in Hugo, you need to configure your config.toml
file:
`toml
[markup]
[markup.highlight]
noClasses = false
\
`
This will enable syntax highlighting using the default Chroma highlighter.
Tip 3:
How to create a custom shortcode in Hugo?
You can create custom shortcodes in Hugo by adding a new file in the layouts/shortcodes
directory. For example, to create a youtube
shortcode, create a file named youtube.html
with the following content:
`html
<iframe width="560" height="315" src="https://www.youtube.com/embed/{{ .Get "id" }}" frameborder="0" allowfullscreen></iframe>
\
`
You can then use this shortcode in your content like this:
`markdown
`
\
Tip 4:
How to use Hugo’s built-in pagination?
To use pagination in Hugo, you need to configure your config.toml
file and use the paginate
parameter in your list templates:
`toml
paginate = 10
\
`
In your list template (e.g., layouts/_default/list.html
), add the following code to enable pagination:
```html {{ range .Paginator.Pages }} {{ .Render “summary”}} {{ end }}
{{ template “_internal/pagination.html” . }} ```
This will paginate your list pages, showing 10 items per page.
Without markdown escape.
Tip 1:
Sometimes, you really don’t wish to pluralize the menu items in Hugo. How can you do that?
# edit config.yml
pluralizelisttitles: "false"
# OR
# edit config.toml
pluralizelisttitles = false
Also the command can tell you whether the list is plural or not
hugo config
Tip 2:
How to enable syntax highlighting in Hugo?
To enable syntax highlighting in Hugo, you need to configure your config.toml
file:
[markup]
[markup.highlight]
noClasses = false
This will enable syntax highlighting using the default Chroma highlighter.
Tip 3:
How to create a custom shortcode in Hugo?
You can create custom shortcodes in Hugo by adding a new file in the layouts/shortcodes
directory. For example, to create a youtube
shortcode, create a file named youtube.html
with the following content:
<iframe width="560" height="315" src="https://www.youtube.com/embed/{{ .Get "id" }}" frameborder="0" allowfullscreen></iframe>
You can then use this shortcode in your content like this:
Tip 4:
How to use Hugo’s built-in pagination?
To use pagination in Hugo, you need to configure your config.toml
file and use the paginate
parameter in your list templates:
paginate = 10
In your list template (e.g., layouts/_default/list.html
), add the following code to enable pagination:
{{ range .Paginator.Pages }}
{{ .Render "summary"}}
{{ end }}
{{ template "_internal/pagination.html" . }}
This will paginate your list pages, showing 10 items per page.