mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-21 21:35:28 +02:00
Merge commit '35dec7c96f7ee3eb17dd444f7067f0c776fb56ae'
This commit is contained in:
13
docs/content/en/functions/urls/_common/_index.md
Normal file
13
docs/content/en/functions/urls/_common/_index.md
Normal file
@@ -0,0 +1,13 @@
|
||||
---
|
||||
cascade:
|
||||
_build:
|
||||
list: never
|
||||
publishResources: false
|
||||
render: never
|
||||
---
|
||||
|
||||
<!--
|
||||
Files within this headless branch bundle are markdown snippets. Each file must contain front matter delimiters, though front matter fields are not required.
|
||||
|
||||
Include the rendered content using the "include" shortcode.
|
||||
-->
|
@@ -0,0 +1,35 @@
|
||||
---
|
||||
# Do not remove front matter.
|
||||
---
|
||||
|
||||
The [`anchorize`] and [`urlize`] functions are similar:
|
||||
|
||||
[`anchorize`]: /functions/urls/anchorize
|
||||
[`urlize`]: /functions/urls/urlize
|
||||
|
||||
- Use the `anchorize` function to generate an HTML `id` attribute value
|
||||
- Use the `urlize` function to sanitize a string for usage in a URL
|
||||
|
||||
For example:
|
||||
|
||||
```go-html-template
|
||||
{{ $s := "A B C" }}
|
||||
{{ $s | anchorize }} → a-b-c
|
||||
{{ $s | urlize }} → a-b-c
|
||||
|
||||
{{ $s := "a b c" }}
|
||||
{{ $s | anchorize }} → a-b---c
|
||||
{{ $s | urlize }} → a-b-c
|
||||
|
||||
{{ $s := "< a, b, & c >" }}
|
||||
{{ $s | anchorize }} → -a-b--c-
|
||||
{{ $s | urlize }} → a-b-c
|
||||
|
||||
{{ $s := "main.go" }}
|
||||
{{ $s | anchorize }} → maingo
|
||||
{{ $s | urlize }} → main.go
|
||||
|
||||
{{ $s := "Hugö" }}
|
||||
{{ $s | anchorize }} → hugö
|
||||
{{ $s | urlize }} → hug%C3%B6
|
||||
```
|
Reference in New Issue
Block a user