diff --git a/content/en/content-management/comments.md b/content/en/content-management/comments.md index 5f2f9660b..9985dd1e6 100644 --- a/content/en/content-management/comments.md +++ b/content/en/content-management/comments.md @@ -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: -{{< code-toggle file=hugo >}} -disqusShortname = "yourDisqusShortname" +{{< code-toggle file="hugo" >}} +[services.disqus] +shortname = 'your-disqus-shortname' {{}} 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: diff --git a/content/en/functions/transform/XMLEscape.md b/content/en/functions/transform/XMLEscape.md new file mode 100644 index 000000000..17ed2a13d --- /dev/null +++ b/content/en/functions/transform/XMLEscape.md @@ -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 "

abc

" → <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" >}} +{{ .Summary | transform.XMLEscape | safeHTML }} +{{< /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 diff --git a/content/en/getting-started/configuration.md b/content/en/getting-started/configuration.md index 089bee8be..d1bea2e76 100644 --- a/content/en/getting-started/configuration.md +++ b/content/en/getting-started/configuration.md @@ -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's content must be top-level, for example: -{{< code-toggle file=hugo >}} +{{< code-toggle file="hugo" copy=false >}} [Params] foo = "bar" {{< /code-toggle >}} -{{< code-toggle file=params >}} +{{< code-toggle file="params" copy=false >}} foo = "bar" {{< /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 -{{< code-toggle file=hugo >}} +{{< code-toggle file=hugo copy=false >}} [services.googleAnalytics] ID = 'G-XXXXXXXXX' {{< /code-toggle >}} @@ -103,7 +103,7 @@ To satisfy these requirements, configure your site as follows: Include this section only: - {{< code-toggle file=hugo >}} + {{< code-toggle file=hugo copy=false >}} [services.googleAnalytics] ID = 'G-PPPPPPPPP' {{< /code-toggle >}} @@ -116,7 +116,7 @@ To satisfy these requirements, configure your site as follows: Include this section only: - {{< code-toggle file=hugo >}} + {{< code-toggle file=hugo copy=false >}} [services.googleAnalytics] ID = 'G-SSSSSSSSS' {{< /code-toggle >}} diff --git a/content/en/templates/internal.md b/content/en/templates/internal.md index 2e73455f0..0785318ab 100644 --- a/content/en/templates/internal.md +++ b/content/en/templates/internal.md @@ -25,7 +25,8 @@ Hugo ships with an internal template supporting [Google Analytics 4]. Provide your tracking ID in your configuration file: -{{< code-toggle file=hugo >}} +**Google Analytics 4 (gtag.js)** +{{< code-toggle file="hugo" >}} [services.googleAnalytics] ID = "G-MEASUREMENT_ID" {{}} @@ -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: -{{< code-toggle file=hugo >}} +{{< code-toggle file="hugo" >}} [services.disqus] shortname = 'your-disqus-shortname' {{}} @@ -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: -{{< code-toggle file=hugo >}} +{{< code-toggle file="hugo" copy=false >}} [params.social] twitter = "GoHugoIO" {{}} diff --git a/data/docs.yaml b/data/docs.yaml index 2cdb0dd53..f59974724 100644 --- a/data/docs.yaml +++ b/data/docs.yaml @@ -19,9 +19,15 @@ chroma: - ada95 - ada2005 Name: Ada + - Aliases: + - agda + Name: Agda - Aliases: - al Name: AL + - Aliases: + - alloy + Name: Alloy - Aliases: - ng2 Name: Angular2 @@ -198,6 +204,9 @@ chroma: - Aliases: - dart Name: Dart + - Aliases: + - dax + Name: Dax - Aliases: - diff - udiff @@ -330,6 +339,9 @@ chroma: - handlebars - hbs Name: Handlebars + - Aliases: + - hare + Name: Hare - Aliases: - haskell - hs @@ -501,6 +513,9 @@ chroma: - obj-c - objc Name: Objective-C + - Aliases: + - objectpascal + Name: ObjectPascal - Aliases: - ocaml Name: OCaml @@ -824,6 +839,8 @@ chroma: - Aliases: - typoscripthtmldata Name: TypoScriptHtmlData + - Aliases: null + Name: ucode - Aliases: - v - vlang @@ -1254,6 +1271,9 @@ config: keepEndTags: true keepQuotes: false keepWhitespace: false + templateDelims: + - "" + - "" js: keepVarNames: false precision: 0 @@ -1563,8 +1583,6 @@ config: getenv: - ^HUGO_ - ^CI$ - goTemplates: - allowActionJSTmpl: false http: mediaTypes: null methods: @@ -2741,6 +2759,21 @@ tpl: map[string]interface {}{ "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: Aliases: null Args: null @@ -4364,6 +4397,16 @@ tpl: - - '{{ "hello = \"Hello World\"" | resources.FromString "data/greetings.toml" | transform.Unmarshal }}' - 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 "

abc

" }}' + - '<p>abc</p>' urls: AbsLangURL: Aliases: