Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/gohugoio/hugo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'docs/content/en/functions/anchorize.md')
-rw-r--r--docs/content/en/functions/anchorize.md26
1 files changed, 26 insertions, 0 deletions
diff --git a/docs/content/en/functions/anchorize.md b/docs/content/en/functions/anchorize.md
new file mode 100644
index 000000000..a0745edaf
--- /dev/null
+++ b/docs/content/en/functions/anchorize.md
@@ -0,0 +1,26 @@
+---
+title: anchorize
+description: Takes a string and sanitizes it the same way as Blackfriday does for markdown headers.
+date: 2018-10-13
+categories: [functions]
+menu:
+ docs:
+ parent: "functions"
+keywords: [markdown,strings]
+signature: ["anchorize INPUT"]
+hugoversion: "0.39"
+workson: []
+relatedfuncs: [humanize]
+---
+
+The template function uses the [`SanitizedAnchorName` logic from Blackfriday](https://github.com/russross/blackfriday#sanitized-anchor-names).
+Since the same sanitizing logic is used as the markdown parser, you can determine the ID of a header for linking with anchor tags.
+
+```
+{{anchorize "This is a header"}} → "this-is-a-header"
+{{anchorize "This is also a header"}} → "this-is-also-a-header"
+{{anchorize "main.go"}} → "main-go"
+{{anchorize "Article 123"}} → "article-123"
+{{anchorize "<- Let's try this, shall we?"}} → "let-s-try-this-shall-we"
+{{anchorize "Hello, 世界"}} → "hello-世界"
+```