We can use the |
operator to compose multiple functions for Function Pipeline.
Version
Hugo 0.91
Page
my blog
is capitalized toMy blog
**
in Markdown is transformed to<strong>
Page Variable
content/_index.md
---
title: my **blog**
---
title
: use Markdown to define page variable
Pipe
layouts/index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<script src="alpine.js" defer></script>
<link rel="stylesheet" href="output.css" />
</head>
<body>
<h1 class="text-4xl text-red-500">{{ .Title | humanize | markdownify }}</h1>
</body>
</html>
Line 10
<h1 class="text-4xl text-red-500">{{ .Title | humanize | markdownify }}</h1>
humanize
: return the humanized version of an argument with the first letter capitalizedmarkdownify
: transform Markdown to HTML|
: Function Pipeline from.Title
tohumanize
tomarkdownify
Conclusion
- When using multiple functions on the template, pipes are more readable for the codebase