diff --git a/README.md b/README.md index 64ba31a48..58d0e748c 100644 --- a/README.md +++ b/README.md @@ -19,9 +19,9 @@ Please see the [contributing] section for guidelines, examples, and process. # Install -```bash +```sh npm i hugo server ``` -**Note:** We're working on removing the need to run `npm i` for local development. Stay tuned. \ No newline at end of file +**Note:** We're working on removing the need to run `npm i` for local development. Stay tuned. diff --git a/content/en/_common/methods/page/next-and-prev.md b/content/en/_common/methods/page/next-and-prev.md index babc88ff4..f859961a4 100644 --- a/content/en/_common/methods/page/next-and-prev.md +++ b/content/en/_common/methods/page/next-and-prev.md @@ -32,13 +32,13 @@ content/ And these templates: -{{< code file=layouts/_default/list.html >}} +```go-html-template {file="layouts/_default/list.html"} {{ range .Pages.ByWeight }}
Related content:
{{- .Inner | htmlEscape | safeHTML }}
{{ .Page.Store.Set "hasMermaid" true }}
-{{< /code >}}
+```
And then include this snippet at the _bottom_ of the content template, before the closing `body` tag:
diff --git a/content/en/content-management/front-matter.md b/content/en/content-management/front-matter.md
index 954364278..30110c604 100644
--- a/content/en/content-management/front-matter.md
+++ b/content/en/content-management/front-matter.md
@@ -243,7 +243,7 @@ You can add taxonomy terms to the front matter of any these [page kinds](g):
Access taxonomy terms from a template using the [`Params`] or [`GetTerms`] method on a `Page` object. For example:
-{{< code file=layouts/_default/single.html >}}
+```go-html-template {file="layouts/_default/single.html"}
{{ with .GetTerms "tags" }}
Tags
Related content:
{{ . }} is even
{{ else }}{{ . }} is odd
{{ end }} -{{< /code >}} +``` When called, the partial renders HTML: @@ -40,9 +40,9 @@ When called, the partial renders HTML: Instead of rendering HTML, let's create a partial that _returns_ a boolean value, reporting whether the given number is even: -{{< code file=layouts/partials/is-even.html >}} +```go-html-template {file="layouts/partials/is-even.html"} {{ return math.ModBool . 2 }} -{{< /code >}} +``` With this template: @@ -75,7 +75,7 @@ A partial that returns a value must contain only one `return` statement, placed For example: -{{< code file=layouts/partials/is-even.html >}} +```go-html-template {file="layouts/partials/is-even.html"} {{ $result := false }} {{ if math.ModBool . 2 }} {{ $result = "even" }} @@ -83,16 +83,16 @@ For example: {{ $result = "odd" }} {{ end }} {{ return $result }} -{{< /code >}} +``` {{< note >}} The construct below is incorrect; it contains more than one `return` statement. {{< /note >}} -{{< code file=layouts/partials/do-not-do-this.html >}} +```go-html-template {file="layouts/partials/do-not-do-this.html"} {{ if math.ModBool . 2 }} {{ return "even" }} {{ else }} {{ return "odd" }} {{ end }} -{{< /code >}} +``` diff --git a/content/en/functions/images/AutoOrient.md b/content/en/functions/images/AutoOrient.md index 4a5e221a8..5af396e59 100644 --- a/content/en/functions/images/AutoOrient.md +++ b/content/en/functions/images/AutoOrient.md @@ -20,7 +20,6 @@ Create the filter: {{ $filter := images.AutoOrient }} ``` - {{% include "/_common/functions/images/apply-image-filter.md" %}} {{< note >}} diff --git a/content/en/functions/images/QR.md b/content/en/functions/images/QR.md index 6d6a5485a..a8375b904 100644 --- a/content/en/functions/images/QR.md +++ b/content/en/functions/images/QR.md @@ -73,7 +73,7 @@ Specify `level`, `scale`, and `targetDir` as needed to achieve the desired resul To include a QR code that points to the `Permalink` of the current page: -{{< code file=layouts/_default/single.html >}} +```go-html-template {file="layouts/_default/single.html"} {{ with images.QR .Permalink }}Related pages:
{{ .Text }}-{{< /code >}} +``` To render a blockquote as an HTML `figure` element with an optional citation and caption: -{{< code file=layouts/_default/_markup/render-blockquote.html copy=true >}} +```go-html-template {file="layouts/_default/_markup/render-blockquote.html" copy=true}
{{ .Text }} @@ -77,7 +77,7 @@ To render a blockquote as an HTML `figure` element with an optional citation and {{ end }}
{{- .Inner | htmlEscape | safeHTML }}
{{ .Page.Store.Set "hasMermaid" true }}
-{{< /code >}}
+```
Then include this snippet at the bottom of the your base template:
-{{< code file=layouts/_default/baseof.html copy=true >}}
+```go-html-template {file="layouts/_default/baseof.html" copy=true}
{{ if .Store.Get "hasMermaid" }}
{{ end }}
-{{< /code >}}
+```
See the [diagrams] page for details.
diff --git a/content/en/render-hooks/headings.md b/content/en/render-hooks/headings.md
index f4ded9b70..89868d478 100755
--- a/content/en/render-hooks/headings.md
+++ b/content/en/render-hooks/headings.md
@@ -46,19 +46,19 @@ In its default configuration, Hugo renders Markdown headings according to the [C
[CommonMark specification]: https://spec.commonmark.org/current/
-{{< code file=layouts/_default/_markup/render-heading.html copy=true >}}
+```go-html-template {file="layouts/_default/_markup/render-heading.html" copy=true}
The page you requested cannot be found.
@@ -19,7 +19,7 @@ To render a 404 error page in the root of your site, create a 404 template in th {{ end }} -{{< /code >}} +``` For multilingual sites, add the language key to the file name: diff --git a/content/en/templates/base.md b/content/en/templates/base.md index b4550fcd4..bf861fbab 100644 --- a/content/en/templates/base.md +++ b/content/en/templates/base.md @@ -21,7 +21,7 @@ See [Template Lookup Order](/templates/lookup-order/) for details and examples. The following defines a simple base template at `_default/baseof.html`. As a default template, it is the shell from which all your pages will be rendered unless you specify another `*baseof.html` closer to the beginning of the lookup order. -{{< code file=layouts/_default/baseof.html >}} +```go-html-template {file="layouts/_default/baseof.html"} @@ -41,13 +41,13 @@ The following defines a simple base template at `_default/baseof.html`. As a def {{ end }} -{{< /code >}} +``` ## Override the base template The default list template will inherit all of the code defined above and can then implement its own `"main"` block from: -{{< code file=layouts/_default/list.html >}} +```go-html-template {file="layouts/_default/list.html"} {{ define "main" }}{{ . }}
{{ end }} -{{< /code >}} +``` In the example above, the context changes as we `range` through the [slice](g) of values. In the first iteration the context is "foo", and in the second iteration the context is "bar". Inside of the `with` block the context is "baz". Hugo renders the above to: @@ -85,11 +85,11 @@ In the example above, the context changes as we `range` through the [slice](g) o Within a `range` or `with` block you can access the context passed into the template by prepending a dollar sign (`$`) to the dot: -{{< code file=layouts/_default/single.html >}} +```go-html-template {file="layouts/_default/single.html"} {{ with "foo" }}{{ $.Title }} - {{ . }}
{{ end }} -{{< /code >}} +``` Hugo renders this to: @@ -107,12 +107,12 @@ In the examples above the paired opening and closing braces represent the beginn A template action may contain literal values ([boolean](g), [string](g), [integer](g), and [float](g)), variables, functions, and methods. -{{< code file=layouts/_default/single.html >}} +```go-html-template {file="layouts/_default/single.html"} {{ $convertToLower := true }} {{ if $convertToLower }}Affiliation: {{ .Params.affiliation }}
@@ -102,6 +102,6 @@ Then create a term template specific to the "authors" taxonomy:Copyright {{ now.Year }}. All rights reserved.
-{{< /code >}} +``` Learn more about [partial templates](/templates/partial/). @@ -197,7 +197,7 @@ A content view template is similar to a partial template, invoked by calling the For example, the home template below inherits the site's shell from the base template, and renders a card component for each page within the "articles" section of your site. -{{< code file=layouts/_default/home.html >}} +```go-html-template {file="layouts/_default/home.html"} {{ define "main" }} {{ .Content }}{{ $inner }}
-
- {{ end }}
- {{ end }}
-