mirror of
https://github.com/tiennm99/hugoDocs.git
synced 2026-10-13 22:16:02 +00:00
Merge branch 'tempv0.121.0'
This commit is contained in:
5 files changed
+95
-12
No files matched your search
@@ -24,8 +24,9 @@ Hugo comes with all the code you need to load Disqus into your templates. Before
|
|||||||
|
|
||||||
Disqus comments require you set a single value in your [site's configuration file][configuration] like so:
|
Disqus comments require you set a single value in your [site's configuration file][configuration] like so:
|
||||||
|
|
||||||
{{< code-toggle file=hugo >}}
|
{{< code-toggle file="hugo" >}}
|
||||||
disqusShortname = "yourDisqusShortname"
|
[services.disqus]
|
||||||
|
shortname = 'your-disqus-shortname'
|
||||||
{{</ code-toggle >}}
|
{{</ code-toggle >}}
|
||||||
|
|
||||||
For many websites, this is enough configuration. However, you also have the option to set the following in the [front matter] of a single content file:
|
For many websites, this is enough configuration. However, you also have the option to set the following in the [front matter] of a single content file:
|
||||||
|
|||||||
@@ -0,0 +1,38 @@
|
|||||||
|
---
|
||||||
|
title: transform.XMLEscape
|
||||||
|
description: Returns the given string, removing disallowed characters then escaping the result to its XML equivalent.
|
||||||
|
categories: []
|
||||||
|
keywords: []
|
||||||
|
action:
|
||||||
|
aliases: []
|
||||||
|
related: []
|
||||||
|
returnType: string
|
||||||
|
signatures: [transform.XMLEscape INPUT]
|
||||||
|
---
|
||||||
|
|
||||||
|
The `transform.XMLEscape` function removes [disallowed characters] as defined in the XML specification, then escapes the result by replacing the following characters with [HTML entities]:
|
||||||
|
|
||||||
|
- `"` → `"`
|
||||||
|
- `'` → `'`
|
||||||
|
- `&` → `&`
|
||||||
|
- `<` → `<`
|
||||||
|
- `>` → `>`
|
||||||
|
- `\t` → `	`
|
||||||
|
- `\n` → `
`
|
||||||
|
- `\r` → `
`
|
||||||
|
|
||||||
|
For example:
|
||||||
|
|
||||||
|
```go-html-template
|
||||||
|
transform.XMLEscape "<p>abc</p>" → <p>abc</p>
|
||||||
|
```
|
||||||
|
|
||||||
|
When using `transform.XMLEscape` in a template rendered by Go's [html/template] package, declare the string to be safe HTML to avoid double escaping. For example, in an RSS template:
|
||||||
|
|
||||||
|
{{< code file="layouts/_default/rss.xml" >}}
|
||||||
|
<description>{{ .Summary | transform.XMLEscape | safeHTML }}</description>
|
||||||
|
{{< /code >}}
|
||||||
|
|
||||||
|
[disallowed characters]: https://www.w3.org/TR/xml/#charsets
|
||||||
|
[html entities]: https://developer.mozilla.org/en-us/docs/glossary/entity
|
||||||
|
[html/template]: https://pkg.go.dev/html/template
|
||||||
@@ -44,12 +44,12 @@ In addition to using a single site configuration file, one can use the `configDi
|
|||||||
- Each file represents a configuration root object, such as `params.toml` for `[Params]`, `menu(s).toml` for `[Menu]`, `languages.toml` for `[Languages]` etc...
|
- Each file represents a configuration root object, such as `params.toml` for `[Params]`, `menu(s).toml` for `[Menu]`, `languages.toml` for `[Languages]` etc...
|
||||||
- Each file's content must be top-level, for example:
|
- Each file's content must be top-level, for example:
|
||||||
|
|
||||||
{{< code-toggle file=hugo >}}
|
{{< code-toggle file="hugo" copy=false >}}
|
||||||
[Params]
|
[Params]
|
||||||
foo = "bar"
|
foo = "bar"
|
||||||
{{< /code-toggle >}}
|
{{< /code-toggle >}}
|
||||||
|
|
||||||
{{< code-toggle file=params >}}
|
{{< code-toggle file="params" copy=false >}}
|
||||||
foo = "bar"
|
foo = "bar"
|
||||||
{{< /code-toggle >}}
|
{{< /code-toggle >}}
|
||||||
|
|
||||||
@@ -78,7 +78,7 @@ Let's take an example to understand this better. Let's say you are using Google
|
|||||||
|
|
||||||
[Google tag ID]: https://support.google.com/tagmanager/answer/12326985?hl=en
|
[Google tag ID]: https://support.google.com/tagmanager/answer/12326985?hl=en
|
||||||
|
|
||||||
{{< code-toggle file=hugo >}}
|
{{< code-toggle file=hugo copy=false >}}
|
||||||
[services.googleAnalytics]
|
[services.googleAnalytics]
|
||||||
ID = 'G-XXXXXXXXX'
|
ID = 'G-XXXXXXXXX'
|
||||||
{{< /code-toggle >}}
|
{{< /code-toggle >}}
|
||||||
@@ -103,7 +103,7 @@ To satisfy these requirements, configure your site as follows:
|
|||||||
|
|
||||||
Include this section only:
|
Include this section only:
|
||||||
|
|
||||||
{{< code-toggle file=hugo >}}
|
{{< code-toggle file=hugo copy=false >}}
|
||||||
[services.googleAnalytics]
|
[services.googleAnalytics]
|
||||||
ID = 'G-PPPPPPPPP'
|
ID = 'G-PPPPPPPPP'
|
||||||
{{< /code-toggle >}}
|
{{< /code-toggle >}}
|
||||||
@@ -116,7 +116,7 @@ To satisfy these requirements, configure your site as follows:
|
|||||||
|
|
||||||
Include this section only:
|
Include this section only:
|
||||||
|
|
||||||
{{< code-toggle file=hugo >}}
|
{{< code-toggle file=hugo copy=false >}}
|
||||||
[services.googleAnalytics]
|
[services.googleAnalytics]
|
||||||
ID = 'G-SSSSSSSSS'
|
ID = 'G-SSSSSSSSS'
|
||||||
{{< /code-toggle >}}
|
{{< /code-toggle >}}
|
||||||
|
|||||||
@@ -25,7 +25,8 @@ Hugo ships with an internal template supporting [Google Analytics 4].
|
|||||||
|
|
||||||
Provide your tracking ID in your configuration file:
|
Provide your tracking ID in your configuration file:
|
||||||
|
|
||||||
{{< code-toggle file=hugo >}}
|
**Google Analytics 4 (gtag.js)**
|
||||||
|
{{< code-toggle file="hugo" >}}
|
||||||
[services.googleAnalytics]
|
[services.googleAnalytics]
|
||||||
ID = "G-MEASUREMENT_ID"
|
ID = "G-MEASUREMENT_ID"
|
||||||
{{</ code-toggle >}}
|
{{</ code-toggle >}}
|
||||||
@@ -48,7 +49,7 @@ Hugo also ships with an internal template for [Disqus comments][disqus], a popul
|
|||||||
|
|
||||||
To use Hugo's Disqus template, first set up a single configuration value:
|
To use Hugo's Disqus template, first set up a single configuration value:
|
||||||
|
|
||||||
{{< code-toggle file=hugo >}}
|
{{< code-toggle file="hugo" >}}
|
||||||
[services.disqus]
|
[services.disqus]
|
||||||
shortname = 'your-disqus-shortname'
|
shortname = 'your-disqus-shortname'
|
||||||
{{</ code-toggle >}}
|
{{</ code-toggle >}}
|
||||||
@@ -186,7 +187,7 @@ Hugo uses the page title and description for the card's title and description fi
|
|||||||
|
|
||||||
Set the value of `twitter:site` in your site configuration:
|
Set the value of `twitter:site` in your site configuration:
|
||||||
|
|
||||||
{{< code-toggle file=hugo >}}
|
{{< code-toggle file="hugo" copy=false >}}
|
||||||
[params.social]
|
[params.social]
|
||||||
twitter = "GoHugoIO"
|
twitter = "GoHugoIO"
|
||||||
{{</ code-toggle >}}
|
{{</ code-toggle >}}
|
||||||
|
|||||||
+45
-2
@@ -19,9 +19,15 @@ chroma:
|
|||||||
- ada95
|
- ada95
|
||||||
- ada2005
|
- ada2005
|
||||||
Name: Ada
|
Name: Ada
|
||||||
|
- Aliases:
|
||||||
|
- agda
|
||||||
|
Name: Agda
|
||||||
- Aliases:
|
- Aliases:
|
||||||
- al
|
- al
|
||||||
Name: AL
|
Name: AL
|
||||||
|
- Aliases:
|
||||||
|
- alloy
|
||||||
|
Name: Alloy
|
||||||
- Aliases:
|
- Aliases:
|
||||||
- ng2
|
- ng2
|
||||||
Name: Angular2
|
Name: Angular2
|
||||||
@@ -198,6 +204,9 @@ chroma:
|
|||||||
- Aliases:
|
- Aliases:
|
||||||
- dart
|
- dart
|
||||||
Name: Dart
|
Name: Dart
|
||||||
|
- Aliases:
|
||||||
|
- dax
|
||||||
|
Name: Dax
|
||||||
- Aliases:
|
- Aliases:
|
||||||
- diff
|
- diff
|
||||||
- udiff
|
- udiff
|
||||||
@@ -330,6 +339,9 @@ chroma:
|
|||||||
- handlebars
|
- handlebars
|
||||||
- hbs
|
- hbs
|
||||||
Name: Handlebars
|
Name: Handlebars
|
||||||
|
- Aliases:
|
||||||
|
- hare
|
||||||
|
Name: Hare
|
||||||
- Aliases:
|
- Aliases:
|
||||||
- haskell
|
- haskell
|
||||||
- hs
|
- hs
|
||||||
@@ -501,6 +513,9 @@ chroma:
|
|||||||
- obj-c
|
- obj-c
|
||||||
- objc
|
- objc
|
||||||
Name: Objective-C
|
Name: Objective-C
|
||||||
|
- Aliases:
|
||||||
|
- objectpascal
|
||||||
|
Name: ObjectPascal
|
||||||
- Aliases:
|
- Aliases:
|
||||||
- ocaml
|
- ocaml
|
||||||
Name: OCaml
|
Name: OCaml
|
||||||
@@ -824,6 +839,8 @@ chroma:
|
|||||||
- Aliases:
|
- Aliases:
|
||||||
- typoscripthtmldata
|
- typoscripthtmldata
|
||||||
Name: TypoScriptHtmlData
|
Name: TypoScriptHtmlData
|
||||||
|
- Aliases: null
|
||||||
|
Name: ucode
|
||||||
- Aliases:
|
- Aliases:
|
||||||
- v
|
- v
|
||||||
- vlang
|
- vlang
|
||||||
@@ -1254,6 +1271,9 @@ config:
|
|||||||
keepEndTags: true
|
keepEndTags: true
|
||||||
keepQuotes: false
|
keepQuotes: false
|
||||||
keepWhitespace: false
|
keepWhitespace: false
|
||||||
|
templateDelims:
|
||||||
|
- ""
|
||||||
|
- ""
|
||||||
js:
|
js:
|
||||||
keepVarNames: false
|
keepVarNames: false
|
||||||
precision: 0
|
precision: 0
|
||||||
@@ -1563,8 +1583,6 @@ config:
|
|||||||
getenv:
|
getenv:
|
||||||
- ^HUGO_
|
- ^HUGO_
|
||||||
- ^CI$
|
- ^CI$
|
||||||
goTemplates:
|
|
||||||
allowActionJSTmpl: false
|
|
||||||
http:
|
http:
|
||||||
mediaTypes: null
|
mediaTypes: null
|
||||||
methods:
|
methods:
|
||||||
@@ -2741,6 +2759,21 @@ tpl:
|
|||||||
map[string]interface {}{
|
map[string]interface {}{
|
||||||
"Hugo": "Rocks!",
|
"Hugo": "Rocks!",
|
||||||
}
|
}
|
||||||
|
TestDeprecationErr:
|
||||||
|
Aliases: null
|
||||||
|
Args: null
|
||||||
|
Description: ""
|
||||||
|
Examples: null
|
||||||
|
TestDeprecationInfo:
|
||||||
|
Aliases: null
|
||||||
|
Args: null
|
||||||
|
Description: ""
|
||||||
|
Examples: null
|
||||||
|
TestDeprecationWarn:
|
||||||
|
Aliases: null
|
||||||
|
Args: null
|
||||||
|
Description: ""
|
||||||
|
Examples: null
|
||||||
Timer:
|
Timer:
|
||||||
Aliases: null
|
Aliases: null
|
||||||
Args: null
|
Args: null
|
||||||
@@ -4364,6 +4397,16 @@ tpl:
|
|||||||
- - '{{ "hello = \"Hello World\"" | resources.FromString "data/greetings.toml"
|
- - '{{ "hello = \"Hello World\"" | resources.FromString "data/greetings.toml"
|
||||||
| transform.Unmarshal }}'
|
| transform.Unmarshal }}'
|
||||||
- map[hello:Hello World]
|
- map[hello:Hello World]
|
||||||
|
XMLEscape:
|
||||||
|
Aliases: null
|
||||||
|
Args:
|
||||||
|
- s
|
||||||
|
Description: |-
|
||||||
|
XMLEscape returns the given string, removing disallowed characters then
|
||||||
|
escaping the result to its XML equivalent.
|
||||||
|
Examples:
|
||||||
|
- - '{{ transform.XMLEscape "<p>abc</p>" }}'
|
||||||
|
- '<p>abc</p>'
|
||||||
urls:
|
urls:
|
||||||
AbsLangURL:
|
AbsLangURL:
|
||||||
Aliases:
|
Aliases:
|
||||||
|
|||||||
Reference in new issue
Block a user