Clarify title function

This commit is contained in:
Joe Mooring 2023-04-01 11:25:26 -07:00 committed by Joe Mooring
parent 47535dc873
commit 59f8a1f48e
2 changed files with 15 additions and 15 deletions

View File

@ -1,29 +1,23 @@
---
title: title
description: Converts all characters in the provided string to title case.
description: Converts the provided string to title case.
categories: [functions]
menu:
docs:
parent: functions
keywords: [strings]
signature:
- "title INPUT"
- "strings.Title INPUT"
- "title STRING"
- "strings.Title STRING"
relatedfuncs: []
---
```go-html-template
{{ title "BatMan"}}` → "Batman"
{{ title "table of contents (TOC)" }} → "Table of Contents (TOC)"
```
Can be combined in pipes. In the following snippet, the link text is cleaned up using `humanize` to remove dashes and `title` to convert the value of `$name` to Initial Caps.
By default, Hugo adheres to the capitalization rules in the [Associated Press (AP) Stylebook]. Change your [site configuration] if you would prefer to follow the [Chicago Manual of Style], or to use Go's convention of captilalizing every word.
```go-html-template
{{ range $name, $items := .Site.Taxonomies.categories }}
<li><a href="{{ printf "%s/%s" "categories" ($name | urlize | lower) | absURL }}">{{ $name | humanize | title }} ({{ len $items }})</a></li>
{{ end }}
```
## Configure Title Case
The default is AP Stylebook, but you can [configure it](/getting-started/configuration/#configure-title-case).
[Associated Press (AP) Stylebook]: https://www.apstylebook.com/
[Chicago Manual of Style]: https://www.chicagomanualofstyle.org/home.html
[site configuration]: /getting-started/configuration/#configure-title-case

View File

@ -575,7 +575,13 @@ status = 404
## Configure Title Case
Set `titleCaseStyle` to specify the title style used by the [title](/functions/title/) template function and the automatic section titles in Hugo. It defaults to [AP Stylebook](https://www.apstylebook.com/) for title casing, but you can also set it to `Chicago` or `Go` (every word starts with a capital letter).
Set `titleCaseStyle` to specify the title style used by the [title](/functions/title/) template function and the automatic section titles in Hugo.
By default, Hugo adheres to the capitalization rules in the [Associated Press (AP) Stylebook]. Set `titleCaseStyle` to `chicago` if you would prefer to follow the [Chicago Manual of Style], or set if to `go` to use Go's convention of captilalizing every word.
[Associated Press (AP) Stylebook]: https://www.apstylebook.com/
[Chicago Manual of Style]: https://www.chicagomanualofstyle.org/home.html
[site configuration]: /getting-started/configuration/#configure-title-case
## Configuration Environment Variables