Hugo provides humanize
function to make a String with the first letter capitalized.
Version
Hugo 0.91
Page
The title
page variable was my blog
, but it shows My blog
on the page.
Page Variable
contact/_index.md
---
title: my blog
---
title
: them
inmy blog
is lowercase
humanize
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 font-bold">{{ humanize .Title }}</h1>
</body>
</html>
Line 10
<h1 class="text-4xl font-bold">{{ humanize .Title }}</h1>
humanize
: return the humanized version of an argument with the first letter capitalized
Conclusion
- Although we can use JavaScript to capitalize the String on the run-time but
humanize
provided by Hugo is much faster on the build-time