Hugo: Todo Shortcode

This post is outdated and contains potential security flaws. Please see the updated version.

Here’s a simple Hugo shortcode to help track todo items while authoring pages.

{{/* /layouts/shortcodes/todo.html */}}
{{- warnf "TODO: %s" .Inner }}
<span>TODO: {{ .Inner }}</span>

You can then insert a TODO into page content as follows:

{{< todo >}}Rework content here...{{< /todo >}}

When you build the site, it will output a warning to the console to remind you the content is unfinished:

Change detected, rebuilding site (#18).
2025-02-21 12:36:59.795 +0000
Source changed /posts/2025-02-21-hugo-todo-shortcode.html
WARN  TODO: Rework content here...
Web Server is available at http://localhost:1313/ (bind address 127.0.0.1)
Total in 7 ms

If preferred, you could make this an error rather than a warning, or remove the span element so that the text doesn’t show in the page.