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

github.com/gohugoio/hugoDocs.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Oliff <christianoliff@pm.me>2022-10-30 16:15:25 +0300
committerGitHub <noreply@github.com>2022-10-30 16:15:25 +0300
commit3eeee13bf490549c8198458b4f80dac16165aff0 (patch)
tree3e5320659c140822d17facb4e68d6abd4b0f634c /content
parente152cdf1ff58d05e8b7dc0fe9cc1034bdf67102c (diff)
Markdown formatting: Add Fenced code block languages (#1858)
Diffstat (limited to 'content')
-rw-r--r--content/en/content-management/image-processing/index.md6
-rw-r--r--content/en/hugo-modules/use-modules.md2
-rw-r--r--content/en/hugo-pipes/js.md2
-rw-r--r--content/en/readfiles/dateformatting.md10
-rw-r--r--content/en/templates/base.md2
-rw-r--r--content/en/templates/data-templates.md12
-rw-r--r--content/en/templates/internal.md10
-rw-r--r--content/en/templates/introduction.md4
-rw-r--r--content/en/templates/lists.md8
-rw-r--r--content/en/templates/menu-templates.md10
-rw-r--r--content/en/templates/output-formats.md4
-rw-r--r--content/en/templates/pagination.md10
-rw-r--r--content/en/templates/section-templates.md8
-rw-r--r--content/en/templates/shortcode-templates.md28
-rw-r--r--content/en/templates/template-debugging.md12
-rw-r--r--content/en/templates/views.md4
-rw-r--r--content/en/troubleshooting/build-performance.md2
-rw-r--r--content/en/variables/page.md14
18 files changed, 73 insertions, 75 deletions
diff --git a/content/en/content-management/image-processing/index.md b/content/en/content-management/image-processing/index.md
index 84e55989b..8fdab2d6e 100644
--- a/content/en/content-management/image-processing/index.md
+++ b/content/en/content-management/image-processing/index.md
@@ -309,7 +309,7 @@ The default value is 75. You may override the default value in the [site configu
<!-- Specifies a libwebp preset, not a libwebp image hint. -->
-Applicable to WebP images, this option corresponds to a set of pre-defined encoding parameters.
+Applicable to WebP images, this option corresponds to a set of predefined encoding parameters.
Value|Example
:--|:--
@@ -377,10 +377,10 @@ _The photo of the sunset used in the examples below is Copyright [Bjørn Erik Pe
This is the shortcode used to generate the examples above:
{{< code file="layouts/shortcodes/imgproc.html" >}}
-{{< readfile file="layouts/shortcodes/imgproc.html" >}}
+{{< readfile file="layouts/shortcodes/imgproc.html" >}}
{{< /code >}}
-Call the shortcode from your markdown like this:
+Call the shortcode from your Markdown like this:
```go-html-template
{{</* imgproc sunset Resize "300x" /*/>}}
diff --git a/content/en/hugo-modules/use-modules.md b/content/en/hugo-modules/use-modules.md
index c1aad955a..267e7953c 100644
--- a/content/en/hugo-modules/use-modules.md
+++ b/content/en/hugo-modules/use-modules.md
@@ -97,7 +97,7 @@ Use `hugo mod graph` from the relevant module directory and it will print the de
E.g.:
-```
+```txt
hugo mod graph
github.com/bep/my-modular-site github.com/bep/hugotestmods/mymounts@v1.2.0
diff --git a/content/en/hugo-pipes/js.md b/content/en/hugo-pipes/js.md
index 705b55996..340e2606e 100644
--- a/content/en/hugo-pipes/js.md
+++ b/content/en/hugo-pipes/js.md
@@ -44,7 +44,7 @@ inject [slice] {{< new-in "0.81.0" >}}
shims {{< new-in "0.81.0" >}}
: This option allows swapping out a component with another. A common use case is to load dependencies like React from a CDN (with _shims_) when in production, but running with the full bundled `node_modules` dependency during development:
-```
+```go-html-template
{{ $shims := dict "react" "js/shims/react.js" "react-dom" "js/shims/react-dom.js" }}
{{ $js = $js | js.Build dict "shims" $shims }}
```
diff --git a/content/en/readfiles/dateformatting.md b/content/en/readfiles/dateformatting.md
index cd340cf19..2aeb60438 100644
--- a/content/en/readfiles/dateformatting.md
+++ b/content/en/readfiles/dateformatting.md
@@ -1,12 +1,12 @@
Go templates [format your dates][time] according to a single reference time:
-```
+```txt
Mon Jan 2 15:04:05 MST 2006
```
You can think of `MST` as `07`, thus making the reference format string a sequence of numbers. The following is [taken directly from the Go docs][gdex]:
-```
+```txt
Jan 2 15:04:05 2006 MST
1 2 3 4 5 6 -7
```
@@ -17,7 +17,7 @@ Each of the following examples show the reference formatting string followed by
Note that the examples were rendered and tested in [CST][] and pull from a single example date you might have in your content's front matter:
-```
+```yml
date: 2017-03-03T14:15:59-06:00
```
@@ -60,13 +60,13 @@ Spelled-out cardinal numbers (e.g. "one", "two", and "three") and ordinal abbrev
To continue with the example above:
-```
+```go-html-template
{{.Date.Format "Jan 2nd 2006"}}
```
Hugo assumes you want to append `nd` as a string to the day of the month and outputs the following:
-```
+```txt
Mar 3nd 2017
```
diff --git a/content/en/templates/base.md b/content/en/templates/base.md
index e6d4388e9..cf1f8584d 100644
--- a/content/en/templates/base.md
+++ b/content/en/templates/base.md
@@ -74,7 +74,7 @@ This replaces the contents of our (basically empty) "main" block with something
{{% warning %}}
Code that you put outside the block definitions *can* break your layout. This even includes HTML comments. For example:
-```
+```go-html-template
<!-- Seemingly harmless HTML comment..that will break your layout at build -->
{{ define "main" }}
...your code here
diff --git a/content/en/templates/data-templates.md b/content/en/templates/data-templates.md
index 3bfdaa056..dfaeedf3e 100644
--- a/content/en/templates/data-templates.md
+++ b/content/en/templates/data-templates.md
@@ -75,7 +75,7 @@ The list of bass players can be accessed via `.Site.Data.jazz.bass`, a single ba
You can now render the list of recordings for all the bass players in a template:
-```
+```go-html-template
{{ range $.Site.Data.jazz.bass }}
{{ partial "artist.html" . }}
{{ end }}
@@ -83,7 +83,7 @@ You can now render the list of recordings for all the bass players in a template
And then in the `partials/artist.html`:
-```
+```go-html-template
<ul>
{{ range .discography }}
<li>{{ . }}</li>
@@ -119,14 +119,14 @@ Note the use of the [`markdownify` template function][markdownify]. This will se
Use `getJSON` or `getCSV` to get remote data:
-```
+```go-html-template
{{ $dataJ := getJSON "url" }}
{{ $dataC := getCSV "separator" "url" }}
```
If you use a prefix or postfix for the URL, the functions accept [variadic arguments][variadic]:
-```
+```go-html-template
{{ $dataJ := getJSON "url prefix" "arg1" "arg2" "arg n" }}
{{ $dataC := getCSV "separator" "url prefix" "arg1" "arg2" "arg n" }}
```
@@ -135,14 +135,14 @@ The separator for `getCSV` must be put in the first position and can only be one
All passed arguments will be joined to the final URL:
-```
+```go-html-template
{{ $urlPre := "https://api.github.com" }}
{{ $gistJ := getJSON $urlPre "/users/GITHUB_USERNAME/gists" }}
```
This will resolve internally to the following:
-```
+```go-html-template
{{ $gistJ := getJSON "https://api.github.com/users/GITHUB_USERNAME/gists" }}
```
diff --git a/content/en/templates/internal.md b/content/en/templates/internal.md
index 40cc3e934..6e6420d16 100644
--- a/content/en/templates/internal.md
+++ b/content/en/templates/internal.md
@@ -52,13 +52,13 @@ googleAnalytics = "UA-PROPERTY_ID"
You can then include the Google Analytics internal template:
-```
+```go-html-template
{{ template "_internal/google_analytics_async.html" . }}
```
**Note:** The async template is _not_ suitable for Google Analytics 4.
-```
+```go-html-template
{{ template "_internal/google_analytics.html" . }}
```
@@ -122,7 +122,7 @@ The `if` statement skips the initialization of the Disqus comment injection when
You can then render your custom Disqus partial template as follows:
-```
+```go-html-template
{{ partial "disqus.html" . }}
```
@@ -172,7 +172,7 @@ If using YouTube this will produce a og:video tag like `<meta property="og:video
To add Open Graph metadata, include the following line between the `<head>` tags in your templates:
-```
+```go-html-template
{{ template "_internal/opengraph.html" . }}
```
@@ -207,7 +207,7 @@ Hugo uses the page title and description for the card's title and description fi
To add Twitter card metadata, include the following line immediately after the `<head>` element in your templates:
-```
+```go-html-template
{{ template "_internal/twitter_cards.html" . }}
```
diff --git a/content/en/templates/introduction.md b/content/en/templates/introduction.md
index 25487e397..01f448778 100644
--- a/content/en/templates/introduction.md
+++ b/content/en/templates/introduction.md
@@ -43,7 +43,7 @@ current scope (like the `.Title` example in the [Variables]({{< relref
Parameters for functions are separated using spaces. The general syntax is:
-```
+```go-html-template
{{ FUNCTION ARG1 ARG2 .. }}
```
@@ -529,7 +529,7 @@ An example of this is used in the Hugo docs. Most of the pages benefit from havi
Here is the example front matter (YAML):
-```
+```yml
---
title: Roadmap
lastmod: 2017-03-05
diff --git a/content/en/templates/lists.md b/content/en/templates/lists.md
index 97dc0f40d..275da8772 100644
--- a/content/en/templates/lists.md
+++ b/content/en/templates/lists.md
@@ -524,21 +524,21 @@ While these are logical defaults, they are not always the desired order. There a
#### 1. Adding the Reverse Method
-```
+```go-html-template
{{ range (.Pages.GroupBy "Section").Reverse }}
```
-```
+```go-html-template
{{ range (.Pages.GroupByDate "2006-01").Reverse }}
```
#### 2. Providing the Alternate Direction
-```
+```go-html-template
{{ range .Pages.GroupByDate "2006-01" "asc" }}
```
-```
+```go-html-template
{{ range .Pages.GroupBy "Section" "desc" }}
```
diff --git a/content/en/templates/menu-templates.md b/content/en/templates/menu-templates.md
index 54f1ba623..65325b578 100644
--- a/content/en/templates/menu-templates.md
+++ b/content/en/templates/menu-templates.md
@@ -72,7 +72,7 @@ Use the [`absLangURL`](/functions/abslangurl) or [`relLangURL`](/functions/rella
To enable this menu, configure `sectionPagesMenu` in your site `config`:
-```
+```yml
sectionPagesMenu = "main"
```
@@ -82,7 +82,7 @@ This will create a menu with all the sections as menu items and all the sections
The _shadow_ implies that the pages isn't represented by a menu-item themselves, but this enables you to create a top-level menu like this:
-```
+```go-html-template
<nav class="sidebar-nav">
{{ $currentPage := . }}
{{ range .Site.Menus.main }}
@@ -116,7 +116,7 @@ It's also possible to create menu entries from the page (i.e. the `.md`-file).
Here is a `yaml` example:
-```
+```yml
---
title: Menu Templates
linktitle: Menu Templates
@@ -147,7 +147,7 @@ That's why you have to use the go template's `with` keyword or something similar
Here's an example:
-```
+```go-html-template
<nav class="sidebar-nav">
{{ range .Site.Menus.main }}
<a href="{{ .URL }}" title="{{ .Title }}">
@@ -168,7 +168,7 @@ User-defined content on menu items are accessible via `.Params`.
Here's an example:
-```
+```go-html-template
<nav class="sidebar-nav">
{{ range .Site.Menus.main }}
<a href="{{ .URL }}" title="{{ .Title }}" class="{{ with .Params.class }}{{ . }}{{ end }}">
diff --git a/content/en/templates/output-formats.md b/content/en/templates/output-formats.md
index 6d0981cca..44e697d34 100644
--- a/content/en/templates/output-formats.md
+++ b/content/en/templates/output-formats.md
@@ -244,13 +244,13 @@ Hugo will now also detect the media type and output format of partials, if possi
Hugo will look for the name given, so you can name it whatever you want. But if you want it treated as plain text, you should use the file suffix and, if needed, the name of the Output Format. The pattern is as follows:
-```
+```go-html-template
[partial name].[OutputFormat].[suffix]
```
The partial below is a plain text template (Output Format is `CSV`, and since this is the only output format with the suffix `csv`, we don't need to include the Output Format's `Name`):
-```
+```go-html-template
{{ partial "mytextpartial.csv" . }}
```
diff --git a/content/en/templates/pagination.md b/content/en/templates/pagination.md
index 5254b47ed..0ae2f4013 100644
--- a/content/en/templates/pagination.md
+++ b/content/en/templates/pagination.md
@@ -4,7 +4,6 @@ linktitle: Pagination
description: Hugo supports pagination for your homepage, section pages, and taxonomies.
date: 2017-02-01
publishdate: 2017-02-01
-lastmod: 2017-02-01
categories: [templates]
keywords: [lists,sections,pagination]
menu:
@@ -13,7 +12,6 @@ menu:
weight: 140
weight: 140
sections_weight: 140
-draft: false
aliases: [/extras/pagination,/doc/pagination/]
toc: true
---
@@ -60,7 +58,7 @@ The global page size setting (`Paginate`) can be overridden by providing a posit
It is also possible to use the `GroupBy` functions in combination with pagination:
-```
+```go-html-template
{{ range (.Paginate (.Pages.GroupByDate "2006")).PageGroups }}
```
@@ -70,7 +68,7 @@ The `.Paginator` contains enough information to build a paginator interface.
The easiest way to add this to your pages is to include the built-in template (with `Bootstrap`-compatible styles):
-```
+```go-html-template
{{ template "_internal/pagination.html" . }}
```
@@ -80,7 +78,7 @@ If you use any filters or ordering functions to create your `.Paginator` *and* y
The following example shows how to create `.Paginator` before its used:
-```
+```go-html-template
{{ $paginator := .Paginate (where .Pages "Type" "posts") }}
{{ template "_internal/pagination.html" . }}
{{ range $paginator.Pages }}
@@ -90,7 +88,7 @@ The following example shows how to create `.Paginator` before its used:
Without the `where` filter, the above example is even simpler:
-```
+```go-html-template
{{ template "_internal/pagination.html" . }}
{{ range .Paginator.Pages }}
{{ .Title }}
diff --git a/content/en/templates/section-templates.md b/content/en/templates/section-templates.md
index 1339f48a1..6b3a099f7 100644
--- a/content/en/templates/section-templates.md
+++ b/content/en/templates/section-templates.md
@@ -85,25 +85,25 @@ The `.Site.GetPage` example that follows assumes the following project directory
`.Site.GetPage` will return `nil` if no `_index.md` page is found. Therefore, if `content/blog/_index.md` does not exist, the template will output the section name:
-```
+```go-html-template
<h1>{{ with .Site.GetPage "section" "blog" }}{{ .Title }}{{ end }}</h1>
```
Since `blog` has a section index page with front matter at `content/blog/_index.md`, the above code will return the following result:
-```
+```html
<h1>My Hugo Blog</h1>
```
If we try the same code with the `events` section, however, Hugo will default to the section title because there is no `content/events/_index.md` from which to pull content and front matter:
-```
+```go-html-template
<h1>{{ with .Site.GetPage "section" "events" }}{{ .Title }}{{ end }}</h1>
```
Which then returns the following:
-```
+```html
<h1>Events</h1>
```
diff --git a/content/en/templates/shortcode-templates.md b/content/en/templates/shortcode-templates.md
index bd017450f..657e91231 100644
--- a/content/en/templates/shortcode-templates.md
+++ b/content/en/templates/shortcode-templates.md
@@ -69,32 +69,32 @@ All shortcode parameters can be accessed via the `.Get` method. Whether you pass
To access a parameter by name, use the `.Get` method followed by the named parameter as a quoted string:
-```
+```go-html-template
{{ .Get "class" }}
```
To access a parameter by position, use the `.Get` followed by a numeric position, keeping in mind that positional parameters are zero-indexed:
-```
+```go-html-template
{{ .Get 0 }}
```
For the second position, you would just use:
-```
+```go-html-template
{{ .Get 1 }}
```
`with` is great when the output depends on a parameter being set:
-```
+```go-html-template
{{ with .Get "class" }} class="{{ . }}"{{ end }}
```
`.Get` can also be used to check if a parameter has been provided. This is
most helpful when the condition depends on either of the values, or both:
-```
+```go-html-template
{{ if or (.Get "title") (.Get "alt") }} alt="{{ with .Get "alt" }}{{ . }}{{ else }}{{ .Get "title" }}{{ end }}"{{ end }}
```
@@ -104,7 +104,7 @@ If a closing shortcode is used, the `.Inner` variable will be populated with all
A shortcode with content declared via the `.Inner` variable can also be declared without the content and without the closing by using the self-closing syntax:
-```
+```go-html-template
{{</* innershortcode /*/>}}
```
@@ -132,13 +132,13 @@ The `.IsNamedParams` variable checks whether the shortcode declaration uses name
For example, you could create an `image` shortcode that can take either a `src` named parameter or the first positional parameter, depending on the preference of the content's author. Let's assume the `image` shortcode is called as follows:
-```
+```go-html-template
{{</* image src="images/my-image.jpg" */>}}
```
You could then include the following as part of your shortcode templating:
-```
+```go-html-template
{{ if .IsNamedParams }}
<img src="{{ .Get "src" }}" alt="">
{{ else }}
@@ -166,9 +166,9 @@ The following are examples of the different types of shortcodes you can create v
### Single-word Example: `year`
-Let's assume you would like to keep mentions of your copyright year current in your content files without having to continually review your markdown. Your goal is to be able to call the shortcode as follows:
+Let's assume you would like to keep mentions of your copyright year current in your content files without having to continually review your Markdown. Your goal is to be able to call the shortcode as follows:
-```
+```go-html-template
{{</* year */>}}
```
@@ -178,9 +178,9 @@ Let's assume you would like to keep mentions of your copyright year current in y
### Single Positional Example: `youtube`
-Embedded videos are a common addition to markdown content that can quickly become unsightly. The following is the code used by [Hugo's built-in YouTube shortcode][youtubeshortcode]:
+Embedded videos are a common addition to Markdown content that can quickly become unsightly. The following is the code used by [Hugo's built-in YouTube shortcode][youtubeshortcode]:
-```
+```go-html-template
{{</* youtube 09jf3ow9jfw */>}}
```
@@ -247,7 +247,7 @@ Would be rendered as:
### Single Flexible Example: `vimeo`
-```
+```go-html-template
{{</* vimeo 49718712 */>}}
{{</* vimeo id="49718712" class="flex-video" */>}}
```
@@ -291,7 +291,7 @@ The following is taken from `highlight`, which is a [built-in shortcode][] that
The template for the `highlight` shortcode uses the following code, which is already included in Hugo:
-```
+```go-html-template
{{ .Get 0 | highlight .Inner }}
```
diff --git a/content/en/templates/template-debugging.md b/content/en/templates/template-debugging.md
index d05f015cc..8992c432d 100644
--- a/content/en/templates/template-debugging.md
+++ b/content/en/templates/template-debugging.md
@@ -23,26 +23,26 @@ These snippets use the `printf` function available in all Go templates. This fu
You can use the template syntax, `$.`, to get the top-level template context from anywhere in your template. This will print out all the values under, `.Site`.
-```
+```go-html-template
{{ printf "%#v" $.Site }}
```
This will print out the value of `.Permalink`:
-```
+```go-html-template
{{ printf "%#v" .Permalink }}
```
This will print out a list of all the variables scoped to the current context
(`.`, aka ["the dot"][tempintro]).
-```
+```go-html-template
{{ printf "%#v" . }}
```
When developing a [homepage][], what does one of the pages you're looping through look like?
-```
+```go-html-template
{{ range .Pages }}
{{/* The context, ".", is now each one of the pages as it goes through the loop */}}
{{ printf "%#v" . }}
@@ -53,13 +53,13 @@ When developing a [homepage][], what does one of the pages you're looping throug
Check that you are passing variables in the `partial` function:
-```
+```go-html-template
{{ partial "header.html" }}
```
This example will render the header partial, but the header partial will not have access to any contextual variables. You need to pass variables explicitly. For example, note the addition of ["the dot"][tempintro].
-```
+```go-html-template
{{ partial "header.html" . }}
```
diff --git a/content/en/templates/views.md b/content/en/templates/views.md
index 87f66afe0..362f1ec62 100644
--- a/content/en/templates/views.md
+++ b/content/en/templates/views.md
@@ -29,7 +29,7 @@ The following are common use cases for content views:
To create a new view, create a template in each of your different content type directories with the view name. The following example contains an "li" view and a "summary" view for the `posts` and `project` content types. As you can see, these sit next to the [single content view][single] template, `single.html`. You can even provide a specific view for a given type and continue to use the `_default/single.html` for the primary view.
-```
+```txt
▾ layouts/
▾ posts/
li.html
@@ -44,7 +44,7 @@ To create a new view, create a template in each of your different content type d
Hugo also has support for a default content template to be used in the event that a specific content view template has not been provided for that type. Content views can also be defined in the `_default` directory and will work the same as list and single templates who eventually trickle down to the `_default` directory as a matter of the lookup order.
-```
+```txt
▾ layouts/
▾ _default/
li.html
diff --git a/content/en/troubleshooting/build-performance.md b/content/en/troubleshooting/build-performance.md
index 543c71247..ea31ef84b 100644
--- a/content/en/troubleshooting/build-performance.md
+++ b/content/en/troubleshooting/build-performance.md
@@ -30,7 +30,7 @@ executions take **in terms of CPU time**.
| count | The number of times a template was executed. |
| template | The template name. |
-```
+```txt
▶ hugo --templateMetrics
Started building sites ...
diff --git a/content/en/variables/page.md b/content/en/variables/page.md
index 43738da20..26249e61d 100644
--- a/content/en/variables/page.md
+++ b/content/en/variables/page.md
@@ -200,7 +200,7 @@ aliased form `.Pages`.
Any other value defined in the front matter in a content file, including taxonomies, will be made available as part of the `.Params` variable.
-```
+```yml
---
title: My First Post
date: 2017-02-20T15:26:23-06:00
@@ -219,7 +219,7 @@ Page-level `.Params` are *only* accessible in lowercase.
The `.Params` variable is particularly useful for the introduction of user-defined front matter fields in content files. For example, a Hugo website on book reviews could have the following front matter in `/content/review/book01.md`:
-```
+```yml
---
...
affiliatelink: "http://www.my-book-link.here"
@@ -252,7 +252,7 @@ See [Archetypes](/content-management/archetypes/) for consistency of `Params` ac
In Hugo, you can declare params in individual pages and globally for your entire website. A common use case is to have a general value for the site param and a more specific value for some of the pages (i.e., a header image):
-```
+```go-html-template
{{ $.Param "header_image" }}
```
@@ -262,7 +262,7 @@ The `.Param` method provides a way to resolve a single value according to it's d
When front matter contains nested fields like the following:
-```
+```yml
---
author:
given_name: John
@@ -272,13 +272,13 @@ author:
```
`.Param` can access these fields by concatenating the field names together with a dot:
-```
+```go-html-template
{{ $.Param "author.display_name" }}
```
If your front matter contains a top-level key that is ambiguous with a nested key, as in the following case:
-```
+```yml
---
favorites.flavor: vanilla
favorites:
@@ -288,7 +288,7 @@ favorites:
The top-level key will be preferred. Therefore, the following method, when applied to the previous example, will print `vanilla` and not `chocolate`:
-```
+```txt
{{ $.Param "favorites.flavor" }}
=> vanilla
```