Hugo Content Tips
Docsy is a theme for the Hugo static site generator. If you’re not already familiar with Hugo and, in particular, its version of Markdown, this page provides some useful tips and potential gotchas for adding and editing content for your site. Feel free to add your own!
Linking
By default, regular relative URLs in links are left unchanged by Hugo (they’re still relative links in your site’s generated HTML), hence some hardcoded relative links like [relative cross-link](../../peer-folder/sub-file.md)
might behave unexpectedly compared to how they work on your local file system. You may find it helpful to use some of Hugo’s built-in link shortcodes to avoid broken links in your generated site. For example a {{< ref "filename.md" >}}
link in Hugo will actually
find and automatically link to your file named filename.md
.
Note, however, that ref
and relref
links don’t work with _index
or index
files (for example, this site’s content landing page): you’ll need to use regular Markdown links to section landing or other index pages. Specify these links relative to the site’s root URL, for example: /docs/adding-content/
.
Nested lists (Blackfriday only)
As of version 0.60.0, Hugo uses the Goldmark Markdown processor.
Prior to that version, Blackfriday was Hugo’s default Markdown processor.
This processor can be sensitive when it come to content that’s deeply nested in a list. In particular, be aware that
this known issue can surface if or when you have multiple authors and
other contributors who might mix tabs
and spaces
when indenting lists, or fail to indent properly.
An additional factor here is that because GitHub uses a different Markdown processor, GitHub markdown and the editor UI may render some nested lists properly, while Blackfriday might render that same content poorly. For example, the count in a numbered list might restart, or your nested content within a list is not indented (shows as a peer element instead of a nested child element). You may want to recommend in your contribution guidelines (as we do) that contributors preview their content with Hugo (or use Netlify’s preview feature for PRs if that’s your chosen deployment tool) to ensure their content renders correctly with Blackfriday.
Tip
Per comments on the known issue, users still using Blackfriday as markup processor will achieve consistent behavior when using tabs for indentation. If you don’t like tabs and want to use spaces for indentation, make sure you use 4 spaces for one indentation level, other you might run into trouble. Therefore, when using spaces for indentation, consider configuring your local editor to use 4 spaces when the Tab key is pressed.Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.