diff --git a/_vendor/github.com/gohugoio/gohugoioTheme/assets/images/sponsors/your-company-dark.svg b/_vendor/github.com/gohugoio/gohugoioTheme/assets/images/sponsors/your-company-dark.svg index 1793cb644..58fd601f5 100644 --- a/_vendor/github.com/gohugoio/gohugoioTheme/assets/images/sponsors/your-company-dark.svg +++ b/_vendor/github.com/gohugoio/gohugoioTheme/assets/images/sponsors/your-company-dark.svg @@ -1,4 +1,4 @@ - + diff --git a/_vendor/github.com/gohugoio/gohugoioTheme/assets/images/sponsors/your-company.svg b/_vendor/github.com/gohugoio/gohugoioTheme/assets/images/sponsors/your-company.svg index 6f3082b54..3b85ece5c 100644 --- a/_vendor/github.com/gohugoio/gohugoioTheme/assets/images/sponsors/your-company.svg +++ b/_vendor/github.com/gohugoio/gohugoioTheme/assets/images/sponsors/your-company.svg @@ -1,4 +1,4 @@ - + diff --git a/_vendor/github.com/gohugoio/gohugoioTheme/data/sponsors.toml b/_vendor/github.com/gohugoio/gohugoioTheme/data/sponsors.toml index c31178c92..71167bfd4 100644 --- a/_vendor/github.com/gohugoio/gohugoioTheme/data/sponsors.toml +++ b/_vendor/github.com/gohugoio/gohugoioTheme/data/sponsors.toml @@ -5,20 +5,17 @@ utm_campaign = "hugosponsor" [[banners]] - name = "ButterCMS" - link = "https://buttercms.com/hugo-cms/" - logo = "images/sponsors/butter-light.svg" - utm_campaign = "sponsorship" - bgcolor = "#131A3E" + name = "Your Company?" + link = "https://bep.is/en/hugo-sponsor-2023-01/" + logo = "/images/sponsors/your-company.svg" + utm_campaign = "hugosponsor" + show_on_hover = true + bgcolor = "#004887" [[banners]] - name = "Gravity Kit" - link = "https://www.gravitykit.com/" - logo = "images/sponsors/graitykit-dark.svg" - query_params = "ref=532&campaign=hugo&" - utm_campaign = "hugosponsor" - bgcolor = "#e0ecf3" - - #hugohome - #hugofooter - #hugogithub + name = "Your Company?" + link = "https://bep.is/en/hugo-sponsor-2023-01/" + logo = "/images/sponsors/your-company.svg" + utm_campaign = "hugosponsor" + show_on_hover = true + bgcolor = "#004887" diff --git a/_vendor/github.com/gohugoio/gohugoioTheme/layouts/partials/home-page-sections/sponsors.html b/_vendor/github.com/gohugoio/gohugoioTheme/layouts/partials/home-page-sections/sponsors.html index b2915e109..32bc44f6a 100644 --- a/_vendor/github.com/gohugoio/gohugoioTheme/layouts/partials/home-page-sections/sponsors.html +++ b/_vendor/github.com/gohugoio/gohugoioTheme/layouts/partials/home-page-sections/sponsors.html @@ -5,6 +5,14 @@ {{ $isFooter := (eq $gtag "footer") }} {{ $utmSource := cond $isFooter "hugofooter" "hugohome" }} {{ with .cx.Site.Data.sponsors }} +
@@ -22,11 +30,18 @@ + class="w-100 grow pa3{{ if .show_on_hover }} + show-on-hover + {{ end }}" + style=""> {{ $logo.Content | safeHTML }} {{ else }} - + {{ $logo.Content | safeHTML }} {{ end }} diff --git a/_vendor/modules.txt b/_vendor/modules.txt index 9e5b08998..5c4b53271 100644 --- a/_vendor/modules.txt +++ b/_vendor/modules.txt @@ -1 +1 @@ -# github.com/gohugoio/gohugoioTheme v0.0.0-20230124135550-462d5fe4a87f +# github.com/gohugoio/gohugoioTheme v0.0.0-20230418063032-99f9185b8e11 diff --git a/archetypes/functions.md b/archetypes/functions.md index c2bb3113e..891458daa 100644 --- a/archetypes/functions.md +++ b/archetypes/functions.md @@ -1,12 +1,11 @@ --- -linktitle: "" +title: {{ replace .Name "-" " " | title }} description: "" -categories: [functions] -tags: [] -ns: "" signature: [] -hugoversion: "" -aliases: [] +categories: [functions] +keywords: [] +menu: + docs: + parent: functions relatedfuncs: [] -toc: false --- diff --git a/content/en/about/_index.md b/content/en/about/_index.md index 8ed441b61..91260a4a6 100644 --- a/content/en/about/_index.md +++ b/content/en/about/_index.md @@ -2,19 +2,14 @@ title: About Hugo linktitle: Overview description: Hugo's features, roadmap, license, and motivation. -date: 2017-02-01 -publishdate: 2017-02-01 -lastmod: 2017-02-01 categories: [] keywords: [] menu: docs: - parent: "about" + parent: about weight: 1 weight: 1 -draft: false aliases: [/about-hugo/,/docs/] -toc: false --- Hugo is not your average static site generator. diff --git a/content/en/about/benefits.md b/content/en/about/benefits.md index 925da1732..91c243413 100644 --- a/content/en/about/benefits.md +++ b/content/en/about/benefits.md @@ -2,19 +2,12 @@ title: The Benefits of Static Site Generators linktitle: The Benefits of Static description: Improved performance, security and ease of use are just a few of the reasons static site generators are so appealing. -date: 2017-02-01 -publishdate: 2017-02-01 -lastmod: 2017-02-01 keywords: [ssg,static,performance,security] menu: docs: - parent: "about" + parent: about weight: 30 weight: 30 -sections_weight: 30 -draft: false -aliases: [] -toc: false --- The purpose of website generators is to render content into HTML files. Most are "dynamic site generators." That means the HTTP server---i.e., the program that sends files to the browser to be viewed---runs the generator to create a new HTML file every time an end user requests a page. diff --git a/content/en/about/features.md b/content/en/about/features.md index fc3d5a030..6fac68cdd 100644 --- a/content/en/about/features.md +++ b/content/en/about/features.md @@ -1,17 +1,11 @@ --- title: Hugo Features -linktitle: Hugo Features description: Hugo boasts blistering speed, robust content management, and a powerful templating language making it a great fit for all kinds of static websites. -date: 2017-02-01 -publishdate: 2017-02-01 -lastmod: 2017-02-01 menu: docs: - parent: "about" + parent: about weight: 20 weight: 20 -sections_weight: 20 -draft: false toc: true --- diff --git a/content/en/about/hugo-and-gdpr.md b/content/en/about/hugo-and-gdpr.md index 2d4fba872..3e0a160c7 100644 --- a/content/en/about/hugo-and-gdpr.md +++ b/content/en/about/hugo-and-gdpr.md @@ -2,16 +2,13 @@ title: Hugo and the General Data Protection Regulation (GDPR) linktitle: Hugo and GDPR description: About how to configure your Hugo site to meet the new regulations. -date: 2018-05-25 layout: single keywords: ["GDPR", "Privacy", "Data Protection"] menu: docs: - parent: "about" + parent: about weight: 5 weight: 5 -sections_weight: 5 -draft: false aliases: [/privacy/,/gdpr/] toc: true --- @@ -57,7 +54,6 @@ disable = false privacyEnhanced = false {{< /code-toggle >}} - ## Disable All Services An example Privacy Config that disables all the relevant services in Hugo. With this configuration, the other settings will not matter. @@ -91,9 +87,9 @@ respectDoNotTrack useSessionStorage : Enabling this will disable the use of Cookies and use Session Storage to Store the GA Client ID. -{{% warning %}} +{{% note %}} `useSessionStorage` is not supported when using Google Analytics v4 (gtag.js). -{{% /warning %}} +{{% /note %}} ### Instagram diff --git a/content/en/about/license.md b/content/en/about/license.md index ae74b6047..267ec95a0 100644 --- a/content/en/about/license.md +++ b/content/en/about/license.md @@ -2,24 +2,20 @@ title: Apache License linktitle: License description: Hugo v0.15 and later are released under the Apache 2.0 license. -date: 2016-02-01 -publishdate: 2016-02-01 -lastmod: 2016-03-02 categories: ["about hugo"] keywords: ["License","apache"] menu: docs: - parent: "about" + parent: about weight: 60 weight: 60 -sections_weight: 60 aliases: [/meta/license] toc: true --- {{% note %}} Hugo v0.15 and later are released under the Apache 2.0 license. -Earlier versions of Hugo were released under the [Simple Public License](https://opensource.org/licenses/Simple-2.0). +Earlier versions of Hugo were released under the [Simple Public License](https://opensource.org/license/simpl-2-0-html/). {{% /note %}} _Version 2.0, January 2004_
@@ -148,7 +144,7 @@ _END OF TERMS AND CONDITIONS_ To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets `[]` replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same “printed page” as the copyright notice for easier identification within third-party archives. -{{< code file="apache-notice.txt" download="apache-notice.txt" >}} +{{< code file="apache-notice.txt" >}} Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/content/en/about/security-model/index.md b/content/en/about/security-model/index.md index d4dacd9bf..a909a4236 100644 --- a/content/en/about/security-model/index.md +++ b/content/en/about/security-model/index.md @@ -1,15 +1,13 @@ --- title: Hugo's Security Model description: A summary of Hugo's security model. -date: 2019-10-01 layout: single keywords: ["Security", "Privacy"] menu: docs: - parent: "about" + parent: about weight: 4 weight: 5 -sections_weight: 5 aliases: [/security/] toc: true --- diff --git a/content/en/about/what-is-hugo.md b/content/en/about/what-is-hugo.md index d61f821cd..3097de50e 100644 --- a/content/en/about/what-is-hugo.md +++ b/content/en/about/what-is-hugo.md @@ -1,18 +1,12 @@ --- title: What is Hugo -linktitle: What is Hugo description: Hugo is a fast and modern static site generator written in Go, and designed to make website creation fun again. -date: 2017-02-01 -publishdate: 2017-02-01 -lastmod: 2017-02-01 layout: single menu: docs: - parent: "about" + parent: about weight: 10 weight: 10 -sections_weight: 10 -draft: false aliases: [/overview/introduction/,/about/why-i-built-hugo/] toc: true --- diff --git a/content/en/commands/hugo_deploy.md b/content/en/commands/hugo_deploy.md index 4e1d468b7..7b14c30ef 100644 --- a/content/en/commands/hugo_deploy.md +++ b/content/en/commands/hugo_deploy.md @@ -31,6 +31,7 @@ hugo deploy [flags] --ignoreVendorPaths string ignores any _vendor for module paths matching the given Glob pattern --invalidateCDN invalidate the CDN cache listed in the deployment target (default true) --maxDeletes int maximum # of files to delete, or -1 to disable (default 256) + --workers int number of workers to transfer files. (default 10) -s, --source string filesystem path to read files relative from --target string target deployment from deployments section in config file; defaults to the first one --themesDir string filesystem path to themes directory diff --git a/content/en/content-management/_index.md b/content/en/content-management/_index.md index 7cb6357c6..e87749d3a 100644 --- a/content/en/content-management/_index.md +++ b/content/en/content-management/_index.md @@ -8,7 +8,6 @@ menu: weight: 10 keywords: [source, organization] categories: [content management] -toc: false weight: 10 aliases: [/content/,/content/organization] --- diff --git a/content/en/content-management/archetypes.md b/content/en/content-management/archetypes.md index 1d2ba3179..f2bc6a441 100644 --- a/content/en/content-management/archetypes.md +++ b/content/en/content-management/archetypes.md @@ -1,6 +1,5 @@ --- title: Archetypes -linkTitle: Archetypes description: Archetypes are templates used when creating new content. keywords: [archetypes,generators,metadata,front matter] categories: [content management] diff --git a/content/en/content-management/build-options.md b/content/en/content-management/build-options.md index f798754f1..4798f9b2b 100644 --- a/content/en/content-management/build-options.md +++ b/content/en/content-management/build-options.md @@ -56,43 +56,39 @@ If true, the page will be treated as part of the project's collections and, when #### publishResources -If set to true the [Bundle's Resources]({{< relref "content-management/page-bundles" >}}) will be published. +If set to true the [Bundle's Resources](/content-management/page-bundles) will be published. Setting this to false will still publish Resources on demand (when a resource's `.Permalink` or `.RelPermalink` is invoked from the templates) but will skip the others. {{% note %}} -Any page, regardless of their build options, will always be available using the [`.GetPage`]({{< relref "functions/GetPage" >}}) methods. +Any page, regardless of their build options, will always be available using the [`.GetPage`](/functions/getpage) methods. {{% /note %}} ------- - ### Illustrative use cases #### Not publishing a page Project needs a "Who We Are" content file for Front Matter and body to be used by the homepage but nowhere else. -```yaml -# content/who-we-are.md` +{{< code-toggle file="content/who-we-are.md" fm=true copy=false >}} title: Who we are _build: list: false render: false -``` +{{< /code-toggle >}} -```go-html-template -{{/* layouts/index.html */}} +{{< code file="layouts/index.html" copy=false >}}
-{{ with site.GetPage "who-we-are" }} - {{ .Content }} -{{ end }} + {{ with site.GetPage "who-we-are" }} + {{ .Content }} + {{ end }}
-``` +{{< /code >}} #### Listing pages without publishing them Website needs to showcase a few of the hundred "testimonials" available as content files without publishing any of them. -To avoid setting the build options on every testimonials, one can use [`cascade`]({{< relref "/content-management/front-matter#front-matter-cascade" >}}) on the testimonial section's content file. +To avoid setting the build options on every testimonials, one can use [`cascade`](/content-management/front-matter#front-matter-cascade) on the testimonial section's content file. {{< code-toggle >}} title: Testimonials @@ -104,12 +100,12 @@ cascade: list: true # default {{< /code-toggle >}} -```go-html-template -{{/* layouts/_defaults/testimonials.html */}} +{{< code file="layouts/_defaults/testimonials.html" copy=false >}}
-{{ range first 5 .Pages }} -
- {{ .Content }} -
-{{ end }} + {{ range first 5 .Pages }} +
+ {{ .Content }} +
+ {{ end }}
+{{< /code >}} diff --git a/content/en/content-management/comments.md b/content/en/content-management/comments.md index e49711e7c..0543f47a7 100644 --- a/content/en/content-management/comments.md +++ b/content/en/content-management/comments.md @@ -1,6 +1,5 @@ --- title: Comments -linkTitle: Comments description: Hugo ships with an internal Disqus template, but this isn't the only commenting system that will work with your new Hugo website. keywords: [sections,content,organization] categories: [project organization, fundamentals] @@ -25,7 +24,7 @@ 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 copy="false" >}} +{{< code-toggle copy=false >}} disqusShortname = "yourDisqusShortname" {{}} diff --git a/content/en/content-management/diagrams.md b/content/en/content-management/diagrams.md index c95548249..e664dd501 100644 --- a/content/en/content-management/diagrams.md +++ b/content/en/content-management/diagrams.md @@ -1,6 +1,5 @@ --- title: Diagrams -LinkTitle: Diagrams description: Use fenced code blocks and markdown render hooks to display diagrams. categories: [content management] keywords: [diagrams,drawing] @@ -58,8 +57,8 @@ And then include this snippet at the bottom of the content template (**Note**: b ```go-html-template {{ if .Page.Store.Get "hasMermaid" }} - - {{ end }} @@ -67,6 +66,7 @@ And then include this snippet at the bottom of the content template (**Note**: b With that you can use the `mermaid` language in Markdown code blocks: +```` ```mermaid sequenceDiagram participant Alice @@ -80,6 +80,7 @@ sequenceDiagram John->>Bob: How about you? Bob-->>John: Jolly good! ``` +```` ## Goat Ascii Diagram Examples diff --git a/content/en/content-management/formats.md b/content/en/content-management/formats.md index a98898821..ba988c29b 100644 --- a/content/en/content-management/formats.md +++ b/content/en/content-management/formats.md @@ -46,9 +46,9 @@ Hugo passes reasonable default arguments to these external helpers by default: - `rst2html`: `--leave-comments --initial-header-level=2` - `pandoc`: `--mathjax` -{{% warning "Performance of External Helpers" %}} +{{% note %}} Because additional formats are external commands, generation performance will rely heavily on the performance of the external tool you are using. As this feature is still in its infancy, feedback is welcome. -{{% /warning %}} +{{% /note %}} ### External Helper AsciiDoc diff --git a/content/en/content-management/front-matter.md b/content/en/content-management/front-matter.md index bf530518f..78d3323dd 100644 --- a/content/en/content-management/front-matter.md +++ b/content/en/content-management/front-matter.md @@ -1,8 +1,6 @@ --- title: Front Matter -linkTitle: Front Matter description: Hugo allows you to add front matter in yaml, toml, or json to your content files. -lastmod: 2017-02-24 categories: [content management] keywords: ["front matter", "yaml", "toml", "json", "metadata", "archetypes"] menu: @@ -56,87 +54,87 @@ slug = "spf13-vim-3-0-release-and-new-website" There are a few predefined variables that Hugo is aware of. See [Page Variables][pagevars] for how to call many of these predefined variables in your templates. aliases -: an array of one or more aliases (e.g., old published paths of renamed content) that will be created in the output directory structure . See [Aliases][aliases] for details. +: An array of one or more aliases (e.g., old published paths of renamed content) that will be created in the output directory structure . See [Aliases][aliases] for details. audio -: an array of paths to audio files related to the page; used by the `opengraph` [internal template](/templates/internal) to populate `og:audio`. +: An array of paths to audio files related to the page; used by the `opengraph` [internal template](/templates/internal) to populate `og:audio`. cascade -: a map of Front Matter keys whose values are passed down to the page's descendants unless overwritten by self or a closer ancestor's cascade. See [Front Matter Cascade](#front-matter-cascade) for details. +: A map of front matter keys whose values are passed down to the page's descendants unless overwritten by self or a closer ancestor's cascade. See [Front Matter Cascade](#front-matter-cascade) for details. date -: the datetime assigned to this page. This is usually fetched from the `date` field in front matter, but this behavior is configurable. +: The datetime assigned to this page. This is usually fetched from the `date` field in front matter, but this behavior is configurable. description -: the description for the content. +: The description for the content. draft -: if `true`, the content will not be rendered unless the `--buildDrafts` flag is passed to the `hugo` command. +: If `true`, the content will not be rendered unless the `--buildDrafts` flag is passed to the `hugo` command. expiryDate -: the datetime at which the content should no longer be published by Hugo; expired content will not be rendered unless the `--buildExpired` flag is passed to the `hugo` command. +: The datetime at which the content should no longer be published by Hugo; expired content will not be rendered unless the `--buildExpired` flag is passed to the `hugo` command. headless -: if `true`, sets a leaf bundle to be [headless][headless-bundle]. +: If `true`, sets a leaf bundle to be [headless][headless-bundle]. images -: an array of paths to images related to the page; used by [internal templates](/templates/internal) such as `_internal/twitter_cards.html`. +: An array of paths to images related to the page; used by [internal templates](/templates/internal) such as `_internal/twitter_cards.html`. isCJKLanguage -: if `true`, Hugo will explicitly treat the content as a CJK language; both `.Summary` and `.WordCount` work properly in CJK languages. +: If `true`, Hugo will explicitly treat the content as a CJK language; both `.Summary` and `.WordCount` work properly in CJK languages. keywords -: the meta keywords for the content. +: The meta keywords for the content. layout -: the layout Hugo should select from the [lookup order][lookup] when rendering the content. If a `type` is not specified in the front matter, Hugo will look for the layout of the same name in the layout directory that corresponds with a content's section. See [Content Types][content type]. +: The layout Hugo should select from the [lookup order][lookup] when rendering the content. If a `type` is not specified in the front matter, Hugo will look for the layout of the same name in the layout directory that corresponds with a content's section. See [Content Types][content type]. lastmod -: the datetime at which the content was last modified. +: The datetime at which the content was last modified. linkTitle -: used for creating links to content; if set, Hugo defaults to using the `linktitle` before the `title`. Hugo can also [order lists of content by `linktitle`][bylinktitle]. +: Used for creating links to content; if set, Hugo defaults to using the `linktitle` before the `title`. Hugo can also [order lists of content by `linktitle`][bylinktitle]. markup : **experimental**; specify `"rst"` for reStructuredText (requires`rst2html`) or `"md"` (default) for Markdown. outputs -: allows you to specify output formats specific to the content. See [output formats][outputs]. +: Allows you to specify output formats specific to the content. See [output formats][outputs]. publishDate -: if in the future, content will not be rendered unless the `--buildFuture` flag is passed to `hugo`. +: If in the future, content will not be rendered unless the `--buildFuture` flag is passed to `hugo`. resources -: used for configuring page bundle resources. See [Page Resources][page-resources]. +: Used for configuring page bundle resources. See [Page Resources][page-resources]. series -: an array of series this page belongs to, as a subset of the `series` [taxonomy](/content-management/taxonomies/); used by the `opengraph` [internal template](/templates/internal) to populate `og:see_also`. +: An array of series this page belongs to, as a subset of the `series` [taxonomy](/content-management/taxonomies/); used by the `opengraph` [internal template](/templates/internal) to populate `og:see_also`. slug -: appears as the tail of the output URL. A value specified in front matter will override the segment of the URL based on the filename. +: Overrides the last segment of the URL path. Not applicable to section pages. See [URL Management](/content-management/urls/#slug) for details. summary -: text used when providing a summary of the article in the `.Summary` page variable; details available in the [content-summaries](/content-management/summaries/) section. +: Text used when providing a summary of the article in the `.Summary` page variable; details available in the [content-summaries](/content-management/summaries/) section. title -: the title for the content. +: The title for the content. type -: the type of the content; this value will be automatically derived from the directory (i.e., the [section]) if not specified in front matter. +: The type of the content; this value will be automatically derived from the directory (i.e., the [section]) if not specified in front matter. url -: the full path to the content from the web root. It makes no assumptions about the path of the content file. See [URL Management](/content-management/urls/#set-url-in-front-matter). +: Overrides the entire URL path. Applicable to regular pages and section pages. See [URL Management](/content-management/urls/#url) for details. videos -: an array of paths to videos related to the page; used by the `opengraph` [internal template](/templates/internal) to populate `og:video`. +: An array of paths to videos related to the page; used by the `opengraph` [internal template](/templates/internal) to populate `og:video`. weight : used for [ordering your content in lists][ordering]. Lower weight gets higher precedence. So content with lower weight will come first. If set, weights should be non-zero, as 0 is interpreted as an *unset* weight. \ -: field name of the *plural* form of the index. See `tags` and `categories` in the above front matter examples. *Note that the plural form of user-defined taxonomies cannot be the same as any of the predefined front matter variables.* +: Field name of the *plural* form of the index. See `tags` and `categories` in the above front matter examples. *Note that the plural form of user-defined taxonomies cannot be the same as any of the predefined front matter variables.* -{{% note "Hugo's Default URL Destinations" %}} +{{% note %}} If neither `slug` nor `url` is present and [permalinks are not configured otherwise in your site `config` file](/content-management/urls/#permalinks), Hugo will use the filename of your content to create the output URL. See [Content Organization](/content-management/organization) for an explanation of paths in Hugo and [URL Management](/content-management/urls/) for ways to customize Hugo's default behaviors. {{% /note %}} @@ -146,7 +144,7 @@ You can add fields to your front matter arbitrarily to meet your needs. These us The following fields can be accessed via `.Params.include_toc` and `.Params.show_comments`, respectively. The [Variables] section provides more information on using Hugo's page- and site-level variables in your templates. -{{< code-toggle copy="false" >}} +{{< code-toggle copy=false >}} include_toc: true show_comments: false {{}} @@ -159,7 +157,7 @@ Any node or section can pass down to descendants a set of Front Matter values as The `cascade` block can be a slice with a optional `_target` keyword, allowing for multiple `cascade` values targeting different page sets. -{{< code-toggle copy="false" >}} +{{< code-toggle copy=false >}} title ="Blog" [[cascade]] background = "yosemite.jpg" @@ -193,7 +191,7 @@ Any of the above can be omitted. In `content/blog/_index.md` -{{< code-toggle copy="false" >}} +{{< code-toggle copy=false >}} title: Blog cascade: banner: images/typewriter.jpg diff --git a/content/en/content-management/image-processing/index.md b/content/en/content-management/image-processing/index.md index 3f71b4244..0043f97b0 100644 --- a/content/en/content-management/image-processing/index.md +++ b/content/en/content-management/image-processing/index.md @@ -1,6 +1,5 @@ --- title: Image Processing -linkTitle: Image Processing description: Resize, crop, rotate, filter, and convert images. categories: [content management] keywords: [resources, images] @@ -457,15 +456,15 @@ If you change image processing methods or options, or if you rename or remove im hugo --gc ``` -[`anchor`]: {{< relref "content-management/image-processing#anchor" >}} -[`lang.FormatNumber`]: {{< relref "functions/lang#langformatnumber" >}} -[Exif]: -[filters]: {{< relref "functions/images" >}} +[time.Format]: /functions/dateformat +[`anchor`]: /content-management/image-processing#anchor +[mounted]: /hugo-modules/configuration#module-config-mounts +[page bundle]: /content-management/page-bundles +[`lang.FormatNumber`]: /functions/lang +[filters]: /functions/images [github.com/disintegration/imaging]: -[mounted]: {{< relref "hugo-modules/configuration#module-config-mounts">}} -[page bundle]: {{< relref "content-management/page-bundles" >}} [Smartcrop]: -[time.Format]: {{< relref "functions/dateformat" >}} +[Exif]: [`Colors`]: #colors [`Crop`]: #crop [`Exif`]: #exif diff --git a/content/en/content-management/menus.md b/content/en/content-management/menus.md index b9fab2ca4..369938aba 100644 --- a/content/en/content-management/menus.md +++ b/content/en/content-management/menus.md @@ -1,7 +1,6 @@ --- title: Menus -linkTitle: Menus -description: Hugo has a simple yet powerful menu system. +description: Create menus by defining entries, localizing each entry, and rendering the resulting data structure. categories: [content management] keywords: [menus] menu: @@ -13,117 +12,214 @@ weight: 190 aliases: [/extras/menus/] --- -{{% note "Lazy Blogger"%}} -If all you want is a simple menu for your sections, see the ["Section Menu for Lazy Bloggers" in Menu Templates](/templates/menu-templates/#section-menu-for-lazy-bloggers). -{{% /note %}} +## Overview -You can do this: +To create a menu for your site: -* Place content in one or many menus -* Handle nested menus with unlimited depth -* Create menu entries without being attached to any content -* Distinguish active element (and active branch) +1. Define the menu entries +2. [Localize] each entry +3. Render the menu with a [template] -## What is a Menu in Hugo? +Create multiple menus, either flat or nested. For example, create a main menu for the header, and a separate menu for the footer. -A **menu** is a named array of menu entries accessible by name via the [`.Site.Menus` site variable][sitevars]. For example, you can access your site's `main` menu via `.Site.Menus.main`. +There are three ways to define menu entries: -{{% note "Menus on Multilingual Sites" %}} -If you make use of the [multilingual feature](/content-management/multilingual/), you can define language-independent menus. -{{% /note %}} - -See the [Menu Entry Properties][me-props] for all the variables and functions related to a menu entry. - -## Add content to menus - -Hugo allows you to add content to a menu via the content's [front matter](/content-management/front-matter/). - -### Simple - -If all you need to do is add an entry to a menu, the simple form works well. - -#### A Single Menu - -{{< code-toggle >}} -menu: "main" -{{< /code-toggle >}} - -#### Multiple Menus - -{{< code-toggle >}} -menu: ["main", "footer"] -{{< /code-toggle >}} - -#### Advanced - -{{< code-toggle >}} -menu: - docs: - parent: 'extras' - weight: 20 -{{< /code-toggle >}} - -## Add Non-content Entries to a Menu - -You can also add entries to menus that aren’t attached to a piece of content. This takes place in your Hugo project's [`config` file][config] (see [Menu Entry Properties][me-props] for full details of available variables). - -Here’s an example snippet pulled from a configuration file: - -{{< code-toggle file="config" >}} -[[menu.main]] - name = "about hugo" - pre = "" - weight = -110 - identifier = "about" - url = "/about/" -[[menu.main]] - name = "getting started" - pre = "" - post = "New!" - weight = -100 - url = "/getting-started/" -{{< /code-toggle >}} +1. Automatically +1. In front matter +1. In site configuration {{% note %}} -The URLs must be relative to the context root. If the `baseURL` is `https://example.com/mysite/`, then the URLs in the menu must not include the context root `mysite`. Using an absolute URL will override the baseURL. If the value used for `URL` in the above example is `https://subdomain.example.com/`, the output will be `https://subdomain.example.com`. +Although you can use these methods in combination when defining a menu, the menu will be easier to conceptualize and maintain if you use one method throughout the site. {{% /note %}} -## Nesting +## Define automatically -All nesting of content is done via the `parent` field. +To automatically define menu entries for each top-level section of your site, enable the section pages menu in your site configuration. -The parent of an entry should be the identifier of another entry. The identifier should be unique (within a menu). +{{< code-toggle file="config" copy=false >}} +sectionPagesMenu = "main" +{{< /code-toggle >}} -The following order is used to determine an Identifier: +This creates a menu structure that you can access with `site.Menus.main` in your templates. See [menu templates] for details. -`.Name > .LinkTitle > .Title` +## Define in front matter -This means that `.Title` will be used unless `.LinkTitle` is present, etc. In practice, `.Name` and `.Identifier` are only used to structure relationships and therefore never displayed. +To add a page to the "main" menu: -In this example, the top level of the menu is defined in your [site `config` file][config]. All content entries are attached to one of these entries via the `.Parent` field. +{{< code-toggle file="content/about.md" copy=false fm=true >}} +title = 'About' +menu = 'main' +{{< /code-toggle >}} -## Params +Access the entry with `site.Menus.main` in your templates. See [menu templates] for details. -You can also add user-defined content to menu items via the `params` field. +To add a page to the "main" and "footer" menus: -A common use case is to define a custom param to add a css class to a specific menu item. +{{< code-toggle file="content/contact.md" copy=false fm=true >}} +title = 'Contact' +menu = ['main','footer'] +{{< /code-toggle >}} -{{< code-toggle file="config" >}} +Access the entry with `site.Menus.main` and `site.Menus.footer` in your templates. See [menu templates] for details. + +### Properties {#properties-front-matter} + +Use these properties when defining menu entries in front matter: + +identifier +: (`string`) Required when two or more menu entries have the same `name`, or when localizing the `name` using translation tables. Must start with a letter, followed by letters, digits, or underscores. + +name +: (`string`) The text to display when rendering the menu entry. + +params +: (`map`) User-defined properties for the menu entry. + +parent +: (`string`) The `identifier` of the parent menu entry. If `identifier` is not defined, use `name`. Required for child entries in a nested menu. + +post +: (`string`) The HTML to append when rendering the menu entry. + +pre +: (`string`) The HTML to prepend when rendering the menu entry. + +title +: (`string`) The HTML `title` attribute of the rendered menu entry. + +weight +: (`int`) A non-zero integer indicating the entry's position relative the root of the menu, or to its parent for a child entry. Lighter entries float to the top, while heavier entries sink to the bottom. + +### Example {#example-front-matter} + +This front matter menu entry demonstrates some of the available properties: + +{{< code-toggle file="content/products/software.md" copy=false fm=true >}} +title = 'Software' +[menu.main] +parent = 'Products' +weight = 20 +pre = '' +[menu.main.params] +class = 'center' +{{< /code-toggle >}} + +Access the entry with `site.Menus.main` in your templates. See [menu templates] for details. + + +## Define in site configuration + +To define entries for the "main" menu: + +{{< code-toggle file="config" copy=false >}} [[menu.main]] - name = "about hugo" - pre = "" - weight = -110 - identifier = "about" - url = "/about/" - [menu.main.params] - class = "highlight-menu-item" -{{}} +name = 'Home' +pageRef = '/' +weight = 10 -## Render Menus +[[menu.main]] +name = 'Products' +pageRef = '/products' +weight = 20 -See [Menu Templates](/templates/menu-templates/) for information on how to render your site menus within your templates. +[[menu.main]] +name = 'Services' +pageRef = '/services' +weight = 30 +{{< /code-toggle >}} -[config]: /getting-started/configuration/ -[multilingual]: /content-management/multilingual/ -[sitevars]: /variables/ -[me-props]: /variables/menus/ +This creates a menu structure that you can access with `site.Menus.main` in your templates. See [menu templates] for details. + +To define entries for the "footer" menu: + +{{< code-toggle file="config" copy=false >}} +[[menu.footer]] +name = 'Terms' +pageRef = '/terms' +weight = 10 + +[[menu.footer]] +name = 'Privacy' +pageRef = '/privacy' +weight = 20 +{{< /code-toggle >}} + +This creates a menu structure that you can access with `site.Menus.footer` in your templates. See [menu templates] for details. + +### Properties {#properties-site-configuration} + +{{% note %}} +The [properties available to entries defined in front matter] are also available to entries defined in site configuration. + +[properties available to entries defined in front matter]: /content-management/menus/#properties-front-matter +{{% /note %}} + +Each menu entry defined in site configuration requires two or more properties: + +- Specify `name` and `pageRef` for internal links +- Specify `name` and `url` for external links + +pageRef +: (`string`) The file path of the target page, relative to the `content` directory. Omit language code and file extension. Required for *internal* links. + +Kind|pageRef +:--|:-- +home|`/` +page|`/books/book-1` +section|`/books` +taxonomy|`/tags` +term|`/tags/foo` + +url +: (`string`) Required for *external* links. + +### Example {#example-site-configuration} + +This nested menu demonstrates some of the available properties: + +{{< code-toggle file="config" copy=false >}} +[[menu.main]] +name = 'Products' +pageRef = '/products' +weight = 10 + +[[menu.main]] +name = 'Hardware' +pageRef = '/products/hardware' +parent = 'Products' +weight = 1 + +[[menu.main]] +name = 'Software' +pageRef = '/products/software' +parent = 'Products' +weight = 2 + +[[menu.main]] +name = 'Services' +pageRef = '/services' +weight = 20 + +[[menu.main]] +name = 'Hugo' +pre = '' +url = 'https://gohugo.io/' +weight = 30 +[menu.main.params] +rel = 'external' +{{< /code-toggle >}} + +This creates a menu structure that you can access with `site.Menus.main` in your templates. See [menu templates] for details. + +## Localize + +Hugo provides two methods to localize your menu entries. See [multilingual]. + +## Render + +See [menu templates]. + +[localize]: /content-management/multilingual/#menus +[menu templates]: /templates/menu-templates/ +[multilingual]: /content-management/multilingual/#menus +[template]: /templates/menu-templates/ diff --git a/content/en/content-management/multilingual.md b/content/en/content-management/multilingual.md index 5eb5506d9..f1f25086a 100644 --- a/content/en/content-management/multilingual.md +++ b/content/en/content-management/multilingual.md @@ -15,7 +15,7 @@ aliases: [/content/multilingual/,/tutorials/create-a-multilingual-site/] You should define the available languages in a `languages` section in your site configuration. -> Also See [Hugo Multilingual Part 1: Content translation] +Also See [Hugo Multilingual Part 1: Content translation]. ## Configure Languages @@ -69,6 +69,35 @@ Only the obvious non-global options can be overridden per language. Examples of **Please note:** use lowercase language codes, even when using regional languages (ie. use pt-pt instead of pt-PT). Currently Hugo language internals lowercase language codes, which can cause conflicts with settings like `defaultContentLanguage` which are not lowercased. Please track the evolution of this issue in [Hugo repository issue tracker](https://github.com/gohugoio/hugo/issues/7344) +### Changes in Hugo 0.112.0 + +{{< new-in "0.112.0" >}} + +In version `0.112.0` of Hugo we did a major we consolidated all configuration options, but also improved how the languages and their params gets merged with the main configuration. But while testing this on Hugo sites out there, we got some error reports. + +1. `site.Language.Params` is deprecated. Use `site.Params` directly. +1. The `params` sections on site and language is the only place to put custom user parameters, and `site.Params` will only contain these user defined parameters (see example below). + +```toml +title = "My blog" +languageCode = "en-us" + +[languages] +[languages.sv] +title = "Min blogg" +languageCode = "sv" +[languages.en.params] +color = "blue" +``` + +In the example above, all the settings exept the `color` below `params` maps to predefined configuration options in Hguo for the site and its language, and should be accessed via the documented accessors: + +``` +{{ site.Title }} +{{ site.LanguageCode }} +{{ site.Params.color }} +``` + ### Disable a Language You can disable one or more languages. This can be useful when working on a new translation. @@ -97,7 +126,9 @@ From **Hugo 0.31** we support multiple languages in a multihost configuration. S This means that you can now configure a `baseURL` per `language`: -> If a `baseURL` is set on the `language` level, then all languages must have one and they must all be different. +{{% note %}} +If a `baseURL` is set on the `language` level, then all languages must have one and they must all be different. +{{% /note %}} Example: @@ -155,9 +186,9 @@ Their language is __assigned__ according to the language code added as a __suffi By having the same **path and base filename**, the content pieces are __linked__ together as translated pages. -{{< note >}} +{{% note %}} If a file has no language code, it will be assigned the default language. -{{}} +{{% /note %}} ### Translation by content directory @@ -209,16 +240,22 @@ By setting the `translationKey` front matter param to `about` in all three pages Because paths and filenames are used to handle linking, all translated pages will share the same URL (apart from the language subdirectory). -To localize the URLs, the [`slug`]({{< ref "/content-management/organization/index.md#slug" >}}) or [`url`]({{< ref "/content-management/organization/index.md#url" >}}) front matter param can be set in any of the non-default language file. +To localize URLs: -For example, a French translation (`content/about.fr.md`) can have its own localized slug. +- For a regular page, set either [`slug`] or [`url`] in front matter +- For a section page, set [`url`] in front matter -{{< code-toggle >}} -Title: A Propos +[`slug`]: /content-management/urls/#slug +[`url`]: /content-management/urls/#url + +For example, a French translation can have its own localized slug. + +{{< code-toggle file="content/about.fr.md" fm=true copy=false >}} +title: A Propos slug: "a-propos" {{< /code-toggle >}} -At render, Hugo will build both `/about/` and `/fr/a-propos/` while maintaining their translation linking. +At render, Hugo will build both `/about/` and `/fr/a-propos/` without affecting the translation link. ### Page Bundles @@ -338,7 +375,7 @@ The function will read `.Count` from `.ReadingTime` and evaluate whether the num {{< code-toggle file="i18n/en-US" >}} [readingTime] one = "One minute to read" -other = "{{.Count}} minutes to read" +other = "{{ .Count }} minutes to read" {{< /code-toggle >}} Assuming `.ReadingTime.Count` in the context has value is 525600. The result will be: @@ -462,76 +499,91 @@ See [lang.FormatPercent] for details. ## Menus -You can define your menus for each language independently. Creating multilingual menus works just like [creating regular menus][menus], except they're defined in language-specific blocks in the configuration file: +Localization of menu entries depends on the how you define them: -{{< code-toggle file="config" >}} -defaultContentLanguage = "en" +- When you define menu entries [automatically] using the section pages menu, you must use translation tables to localize each entry. +- When you define menu entries [in front matter], they are already localized based on the front matter itself. If the front matter values are insufficient, use translation tables to localize each entry. +- When you define menu entries [in site configuration], you can (a) use translation tables, or (b) create language-specific menu entries under each language key. -[languages.en] -weight = 0 -languageName = "English" +### Use translation tables -[[languages.en.menu.main]] -url = "/" -name = "Home" -weight = 0 - -[languages.de] -weight = 10 -languageName = "Deutsch" - -[[languages.de.menu.main]] -url = "/" -name = "Startseite" -weight = 0 -{{< /code-toggle >}} - -The rendering of the main navigation works as usual. `.Site.Menus` will just contain the menu in the current language. Note that `absLangURL` below will link to the correct locale of your website. Without it, menu entries in all languages would link to the English version, since it's the default content language that resides in the root directory. +When rendering the text that appears in menu each entry, the [example menu template] does this: ```go-html-template -
    - {{- $currentPage := . -}} - {{ range .Site.Menus.main -}} -
  • - {{ .Name }} -
  • - {{- end }} -
+{{ or (T .Identifier) .Name | safeHTML }} ``` -### Dynamically localizing menus with i18n +It queries the translation table for the current language using the menu entry's `identifier` and returns the translated string. If the translation table does not exist, or if the `identifier` key is not present in the translation table, it falls back to `name`. -While customizing menus per language is useful, your config file can become hard to maintain if you have a lot of languages +The `identifier` depends on how you define menu entries: -If your menus are the same in all languages (ie. if the only thing that changes is the translated name) you can use the `.Identifier` as a translation key for the menu name: +- If you define the menu entry [automatically] using the section pages menu, the `identifier` is the page's `.Section`. +- If you define the menu entry [in site configuration] or [in front matter], set the `identifier` property to the desired value. -{{< code-toggle file="config" >}} +For example, if you define menu entries in site configuration: + +{{< code-toggle file="config" copy=false >}} [[menu.main]] -name = "About me" -url = "about" + identifier = 'products' + name = 'Products' + pageRef = '/products' + weight = 10 +[[menu.main]] + identifier = 'services' + name = 'Services' + pageRef = '/services' + weight = 20 +{{< / code-toggle >}} + +Create corresponding entries in the translation tables: + +{{< code-toggle file="i18n/de" copy=false >}} +products = 'Produkte' +services = 'Leistungen' +{{< / code-toggle >}} + +[example menu template]: /templates/menu-templates/#example +[automatically]: /content-management/menus/#define-automatically +[in front matter]: /content-management/menus/#define-in-front-matter +[in site configuration]: /content-management/menus/#define-in-site-configuration + +### Create language-specific menu entries + +For example: + +{{< code-toggle file="config" copy=false >}} +[languages.de] +languageCode = 'de-DE' +languageName = 'Deutsch' weight = 1 -identifier = "about" + +[[languages.de.menu.main]] +name = 'Produkte' +pageRef = '/products' +weight = 10 + +[[languages.de.menu.main]] +name = 'Leistungen' +pageRef = '/services' +weight = 20 + +[languages.en] +languageCode = 'en-US' +languageName = 'English' +weight = 2 + +[[languages.en.menu.main]] +name = 'Products' +pageRef = '/products' +weight = 10 + +[[languages.en.menu.main]] +name = 'Services' +pageRef = '/services' +weight = 20 {{< /code-toggle >}} -You now need to specify the translations for the menu keys in the i18n files: - -{{< code file="i18n/pt.toml" >}} -[about] -other="Sobre mim" -{{< /code >}} - -And do the appropriate changes in the menu code to use the `i18n` tag with the `.Identifier` as a key. You will also note that here we are using a `default` to fall back to `.Name`, in case the `.Identifier` key is also not present in the language specified in the `defaultContentLanguage` configuration. - -{{< code file="layouts/partials/menu.html" >}} - -{{< /code >}} +For a simple menu with two languages, these menu entries are easy to create and maintain. For a larger menu, or with more than two languages, using translation tables as described above is preferable. ## Missing Translations @@ -586,11 +638,11 @@ hugo new content/de/post/test.md [homepage]: /templates/homepage/ [Hugo Multilingual Part 1: Content translation]: https://regisphilibert.com/blog/2018/08/hugo-multilingual-part-1-managing-content-translation/ [i18func]: /functions/i18n/ -[lang.FormatAccounting]: /functions/lang/#langformataccounting -[lang.FormatCurrency]: /functions/lang/#langformatcurrency -[lang.FormatNumber]: /functions/lang/#langformatnumber -[lang.FormatNumberCustom]: /functions/lang/#langformatnumbercustom -[lang.FormatPercent]: /functions/lang/#langformatpercent +[lang.FormatAccounting]: /functions/lang +[lang.FormatCurrency]: /functions/lang +[lang.FormatNumber]: /functions/lang +[lang.FormatNumberCustom]: /functions/lang +[lang.FormatPercent]: /functions/lang [lang.Merge]: /functions/lang.merge/ [menus]: /content-management/menus/ [OS environment]: /getting-started/configuration/#configure-with-environment-variables diff --git a/content/en/content-management/organization/index.md b/content/en/content-management/organization/index.md index 94c0cfd5a..efa355ddc 100644 --- a/content/en/content-management/organization/index.md +++ b/content/en/content-management/organization/index.md @@ -17,7 +17,7 @@ aliases: [/content/sections/] Hugo `0.32` announced page-relative images and other resources packaged into `Page Bundles`. -These terms are connected, and you also need to read about [Page Resources]({{< relref "/content-management/page-resources" >}}) and [Image Processing]({{< relref "/content-management/image-processing" >}}) to get the full picture. +These terms are connected, and you also need to read about [Page Resources](/content-management/page-resources) and [Image Processing](/content-management/image-processing) to get the full picture. {{< imgproc 1-featured Resize "300x" >}} The illustration shows three bundles. Note that the home page bundle cannot contain other content pages, although other files (images etc.) are allowed. @@ -131,10 +131,7 @@ A default content type is determined by the section in which a content item is s ### `slug` -A content's `slug` is either `name.extension` or `name/`. The value for `slug` is determined by - -* the name of the content file (e.g., `lollapalooza.md`) OR -* front matter overrides +The `slug` is the last segment of the URL path, defined by the file name and optionally overridden by a `slug` value in front matter. See [URL Management](/content-management/urls/#slug) for details. ### `path` @@ -145,78 +142,7 @@ A content's `path` is determined by the section's path to the file. The file `pa ### `url` -The `url` is the relative URL for the piece of content. The `url` - -* is based on the content item's location within the directory structure OR -* is defined in front matter, in which case it *overrides all the above* - -## Override Destination Paths via Front Matter - -Hugo assumes that your content is organized with a purpose. The same structure that you use to organize your source content is used to organize the rendered site. As displayed above, the organization of the source content will be mirrored at the destination. - -There are times when you may need more fine-grained control over the content organization. In such cases, the front matter field can be used to determine the destination of a specific piece of content. - -The following items are defined in a specific order for a reason: items explained lower down in the list override higher items. Note that not all items can be defined in front matter. - -### `filename` - -`filename` is not a front matter field. It is the actual file name, minus the extension. This will be the name of the file in the destination (e.g., `content/posts/my-post.md` becomes `example.com/posts/my-post/`). - -### `slug` - -When defined in the front matter, the `slug` can take the place of the filename in the destination. - -{{< code file="content/posts/old-post.md" >}} ---- -title: A new post with the filename old-post.md -slug: "new-post" ---- -{{< /code >}} - -This will render to the following destination according to Hugo's default behavior: - -```txt -example.com/posts/new-post/ -``` - -### `section` - -`section` is determined by a content item's location on disk and *cannot* be specified in the front matter. See [sections] for more information. - -### `type` - -A content item's `type` is also determined by its location on disk but, unlike `section`, it *can* be specified in the front matter. See [types]. This can come in especially handy when you want a piece of content to render using a different layout. In the following example, you can create a layout at `layouts/new/mylayout.html` that Hugo will use to render this piece of content, even in the midst of many other posts. - -{{< code file="content/posts/my-post.md" >}} ---- -title: My Post -type: new -layout: mylayout ---- -{{< /code >}} - - - - - -### `url` - -A complete URL can be provided. This will override all the above as it pertains to the end destination. This must be the path from the baseURL (starting with a `/`). `url` will be used exactly as it is defined in the front matter, and will ignore the `--uglyURLs` setting in your site configuration: - -{{< code file="content/posts/old-url.md" >}} ---- -title: Old URL -url: /blog/new-url/ ---- -{{< /code >}} - -Assuming your `baseURL` is [configured][config] to `https://example.com`, the addition of `url` to the front matter will make `old-url.md` render to the following destination: - -```txt -https://example.com/blog/new-url/ -``` - -You can see more information on how to control output paths in [URL Management][urls]. +The `url` is the entire URL path, defined by the file path and optionally overridden by a `url` value in front matter. See [URL Management](/content-management/urls/#slug) for details. [config]: /getting-started/configuration/ [formats]: /content-management/formats/ @@ -225,7 +151,7 @@ You can see more information on how to control output paths in [URL Management][ [homepage template]: /templates/homepage/ [homepage]: /templates/homepage/ [lists]: /templates/lists/ -[pretty]: /content-management/urls/#pretty-urls +[pretty]: /content-management/urls/#appearance [section templates]: /templates/section-templates/ [sections]: /content-management/sections/ [singles]: /templates/single-page-templates/ diff --git a/content/en/content-management/page-bundles.md b/content/en/content-management/page-bundles.md index 28ab004c5..2a5147c21 100644 --- a/content/en/content-management/page-bundles.md +++ b/content/en/content-management/page-bundles.md @@ -1,14 +1,11 @@ --- title: Page Bundles -linkTitle: Page Bundles description: Content organization using Page Bundles -linkTitle: Page Bundles keywords: [page, bundle, leaf, branch] categories: [content management] menu : docs: - identifier: "page-bundles" - parent: "content-management" + parent: content-management weight: 30 toc: true weight: 30 @@ -132,9 +129,9 @@ Explanation of the above example: A leaf bundle can be made headless by adding below in the Front Matter (in the `index.md`): -```toml +{{< code-toggle file="content/headless/index.md" fm=true copy=false >}} headless = true -``` +{{< /code-toggle >}} There are many use cases of such headless page bundles: diff --git a/content/en/content-management/page-resources.md b/content/en/content-management/page-resources.md index 16c9fc0ab..4bbd159be 100644 --- a/content/en/content-management/page-resources.md +++ b/content/en/content-management/page-resources.md @@ -1,6 +1,5 @@ --- title: Page Resources -linkTitle: Page Resources description: Page resources -- images, other pages, documents, etc. -- have page-relative URLs and their own metadata. categories: [content management] keywords: [bundle,content,resources] @@ -11,8 +10,7 @@ menu: toc: true weight: 80 --- -Page resources are only accessible from [page bundles]({{< relref -"/content-management/page-bundles" >}}), those directories with `index.md` or +Page resources are only accessible from [page bundles](/content-management/page-bundles), those directories with `index.md` or `_index.md` files at their root. Page resources are only available to the page with which they are bundled. @@ -128,9 +126,9 @@ Resources of type `page` get `Title` etc. from their own front matter. name : Sets the value returned in `Name`. -{{% warning %}} +{{% note %}} The methods `Match`, `Get` and `GetMatch` use `Name` to match the resources. -{{%/ warning %}} +{{% /note %}} title : Sets the value returned in `Title` @@ -140,7 +138,7 @@ params ### Resources metadata example -{{< code-toggle copy="false">}} +{{< code-toggle copy=false >}} title: Application date : 2018-01-25 resources : @@ -174,9 +172,9 @@ From the example above: - All `PDF` files will get a new `Name`. The `name` parameter contains a special placeholder [`:counter`](#the-counter-placeholder-in-name-and-title), so the `Name` will be `pdf-file-1`, `pdf-file-2`, `pdf-file-3`. - Every docx in the bundle will receive the `word` icon. -{{% warning %}} +{{% note %}} The __order matters__ --- Only the **first set** values of the `title`, `name` and `params`-**keys** will be used. Consecutive parameters will be set only for the ones not already set. In the above example, `.Params.icon` is first set to `"photo"` in `src = "documents/photo_specs.pdf"`. So that would not get overridden to `"pdf"` by the later set `src = "**.pdf"` rule. -{{%/ warning %}} +{{% /note %}} ### The `:counter` placeholder in `name` and `title` @@ -186,7 +184,7 @@ The counter starts at 1 the first time they are used in either `name` or `title` For example, if a bundle has the resources `photo_specs.pdf`, `other_specs.pdf`, `guide.pdf` and `checklist.pdf`, and the front matter has specified the `resources` as: -{{< code-toggle copy="false">}} +{{< code-toggle copy=false >}} [[resources]] src = "*specs.pdf" title = "Specification #:counter" diff --git a/content/en/content-management/related.md b/content/en/content-management/related.md index 2d2077c81..823e3035c 100644 --- a/content/en/content-management/related.md +++ b/content/en/content-management/related.md @@ -1,6 +1,5 @@ --- title: Related Content -linkTitle: Related Content description: List related content in "See Also" sections. categories: [content management] keywords: [content] @@ -31,40 +30,81 @@ To list up to 5 related pages (which share the same _date_ or _keyword_ paramete {{ end }} {{< /code >}} -### Methods +The `Related` method takes one argument which may be a `Page` or a options map. The options map have these options: -Here is the list of "Related" methods available on a page collection such `.RegularPages`. +indices +: The indices to search in. -#### .Related PAGE +document +: The document to search for related content for. -Returns a collection of pages related the given one. +namedSlices +: The keywords to search for. + +fragments +: Fragments holds a a list of special keywords that is used for indices configured as type "fragments". This will match the fragment identifiers of the documents. + +A fictional example using all of the above options: ```go-html-template -{{ $related := site.RegularPages.Related . }} -``` - -#### .RelatedIndices PAGE INDICE1 [INDICE2 ...] - -Returns a collection of pages related to a given one restricted to a list of indices. - -```go-html-template -{{ $related := site.RegularPages.RelatedIndices . "tags" "date" }} -``` - -#### .RelatedTo KEYVALS [KEYVALS2 ...] - -Returns a collection of pages related together by a set of indices and their match. - -In order to build those set and pass them as argument, one must use the `keyVals` function where the first argument would be the `indice` and the consecutive ones its potential `matches`. - -```go-html-template -{{ $related := site.RegularPages.RelatedTo ( keyVals "tags" "hugo" "rocks") ( keyVals "date" .Date ) }} +{{ $page := . }} +{{ $opts := + "indices" (slice "tags" "keywords") + "document" $page + "namedSlices" (slice (keyVals "tags" "hugo" "rocks") (keyVals "date" $page.Date)) + "fragments" (slice "heading-1" "heading-2") +}} ``` {{% note %}} -Read [this blog article](https://regisphilibert.com/blog/2018/04/hugo-optmized-relashionships-with-related-content/) for a great explanation of more advanced usage of this feature. +We improved and simplified this feature in Hugo 0.111.0. Before this we had 3 different methods: `Related`, `RelatedTo` and `RelatedIndicies`. Now we have only one method: `Related`. The old methods are still available but deprecated. Also see [this blog article](https://regisphilibert.com/blog/2018/04/hugo-optmized-relashionships-with-related-content/) for a great explanation of more advanced usage of this feature. {{% /note %}} +## Index Content Headings in Related Content + +{{< new-in "0.111.0" >}} + +Hugo can index the headings in your content and use this to find related content. You can enable this by adding a index of type `fragments` to your `related` configuration: + +{{< code-toggle file="config" copy=false >}} +[related] +threshold = 20 +includeNewer = true +toLower = false +[[related.indices]] +name = "fragmentrefs" +type = "fragments" +applyFilter = false +weight = 80 +{{< /code-toggle >}} + +* The `name` maps to a optional front matter slice attribute that can be used to link from the page level down to the fragment/heading level. +* If `applyFilter`is enabled, the `.HeadingsFiltered` on each page in the result will reflect the filtered headings. This is useful if you want to show the headings in the related content listing: + +```go-html-template +{{ $related := .Site.RegularPages.Related . | first 5 }} +{{ with $related }} +

See Also

+
    + {{ range $i, $p := . }} +
  • + {{ .Title }} + {{ with .HeadingsFiltered }} +
      + {{ range . }} + {{ $link := printf "%s#%s" $p.RelPermalink .ID | safeURL }} +
    • + {{ .Title }} +
    • + {{ end }} +
    + {{ end }} +
  • + {{ end }} +
+{{ end }} +``` + ## Configure Related Content Hugo provides a sensible default configuration of Related Content, but you can fine-tune this in your configuration, on the global or language level if needed. @@ -109,9 +149,19 @@ toLower name : The index name. This value maps directly to a page param. Hugo supports string values (`author` in the example) and lists (`tags`, `keywords` etc.) and time and date objects. +type +: {{< new-in "0.111.0" >}}. One of `basic`(default) or `fragments`. + +applyFilter +: {{< new-in "0.111.0" >}}. Apply a `type` specific filter to the result of a search. This is currently only used for the `fragments` type. + weight : An integer weight that indicates _how important_ this parameter is relative to the other parameters. It can be 0, which has the effect of turning this index off, or even negative. Test with different values to see what fits your content best. + +cardinalityThreshold (default 0) +: {{< new-in "0.111.0" >}}. A percentage (0-100) used to remove common keywords from the index. As an example, setting this to 50 will remove all keywords that are used in more than 50% of the documents in the index. + pattern : This is currently only relevant for dates. When listing related content, we may want to list content that is also close in time. Setting "2006" (default value for date indexes) as the pattern for a date index will add weight to pages published in the same year. For busier blogs, "200601" (year and month) may be a better default. diff --git a/content/en/content-management/sections.md b/content/en/content-management/sections.md index b68a5bdb9..10c87e6cb 100644 --- a/content/en/content-management/sections.md +++ b/content/en/content-management/sections.md @@ -2,9 +2,6 @@ title: Content Sections linkTitle: Sections description: Hugo generates a **section tree** that matches your content. -date: 2017-02-01 -publishdate: 2017-02-01 -lastmod: 2017-02-01 categories: [content management] keywords: [lists,sections,content types,organization] menu: @@ -62,17 +59,19 @@ If you need a specific template for a sub-section, you need to adjust either the With the available [section variables and methods](#section-page-variables-and-methods) you can build powerful navigation. One common example would be a partial to show Breadcrumb navigation: -{{< code file="layouts/partials/breadcrumb.html" download="breadcrumb.html" >}} - +{{< code file="layouts/partials/breadcrumb.html" >}} + {{< /code >}} ## Section Page Variables and Methods diff --git a/content/en/content-management/shortcodes.md b/content/en/content-management/shortcodes.md index 634444684..f91adc227 100644 --- a/content/en/content-management/shortcodes.md +++ b/content/en/content-management/shortcodes.md @@ -1,6 +1,5 @@ --- title: Shortcodes -linkTitle: Shortcodes description: Shortcodes are simple snippets inside your content files calling built-in or custom templates. categories: [content management] keywords: [markdown,content,shortcodes] @@ -126,130 +125,129 @@ attrlink #### Example `figure` Input {{< code file="figure-input-example.md" >}} -{{}} +{{An elephant at sunset" */>}} {{< /code >}} #### Example `figure` Output -{{< output file="figure-output-example.html" >}} +```html
- -
-

Steve Francia

-
+ +
An elephant at sunset
-{{< /output >}} +``` ### `gist` -Bloggers often want to include GitHub gists when writing posts. Let's suppose we want to use the [gist at the following url][examplegist]: +To display a GitHub [gist] with this URL: -```txt -https://gist.github.com/spf13/7896402 +[gist]: https://docs.github.com/en/get-started/writing-on-github/editing-and-sharing-content-with-gists + +```text +https://gist.github.com/user/50a7482715eac222e230d1e64dd9a89b ``` -We can embed the gist in our content via username and gist ID pulled from the URL: +Include this in your markdown: -```go-html-template -{{}} +```text +{{}} ``` -#### Example `gist` Input +This will display all files in the gist alphabetically by file name. -If the gist contains several files and you want to quote just one of them, you can pass the filename (quoted) as an optional third argument: +{{< gist jmooring 50a7482715eac222e230d1e64dd9a89b >}} -{{< code file="gist-input.md" >}} -{{}} -{{< /code >}} +To display a specific file within the gist: -#### Example `gist` Output +```text +{{}} +``` -{{< output file="gist-output.html" >}} -{{< gist spf13 7896402 >}} -{{< /output >}} +Rendered: -#### Example `gist` Display - -To demonstrate the remarkable efficiency of Hugo's shortcode feature, we have embedded the `spf13` `gist` example in this page. The following simulates the experience for visitors to your website. Naturally, the final display will depend on your stylesheets and surrounding markup. - -{{< gist spf13 7896402 >}} +{{< gist jmooring 50a7482715eac222e230d1e64dd9a89b 1-template.html >}} ### `highlight` -This shortcode will convert the source code provided into syntax-highlighted HTML. Read more on [highlighting](/content-management/syntax-highlighting/). `highlight` takes exactly one required `language` parameter and requires a closing shortcode. +To display a highlighted code sample: -#### Example `highlight` Input - -{{< code file="content/tutorials/learn-html.md" >}} -{{}} -
-
-

{{ .Title }}

- {{ range .Pages }} - {{ .Render "summary"}} - {{ end }} -
-
+```text +{{}} +{{ range .Pages }} +

{{ .LinkTitle }}

+{{ end }} {{}} -{{< /code >}} +``` -#### Example `highlight` Output +Rendered: -The `highlight` shortcode example above would produce the following HTML when the site is rendered: +{{< highlight go-html-template >}} +{{ range .Pages }} +

{{ .LinkTitle }}

+{{ end }} +{{< /highlight >}} -{{< output file="tutorials/learn-html/index.html" >}} -<section id="main"> - <div> - <h1 id="title">{{ .Title }}</h1> - {{ range .Pages }} - {{ .Render "summary"}} - {{ end }} - </div> -</section> -{{< /output >}} +To specify one or more [highlighting options], include a quotation-encapsulated, comma-separated list: -{{% note "More on Syntax Highlighting" %}} -To see even more options for adding syntax-highlighted code blocks to your website, see [Syntax Highlighting in Developer Tools](/tools/syntax-highlighting/). -{{% /note %}} +[highlighting options]: /functions/highlight/ + +```text +{{}} +{{ range .Pages }} +

{{ .LinkTitle }}

+{{ end }} +{{}} +``` + +Rendered: + +{{< highlight go-html-template "lineNos=inline, lineNoStart=42" >}} +{{ range .Pages }} +

{{ .LinkTitle }}

+{{ end }} +{{< /highlight >}} ### `instagram` -If you'd like to embed a photo from [Instagram], you only need the photo's ID. You can discern an Instagram photo ID from the URL: +The `instagram` shortcode uses Facebook's **oEmbed Read** feature. The Facebook [developer documentation] states: -```txt +- This permission or feature requires successful completion of the App Review process before your app can access live data. [Learn More] +- This permission or feature is only available with business verification. You may also need to sign additional contracts before your app can access data. [Learn More Here] + +[developer documentation]: https://developers.facebook.com/docs/features-reference/oembed-read +[Learn More]: https://developers.facebook.com/docs/app-review +[Learn More Here]: https://developers.facebook.com/docs/development/release/business-verification + +You must obtain an Access Token to use the `instagram` shortcode. + +If your site configuration is private: + +{{< code-toggle file=config copy=false >}} +[services.instagram] +accessToken = 'xxx' +{{< /code-toggle >}} + +If your site configuration is _not_ private, set the Access Token with an environment variable: + +```text +HUGO_SERVICES_INSTAGRAM_ACCESSTOKEN=xxx hugo --gc --minify +``` + +{{% note %}} +If you are using a Client Access Token, you must combine the Access Token with your App ID using a pipe symbol (`APPID|ACCESSTOKEN`). +{{% /note %}} + +To display an Instagram post with this URL: + +```text https://www.instagram.com/p/BWNjjyYFxVx/ ``` -#### Example `instagram` Input +Include this in your markdown: -{{< code file="instagram-input.md" >}} +```text {{}} -{{< /code >}} - -You also have the option to hide the caption: - -{{< code file="instagram-input-hide-caption.md" >}} -{{}} -{{< /code >}} - -#### Example `instagram` Output - -By adding the preceding `hidecaption` example, the following HTML will be added to your rendered website's markup: - -{{< output file="instagram-hide-caption-output.html" >}} -{{< instagram BWNjjyYFxVx hidecaption >}} -{{< /output >}} - -#### Example `instagram` Display - -Using the preceding `instagram` with `hidecaption` example above, the following simulates the displayed experience for visitors to your website. Naturally, the final display will be contingent on your style sheets and surrounding markup. - -{{< instagram BWNjjyYFxVx hidecaption >}} - - -{{% note %}} -The `instagram`-shortcode refers an endpoint of Instagram's API, that's deprecated since October 24th, 2020. Thus, no images can be fetched from this API endpoint, resulting in an error when the `instagram`-shortcode is used. For more information please have a look at GitHub issue [#7879](https://github.com/gohugoio/hugo/issues/7879). -{{% /note %}} +``` ### `param` @@ -275,7 +273,7 @@ These shortcodes will look up the pages by their relative path (e.g., `blog/post `ref` and `relref` also make it possible to make fragmentary links that work for the header links generated by Hugo. -{{% note "More on Cross References" %}} +{{% note %}} Read a more extensive description of `ref` and `relref` in the [cross references](/content-management/cross-references/) documentation. {{% /note %}} @@ -299,71 +297,47 @@ Assuming that standard Hugo pretty URLs are turned on. ### `tweet` -You want to include a single tweet into your blog post? Everything you need is the URL of the tweet: +To display a Twitter post with this URL: ```txt https://twitter.com/SanDiegoZoo/status/1453110110599868418 ``` -#### Example `tweet` Input +Include this in your markdown: -Pass the tweet's user (case-insensitive) and ID from the URL as parameters to the `tweet` shortcode. - -{{< code file="example-tweet-input.md" >}} +```text {{}} -{{< /code >}} +``` -#### Example `tweet` Output - -Using the preceding `tweet` example, the following HTML will be added to your rendered website's markup: - -{{< output file="example-tweet-output.html" >}} -{{< tweet user="SanDiegoZoo" id="1453110110599868418" >}} -{{< /output >}} - -#### Example `tweet` Display - -Using the preceding `tweet` example, the following simulates the displayed experience for visitors to your website. Naturally, the final display will be contingent on your stylesheets and surrounding markup. +Rendered: {{< tweet user="SanDiegoZoo" id="1453110110599868418" >}} ### `vimeo` -Adding a video from [Vimeo] is equivalent to the [YouTube Input shortcode]. +To display a Vimeo video with this URL: -```txt -https://vimeo.com/channels/staffpicks/146022717 +```text +https://vimeo.com/channels/staffpicks/55073825 ``` -#### Example `vimeo` Input +Include this in your markdown: -Extract the ID from the video's URL and pass it to the `vimeo` shortcode: +```text +{{}} +``` -{{< code file="example-vimeo-input.md" >}} -{{}} -{{< /code >}} +Rendered: -#### Example `vimeo` Output +{{< vimeo 55073825 >}} -Using the preceding `vimeo` example, the following HTML will be added to your rendered website's markup: - -{{< output file="example-vimeo-output.html" >}} -{{< vimeo 146022717 >}} -{{< /output >}} - -{{% tip %}} +{{% note %}} If you want to further customize the visual styling of the YouTube or Vimeo output, add a `class` named parameter when calling the shortcode. The new `class` will be added to the `
` that wraps the `
@@ -297,7 +291,7 @@ The template for the `highlight` shortcode uses the following code, which is alr The rendered output of the HTML example code block will be as follows: -{{< code file="syntax-highlighted.html" copy="false" >}} +{{< code file="syntax-highlighted.html" copy=false >}}
<html>
     <body> This HTML </body>
 </html>
@@ -321,9 +315,9 @@ You also have an `img` shortcode with a single named `src` parameter that you wa
 {{< code file="layouts/shortcodes/img.html" >}}
 {{- $src := .Get "src" -}}
 {{- with .Parent -}}
-  
+  
 {{- else -}}
-  
+  
 {{- end -}}
 {{< /code >}}
 
diff --git a/content/en/templates/single-page-templates.md b/content/en/templates/single-page-templates.md
index 925f97b03..559f2fb17 100644
--- a/content/en/templates/single-page-templates.md
+++ b/content/en/templates/single-page-templates.md
@@ -1,19 +1,13 @@
 ---
 title: Single Page Templates
-linktitle:
 description: The primary view of content in Hugo is the single view. Hugo will render every Markdown file provided with a corresponding single template.
-date: 2017-02-01
-publishdate: 2017-02-01
-lastmod: 2017-04-06
 categories: [templates]
 keywords: [page, templates]
 menu:
   docs:
-    parent: "templates"
+    parent: templates
     weight: 60
 weight: 60
-sections_weight: 60
-draft: false
 aliases: [/layout/content/]
 toc: true
 ---
@@ -30,46 +24,46 @@ Content pages are of the type `page` and will therefore have all the [page varia
 
 This single page template makes use of Hugo [base templates], the [`.Format` function] for dates, the [`.WordCount` page variable][pagevars], and ranges through the single content's specific [taxonomies][pagetaxonomy]. [`with`] is also used to check whether the taxonomies are set in the front matter.
 
-{{< code file="layouts/posts/single.html" download="single.html" >}}
+{{< code file="layouts/posts/single.html" >}}
 {{ define "main" }}
 
 

{{ .Title }}

-
- {{ .Content }} -
+
+ {{ .Content }} +
{{ end }} {{< /code >}} diff --git a/content/en/templates/sitemap-template.md b/content/en/templates/sitemap-template.md index 9fc817020..d0738a362 100644 --- a/content/en/templates/sitemap-template.md +++ b/content/en/templates/sitemap-template.md @@ -1,16 +1,13 @@ --- title: Sitemap Templates description: Hugo provides built-in sitemap templates. -date: 2017-02-01 categories: [templates] keywords: [sitemap, xml, templates] menu: docs: - parent: "templates" + parent: templates weight: 160 weight: 160 -sections_weight: 160 -draft: false aliases: [/layout/sitemap/,/templates/sitemap/] toc: true --- @@ -79,7 +76,7 @@ You may disable sitemap generation in your site configuration: disableKinds = ['sitemap'] {{}} -[`publishDir`]: {{< relref "getting-started/configuration#publishdir" >}} +[`publishDir`]: /getting-started/configuration#publishdir [change frequency]: [priority]: [sitemap protocol]: diff --git a/content/en/templates/taxonomy-templates.md b/content/en/templates/taxonomy-templates.md index e9fc80525..e343df471 100644 --- a/content/en/templates/taxonomy-templates.md +++ b/content/en/templates/taxonomy-templates.md @@ -1,19 +1,13 @@ --- title: Taxonomy Templates -# linktitle: description: Taxonomy templating includes taxonomy list pages, taxonomy terms pages, and using taxonomies in your single page templates. -date: 2017-02-01 -publishdate: 2017-02-01 -lastmod: 2017-02-01 categories: [templates] keywords: [taxonomies,metadata,front matter,terms,templates] menu: docs: - parent: "templates" + parent: templates weight: 50 weight: 50 -sections_weight: 50 -draft: false aliases: [/taxonomies/displaying/,/templates/terms/,/indexes/displaying/,/taxonomies/templates/,/indexes/ordering/, /templates/taxonomies/, /templates/taxonomy/] toc: true --- @@ -150,16 +144,14 @@ Weights of zero are thus treated specially: if two pages have unequal weights, a Content can be assigned weight for each taxonomy that it's assigned to. -```txt -+++ + +{{< code-toggle file="content/example.md" fm=true copy=false >}} tags = [ "a", "b", "c" ] tags_weight = 22 categories = ["d"] -title = "foo" +title = "Example" categories_weight = 44 -+++ -Front Matter with weighted tags and categories -``` +{{< /code-toggle >}} The convention is `taxonomyname_weight`. @@ -177,16 +169,16 @@ There are two different templates that the use of taxonomies will require you to Both templates are covered in detail in the templates section. -A [list template](/templates/list/) is any template that will be used to render multiple pieces of content in a single html page. This template will be used to generate all the automatically created taxonomy pages. +A [list template](/templates/lists/) is any template that will be used to render multiple pieces of content in a single html page. This template will be used to generate all the automatically created taxonomy pages. -A [taxonomy terms template](/templates/terms/) is a template used to +A [taxonomy template](/templates/taxonomy-templates/) is a template used to generate the list of terms for a given template. There are four common ways you can display the data in your taxonomies in addition to the automatic taxonomy pages created by hugo -using the [list templates](/templates/list/): +using the [list templates](/templates/lists/): 1. For a given piece of content, you can list the terms attached 2. For a given piece of content, you can list other content with the same @@ -258,7 +250,7 @@ This would be very useful in a sidebar as “featured content”. You could even
  • {{ $key }}
  • {{ end }} @@ -288,7 +280,7 @@ The following example displays all terms in a site's tags taxonomy: This example will list all taxonomies and their terms, as well as all the content assigned to each of the terms. -{{< code file="layouts/partials/all-taxonomies.html" download="all-taxonomies.html" download="all-taxonomies.html" >}} +{{< code file="layouts/partials/all-taxonomies.html" >}}
      {{ range $taxonomy_term, $taxonomy := .Site.Taxonomies }} @@ -299,8 +291,8 @@ This example will list all taxonomies and their terms, as well as all the conten
    • {{ $key }}
    • @@ -315,14 +307,14 @@ This example will list all taxonomies and their terms, as well as all the conten ## `.Site.GetPage` for Taxonomies -Because taxonomies are lists, the [`.GetPage` function][getpage] can be used to get all the pages associated with a particular taxonomy term using a terse syntax. The following ranges over the full list of tags on your site and links to each of the individual taxonomy pages for each term without having to use the more fragile URL construction of the ["List All Site Tags" example above]({{< relref "#example-list-all-site-tags" >}}): +Because taxonomies are lists, the [`.GetPage` function][getpage] can be used to get all the pages associated with a particular taxonomy term using a terse syntax. The following ranges over the full list of tags on your site and links to each of the individual taxonomy pages for each term without having to use the more fragile URL construction of the ["List All Site Tags" example above](#example-list-all-site-tags): {{< code file="links-to-all-tags.html" >}} {{ $taxo := "tags" }}
        {{ with ($.Site.GetPage (printf "/%s" $taxo)) }} {{ range .Pages }} -
      • {{ .Title}}
      • +
      • {{ .Title }}
      • {{ end }} {{ end }}
      diff --git a/content/en/templates/template-debugging.md b/content/en/templates/template-debugging.md index b8938890f..0f32fa732 100644 --- a/content/en/templates/template-debugging.md +++ b/content/en/templates/template-debugging.md @@ -1,18 +1,13 @@ --- title: Template Debugging description: You can use Go templates' `printf` function to debug your Hugo templates. These snippets provide a quick and easy visualization of the variables available to you in different contexts. -date: 2017-02-01 -publishdate: 2017-02-01 categories: [templates] keywords: [debugging,troubleshooting] menu: docs: - parent: "templates" + parent: templates weight: 180 weight: 180 -sections_weight: 180 -aliases: [] -toc: false --- Here are some snippets you can add to your template to answer some common questions. diff --git a/content/en/templates/views.md b/content/en/templates/views.md index 495f701bd..24ff61150 100644 --- a/content/en/templates/views.md +++ b/content/en/templates/views.md @@ -1,20 +1,13 @@ --- title: Content View Templates -# linktitle: Content Views description: Hugo can render alternative views of your content, which is especially useful in list and summary views. -date: 2017-02-01 -publishdate: 2017-02-01 -lastmod: 2017-02-01 categories: [templates] keywords: [views] menu: docs: - parent: "templates" + parent: templates weight: 70 weight: 70 -sections_weight: 70 -draft: false -aliases: [] toc: true --- @@ -69,13 +62,13 @@ The following example demonstrates how to use content views inside your [list te In this example, `.Render` is passed into the template to call the [render function][render]. `.Render` is a special function that instructs content to render itself with the view template provided as the first argument. In this case, the template is going to render the `summary.html` view that follows: -{{< code file="layouts/_default/list.html" download="list.html" >}} +{{< code file="layouts/_default/list.html" >}}
      -

      {{ .Title }}

      - {{ range .Pages }} - {{ .Render "summary"}} - {{ end }} +

      {{ .Title }}

      + {{ range .Pages }} + {{ .Render "summary" }} + {{ end }}
      {{< /code >}} @@ -84,7 +77,7 @@ In this example, `.Render` is passed into the template to call the [render funct Hugo will pass the entire page object to the following `summary.html` view template. (See [Page Variables][pagevars] for a complete list.) -{{< code file="layouts/_default/summary.html" download="summary.html" >}} +{{< code file="layouts/_default/summary.html" >}}

      {{ .Title }}

      @@ -101,7 +94,7 @@ Hugo will pass the entire page object to the following `summary.html` view templ Continuing on the previous example, we can change our render function to use a smaller `li.html` view by changing the argument in the call to the `.Render` function (i.e., `{{ .Render "li" }}`). -{{< code file="layouts/_default/li.html" download="li.html" >}} +{{< code file="layouts/_default/li.html" >}}
    • {{ .Title }}
      {{ .Date.Format "Mon, Jan 2, 2006" }}
      diff --git a/content/en/tools/_index.md b/content/en/tools/_index.md index a63041819..b553dac9c 100644 --- a/content/en/tools/_index.md +++ b/content/en/tools/_index.md @@ -2,17 +2,13 @@ title: Developer Tools linktitle: Developer Tools Overview description: In addition to Hugo's powerful CLI, there is a large number of community-developed tool chains for Hugo developers. -date: 2016-12-05 -publishdate: 2016-12-05 -lastmod: 2017-02-26 categories: [developer tools] keywords: [] menu: docs: - parent: "tools" + parent: tools weight: 01 weight: 01 -sections_weight: 01 --- One of Hugo's greatest strengths is its passionate---and always evolving---developer community. With the exception of the `highlight` shortcode mentioned in [Syntax Highlighting][syntax], the tools and other projects featured in this section are offerings from both commercial services and open-source projects, many of which are developed by Hugo developers just like you. @@ -20,4 +16,4 @@ One of Hugo's greatest strengths is its passionate---and always evolving---devel [See the popularity of Hugo compared with other static site generators.][staticgen] [staticgen]: https://staticgen.com -[syntax]: /tools/syntax-highlighting/ +[syntax]: /content-management/syntax-highlighting/ diff --git a/content/en/tools/editors.md b/content/en/tools/editors.md index ed67885fc..55ab47090 100644 --- a/content/en/tools/editors.md +++ b/content/en/tools/editors.md @@ -2,19 +2,13 @@ title: Editor Plug-ins for Hugo linktitle: Editor Plug-ins description: The Hugo community uses a wide range of preferred tools and has developed plug-ins for some of the most popular text editors to help automate parts of your workflow. -date: 2017-02-01 -publishdate: 2017-02-01 categories: [developer tools] keywords: [editor, plug-ins] menu: docs: - parent: "tools" + parent: tools weight: 50 weight: 50 -sections_weight: 50 -draft: false -aliases: [] -toc: false --- The Hugo community uses a wide range of preferred tools and has developed plug-ins for some of the most popular text editors to help automate parts of your workflow. diff --git a/content/en/tools/frontends.md b/content/en/tools/frontends.md index 7ad44df53..1bfaf0995 100644 --- a/content/en/tools/frontends.md +++ b/content/en/tools/frontends.md @@ -2,20 +2,13 @@ title: Frontend Interfaces with Hugo linktitle: Frontends description: Do you prefer a graphical user interface over a text editor? Give these frontends a try. -date: 2017-02-01 -publishdate: 2017-02-01 -lastmod: 2017-02-01 categories: [developer tools] keywords: [frontend, gui] menu: docs: - parent: "tools" + parent: tools weight: 40 weight: 40 -sections_weight: 40 -draft: false -aliases: [] -toc: false --- - [enwrite](https://github.com/zzamboni/enwrite). Enwrite enables evernote-powered, statically generated blogs and websites. Now posting to your blog or updating your website is as easy as writing a new note in Evernote! diff --git a/content/en/tools/migrations.md b/content/en/tools/migrations.md index d6ca14ab5..0156c46db 100644 --- a/content/en/tools/migrations.md +++ b/content/en/tools/migrations.md @@ -2,17 +2,12 @@ title: Migrate to Hugo linktitle: Migrations description: A list of community-developed tools for migrating from your existing static site generator or content management system to Hugo. -date: 2017-02-01 -publishdate: 2017-02-01 -lastmod: 2022-03-26 keywords: [migrations, jekyll, wordpress, drupal, ghost, contentful] menu: docs: - parent: "tools" + parent: tools weight: 10 weight: 10 -sections_weight: 10 -draft: false aliases: [/developer-tools/migrations/, /developer-tools/migrated/] toc: true --- @@ -78,7 +73,7 @@ Alternatively, you can use the new [Jekyll import command](/commands/hugo_import ## Contentful -- [contentful2hugo](https://github.com/ArnoNuyts/contentful2hugo) - A tool to create content-files for Hugo from content on [Contentful](https://www.contentful.com/). +- [contentful-hugo](https://github.com/ModiiMedia/contentful-hugo) - A tool to create content-files for Hugo from content on [Contentful](https://www.contentful.com/). ## BlogML diff --git a/content/en/tools/other.md b/content/en/tools/other.md index ed7c530d0..3f8aeebbb 100644 --- a/content/en/tools/other.md +++ b/content/en/tools/other.md @@ -2,18 +2,13 @@ title: Other Hugo Community Projects linktitle: Other Projects description: Some interesting projects developed by the Hugo community that don't quite fit into our other developer tool categories. -date: 2017-02-01 -publishdate: 2017-02-01 categories: [developer tools] keywords: [frontend, gui] menu: docs: - parent: "tools" + parent: tools weight: 70 weight: 70 -sections_weight: 70 -aliases: [] -toc: false --- And for all the other small things around Hugo: diff --git a/content/en/tools/search.md b/content/en/tools/search.md index 464aa9107..030e9f2c7 100644 --- a/content/en/tools/search.md +++ b/content/en/tools/search.md @@ -2,17 +2,11 @@ title: Search for your Hugo Website linktitle: Search description: See some of the open-source and commercial search options for your newly created Hugo website. -date: 2017-02-01 -publishdate: 2017-02-01 -categories: [developer tools] -keywords: [search,tools] menu: docs: - parent: "tools" + parent: tools weight: 60 weight: 60 -sections_weight: 60 -aliases: [] toc: true --- @@ -32,5 +26,5 @@ A static website with a dynamic search function? Yes, Hugo provides an alternati ## Commercial Search Services * [Algolia](https://www.algolia.com/)'s Search API makes it easy to deliver a great search experience in your apps and websites. Algolia Search provides hosted full-text, numerical, faceted, and geolocalized search. -* [Bonsai](https://www.bonsai.io) is a fully-managed hosted Elasticsearch service that is fast, reliable, and simple to set up. Easily ingest your docs from Hugo into Elasticsearch following [this guide from the docs](https://docs.bonsai.io/docs/hugo). +* [Bonsai](https://www.bonsai.io) is a fully-managed hosted Elasticsearch service that is fast, reliable, and simple to set up. Easily ingest your docs from Hugo into Elasticsearch following [this guide from the docs](https://docs.bonsai.io/hc/en-us/articles/13929190788756-Hugo). * [ExpertRec](https://www.expertrec.com/) is a hosted search-as-a-service solution that is fast and scalable. Set-up and integration is extremely easy and takes only a few minutes. The search settings can be modified without coding using a dashboard. diff --git a/content/en/tools/starter-kits.md b/content/en/tools/starter-kits.md index 8399e99df..69c8f3e0b 100644 --- a/content/en/tools/starter-kits.md +++ b/content/en/tools/starter-kits.md @@ -1,25 +1,18 @@ --- title: Starter Kits -linktitle: Starter Kits description: A list of community-developed projects designed to help you get up and running with Hugo. -date: 2017-02-22 -publishdate: 2017-02-01 -lastmod: 2018-08-11 keywords: [starters,assets,pipeline] menu: docs: - parent: "tools" + parent: tools weight: 30 weight: 30 -sections_weight: 30 -draft: false aliases: [/developer-tools/migrations/,/developer-tools/migrated/] -toc: false --- Know of a Hugo-related starter kit that isn't mentioned here? [Please add it to the list.][addkit] -{{% note "Starter Kits are Not Maintained by the Hugo Team"%}} +{{% note %}} The following starter kits are developed by active members of the Hugo community. If you find yourself having issues with any of the projects, it's best to file an issue directly with the project's maintainer(s). {{% /note %}} @@ -32,7 +25,7 @@ The following starter kits are developed by active members of the Hugo community [addkit]: https://github.com/gohugoio/hugo/edit/master/docs/content/en/tools/starter-kits.md [amp]: https://amp.dev [GOHUGO AMP]: https://github.com/wildhaber/gohugo-amp -[gohugodocs]: https://gohugo-amp.gohugohq.com/ +[gohugodocs]: https://github.com/wildhaber/gohugo-amp.gohugohq.com [hugow]: https://github.com/khos2ow/hugo-wrapper [hugow-test]: https://github.com/khos2ow/hugo-wrapper#tested-on [Hyas]: https://github.com/h-enk/hyas diff --git a/content/en/troubleshooting/_index.md b/content/en/troubleshooting/_index.md index 3170dc7d8..51f1791a3 100644 --- a/content/en/troubleshooting/_index.md +++ b/content/en/troubleshooting/_index.md @@ -1,21 +1,12 @@ --- title: Troubleshoot -linktitle: Troubleshoot description: Frequently asked questions and known issues pulled from the Hugo Discuss forum. -date: 2017-02-01 -publishdate: 2017-02-01 -lastmod: 2017-02-01 menu: docs: - parent: "troubleshooting" + parent: troubleshooting weight: 1 weight: 1 -draft: false -hidesectioncontents: false -slug: aliases: [/troubleshooting/faqs/,/faqs/] -toc: false -notesforauthors: --- The Troubleshooting section includes known issues, recent workarounds, and FAQs pulled from the [Hugo Discussion Forum][forum]. diff --git a/content/en/troubleshooting/build-performance.md b/content/en/troubleshooting/build-performance.md index ea31ef84b..b58cdc11f 100644 --- a/content/en/troubleshooting/build-performance.md +++ b/content/en/troubleshooting/build-performance.md @@ -1,17 +1,10 @@ --- title: Build Performance -linktitle: Build Performance description: An overview of features used for diagnosing and improving performance issues in site builds. -date: 2017-03-12 -publishdate: 2017-03-12 -keywords: [performance, build] -categories: [troubleshooting] menu: docs: - parent: "troubleshooting" + parent: troubleshooting weight: 3 -slug: -aliases: [] toc: true --- @@ -85,10 +78,10 @@ the desired output, the template may benefit from caching to reduce the number of executions. The [`partialCached`][partialcached] template function provides caching capabilities for `partial` templates. -{{% tip %}} +{{% note %}} Note that you can create cached variants of each `partial` by passing additional parameters to `partialCached` beyond the initial context. See the `partialCached` documentation for more details. -{{% /tip %}} +{{% /note %}} -[partialCached]:{{< ref "/functions/partialCached.md" >}} +[partialCached]: /functions/partialcached diff --git a/content/en/troubleshooting/faq.md b/content/en/troubleshooting/faq.md index 998f9bbbe..04e857acb 100644 --- a/content/en/troubleshooting/faq.md +++ b/content/en/troubleshooting/faq.md @@ -2,11 +2,10 @@ title: Frequently Asked Questions linktitle: FAQ description: Solutions to some common Hugo problems. -date: 2018-02-10 categories: [troubleshooting] menu: docs: - parent: "troubleshooting" + parent: troubleshooting keywords: [faqs] weight: 2 toc: true diff --git a/content/en/variables/_index.md b/content/en/variables/_index.md index 382ee25d4..9b5289573 100644 --- a/content/en/variables/_index.md +++ b/content/en/variables/_index.md @@ -2,20 +2,14 @@ title: Variables and Params linktitle: Variables Overview description: Page-, file-, taxonomy-, and site-level variables and parameters available in templates. -date: 2017-02-01 -publishdate: 2017-02-01 -lastmod: 2017-02-01 categories: [variables and params] keywords: [variables,params,values,globals] -draft: false menu: docs: - parent: "variables" + parent: variables weight: 1 -weight: 01 #rem -sections_weight: 01 +weight: 01 aliases: [/templates/variables/] -toc: false --- Hugo's templates are context aware and make a large number of values available to you as you're creating views for your website. diff --git a/content/en/variables/files.md b/content/en/variables/files.md index 4e6c0632f..784ab7c64 100644 --- a/content/en/variables/files.md +++ b/content/en/variables/files.md @@ -1,54 +1,102 @@ --- title: File Variables -linktitle: -description: "You can access filesystem-related data for a content file in the `.File` variable." -date: 2017-02-01 -publishdate: 2017-02-01 -lastmod: 2017-02-01 +description: "Use File variables to access file-related values for each page that is backed by a file." categories: [variables and params] keywords: [files] -draft: false menu: docs: - parent: "variables" + parent: variables weight: 40 +toc: true weight: 40 -sections_weight: 40 aliases: [/variables/file-variables/] -toc: false --- +## Variables -{{% note "Rendering Local Files" %}} -For information on creating shortcodes and templates that tap into Hugo's file-related feature set, see [Local File Templates](/templates/files/). +{{% note %}} +The path separators (slash or backslash) in `.File.Path`, `.File.Dir`, and `.File.Filename` depend on the operating system. {{% /note %}} -The `.File` object contains the following fields: - .File.Path -: the original relative path of the page, relative to the content dir (e.g., `posts/foo.en.md`) - -.File.LogicalName -: the name of the content file that represents a page (e.g., `foo.en.md`) - -.File.TranslationBaseName -: the filename without extension or optional language identifier (e.g., `foo`) - -.File.ContentBaseName -: is either a TranslationBaseName or name of containing folder if file is a leaf bundle. - -.File.BaseFileName -: the filename without extension (e.g., `foo.en`) - -.File.Ext -: the file extension of the content file (e.g., `md`). - -.File.Lang -: the language associated with the given file if Hugo's [Multilingual features][multilingual] are enabled (e.g., `en`) +: (`string`) The file path, relative to the `content` directory. .File.Dir -: given the path `content/posts/dir1/dir2/`, the relative directory path of the content file will be returned (e.g., `posts/dir1/dir2/`). Note that the path separator (`\` or `/`) could be dependent on the operating system. +: (`string`) The file path, excluding the file name, relative to the `content` directory. + +.File.LogicalName +: (`string`) The file name. + +.File.BaseFileName +: (`string`) The file name, excluding the extension. + +.File.TranslationBaseName +: (`string`) The file name, excluding the extension and language identifier. + +.File.Ext +: (`string`) The file extension. + +.File.Lang +: (`string`) The language associated with the given file. + + +.File.ContentBaseName +: (`string`) If the page is a branch or leaf bundle, the name of the containing directory, else the `.TranslationBaseName`. + +.File.Filename +: (`string`) The absolute file path. .File.UniqueID -: the MD5-checksum of the content file's path. +: (`string`) The MD5 hash of `.File.Path`. -[Multilingual]: /content-management/multilingual/ +## Examples + +```text +content/ +├── news/ +│   ├── b/ +│   │   ├── index.de.md <-- leaf bundle +│   │   └── index.en.md <-- leaf bundle +│   ├── a.de.md <-- regular content +│   ├── a.en.md <-- regular content +│   ├── _index.de.md <-- branch bundle +│   └── _index.en.md <-- branch bundle +├── _index.de.md +└── _index.en.md +``` + +With the content structure above, the `.File` objects for the English pages contain the following properties: + + |regular content|leaf bundle|branch bundle +:--|:--|:--|:-- +Path|news/a.en.md|news/b/index.en.md|news/_index.en.md +Dir|news/|news/b/|news/ +LogicalName|a.en.md|index.en.md|_index.en.md +BaseFileName|a.en|index.en|_index.en +TranslationBaseName|a|index|_index +Ext|md|md|md +Lang|en|en|en +ContentBaseName|a|b|news +Filename|/home/user/...|/home/user/...|/home/user/... +UniqueID|15be14b...|186868f...|7d9159d... + +## Defensive coding + +Some of the pages on a site may not be backed by a file. For example: + +- Top level section pages +- Taxonomy pages +- Term pages + +Without a backing file, Hugo will throw a warning if you attempt to access a `.File` property. For example: + +```text +WARN .File.ContentBaseName on zero object. Wrap it in if or with... +``` + +To code defensively: + +```go-html-template +{{ with .File }} + {{ .ContentBaseName }} +{{ end }} +``` diff --git a/content/en/variables/git.md b/content/en/variables/git.md index 24878e350..dfd6e5407 100644 --- a/content/en/variables/git.md +++ b/content/en/variables/git.md @@ -2,24 +2,17 @@ title: Git Info Variables linktitle: Git Variables description: Get the last Git revision information for every content file. -date: 2017-03-12 -publishdate: 2017-03-12 -lastmod: 2017-03-12 categories: [variables and params] keywords: [git] -draft: false menu: docs: - parent: "variables" + parent: variables weight: 70 weight: 70 -sections_weight: 70 aliases: [/extras/gitinfo/] -toc: false -wip: false --- -{{% note "`.GitInfo` Performance Considerations" %}} +{{% note %}} Hugo's Git integrations should be fairly performant but *can* increase your build time. This will depend on the size of your Git history. {{% /note %}} diff --git a/content/en/variables/menus.md b/content/en/variables/menus.md index a59560729..b88514803 100644 --- a/content/en/variables/menus.md +++ b/content/en/variables/menus.md @@ -1,127 +1,92 @@ --- -title: Menu Entry Properties -linktitle: Menu Entry Properties -description: A menu entry in a menu-template has specific variables and functions to make menu management easier. -date: 2017-03-12 -publishdate: 2017-03-12 -lastmod: 2017-03-12 +title: Menu Variables +description: Use these variables and methods in your menu templates. categories: [variables and params] keywords: [menus] -draft: false menu: docs: - title: "variables defined by a menu entry" - parent: "variables" + parent: variables weight: 50 weight: 50 -sections_weight: 50 aliases: [/variables/menu/] -toc: false --- -A **menu entry** has the following properties available that can be used in a -[menu template][menu-template]. +## Variables -## Menu Entry Variables - -.Menu -: _string_
      -Name of the **menu** that contains this **menu entry**. - -.URL -: _string_
      -URL that the menu entry points to. The `url` key, if set for the menu entry, -sets this value. If that key is not set, and if the menu entry is set in a page -front-matter, this value defaults to the page's `.RelPermalink`. - -.Page -: _\*Page_
      -Reference to the [page object][page-object] associated with the menu entry. This -will be non-nil if the menu entry is set via a page's front-matter and not via -the site config. - -.PageRef -: _string_
      Can be set if defined in site config and the menu entry refers to a Page. [site.GetPage](/functions/getpage/) will be used to do the page lookup. If this is set, you don't need to set the `URL`. - -.Name -: _string_
      -Name of the menu entry. The `name` key, if set for the menu entry, sets -this value. If that key is not set, and if the menu entry is set in a page -front-matter, this value defaults to the page's `.LinkTitle`. - -.Identifier -: _string_
      -Value of the `identifier` key if set for the menu entry. This value must be -unique for each menu entry. **It is necessary to set a unique identifier -manually if two or more menu entries have the same `.Name`.** - -.Pre -: _template.HTML_
      -Value of the `pre` key if set for the menu entry. This value typically contains -a string representing HTML. - -.Post -: _template.HTML_
      -Value of the `post` key if set for the menu entry. This value typically contains -a string representing HTML. - -.Weight -: _int_
      -Value of the `weight` key if set for the menu entry. By default the entries in -a menu are sorted ascending by their `weight`. If that key is not set, and if -the menu entry is set in a page front-matter, this value defaults to the page's -`.Weight`. - -.Parent -: _string_
      -Name (or Identifier if present) of this menu entry's parent **menu entry**. The -`parent` key, if set for the menu entry, sets this value. If this key is set, -this menu entry nests under that parent entry, else it nests directly under the -`.Menu`. +After [defining menu entries], access their properties in [menu templates] with these variables. .Children -: _Menu_
      -This value is auto-populated by Hugo. It is a collection of children menu -entries, if any, under the current menu entry. +: (`menu`) A collection of child menu entries, if any, under the current menu entry. -## Menu Entry Functions - -Menus also have the following functions available: - -.HasChildren -: _boolean_
      -Returns `true` if `.Children` is non-nil. +.Identifier +: (`string`) The `identifier` property of the menu entry. If you define the menu entry [automatically], the page's `.Section`. .KeyName -: _string_
      -Returns the `.Identifier` if present, else returns the `.Name`. +: (`string`) The `identifier` property of the menu entry, else the `name` property. -.IsEqual -: _boolean_
      -Returns `true` if the two compared menu entries represent the same menu entry. +.Menu +: (`string`) The identifier of the menu that contains the menu entry. -.IsSameResource -: _boolean_
      -Returns `true` if the two compared menu entries have the same `.URL`. +.Name +: (`string`) The `name` property of the menu entry. + +- If you define the menu entry [automatically], the page's `.LinkTitle`, else the page's `.Title`. +- If you define the menu [in front matter] or [in site configuration], falls back to the page's `.LinkTitle`, then to the page's `.Title`. + +.Page +: (`page`) A reference to the page associated with the menu entry. + + + +.Params +: (`map`) The `params` property of the menu entry. + +.Parent +: (`string`) The `parent` property of the menu entry. + +.Post +: (`template.HTML`) The `post` property of the menu entry. + +.Pre +: (`template.HTML`) The `pre` property of the menu entry. .Title -: _string_
      -Link title, meant to be used in the `title` attribute of a menu entry's -``-tags. Returns the menu entry's `title` key if set. Else, if the menu -entry was created through a page's front-matter, it returns the page's -`.LinkTitle`. Else, it just returns an empty string. +: (`string`) The `title` property of the menu entry. -## Other Menu-related Functions +- If you define the menu entry [automatically], the page's `.LinkTitle`, else the page's `.Title`. +- If you define the menu [in front matter] or [in site configuration], falls back to the page's `.LinkTitle`, then to the page's `.Title`. -Additionally, here are some relevant methods available to menus on a page: +.URL +: (`string`) The `.RelPermalink` of the page associated with the menu entry. For menu entries pointing to external resources, the `url` property of the menu entry. -.IsMenuCurrent -: _(menu string, menuEntry *MenuEntry ) boolean_
      -See [`.IsMenuCurrent` method](/functions/ismenucurrent/). +.Weight +: (`int`) The `weight` property of the menu entry. -.HasMenuCurrent -: _(menu string, menuEntry *MenuEntry) boolean_
      -See [`.HasMenuCurrent` method](/functions/hasmenucurrent/). +- If you define the menu entry [automatically], the page's `.Weight`. +- If you define the menu [in front matter] or [in site configuration], falls back to the page's `.Weight`. -[menu-template]: /templates/menu-templates/ -[page-object]: /variables/page/ +## Methods + +.HasChildren +: (`bool`) Returns `true` if `.Children` is non-nil. + +.IsEqual +: (`bool`) Returns `true` if the compared menu entries represent the same menu entry. + +.IsSameResource +: (`bool`) Returns `true` if the compared menu entries point to the same resource. + +.Page.HasMenuCurrent +: (`bool`) Use this method to determine ancestors of the active menu entry. See [details](/functions/hasmenucurrent/). + +.Page.IsMenuCurrent +: (`bool`) Use this method to determine the active menu entry. See [details](/functions/ismenucurrent/). + +[automatically]: /content-management/menus/#define-automatically +[defining menu entries]: /content-management/menus/#overview +[in front matter]: /content-management/menus/#define-in-front-matter +[in site configuration]: /content-management/menus/#define-in-site-configuration +[menu templates]: /templates/menu-templates/ diff --git a/content/en/variables/page.md b/content/en/variables/page.md index 2de54ff8b..f8266965e 100644 --- a/content/en/variables/page.md +++ b/content/en/variables/page.md @@ -1,29 +1,18 @@ --- title: Page Variables -linktitle: description: Page-level variables are defined in a content file's front matter, derived from the content's file location, or extracted from the content body itself. -date: 2017-02-01 -publishdate: 2017-02-01 categories: [variables and params] keywords: [pages] -draft: false menu: docs: - title: "variables defined by a page" - parent: "variables" + parent: variables weight: 20 weight: 20 -sections_weight: 20 -aliases: [] toc: true --- The following is a list of page-level variables. Many of these will be defined in the front matter, derived from file location, or extracted from the content itself. -{{% note "`.Scratch`" %}} -See [`.Scratch`](/functions/scratch/) for page-scoped, writable variables. -{{% /note %}} - ## Page Variables .AlternativeOutputFormats @@ -33,7 +22,7 @@ See [`.Scratch`](/functions/scratch/) for page-scoped, writable variables. : aliases of this page .Ancestors -: get the ancestors of each page, simplify [breadcrumb navigation]({{< relref "content-management/sections#example-breadcrumb-navigation" >}}) implementation complexity +: get the ancestors of each page, simplify [breadcrumb navigation](/content-management/sections#example-breadcrumb-navigation) implementation complexity .BundleType : the [bundle] type: `leaf`, `branch`, or an empty string if the page is not a bundle. @@ -59,6 +48,9 @@ See [`.Scratch`](/functions/scratch/) for page-scoped, writable variables. .File : filesystem-related data for this content file. See also [File Variables]. +.Fragments +: Fragments returns the fragments for this page. See [Page Fragments](#page-fragments). + .FuzzyWordCount : the approximate number of words in the content. @@ -98,17 +90,17 @@ See also `.ExpiryDate`, `.Date`, `.PublishDate`, and [`.GitInfo`][gitinfo]. : access when creating links to the content. If set, Hugo will use the `linktitle` from the front matter before `title`. .Next -: Points up to the next [regular page](/variables/site/#site-pages) (sorted by Hugo's [default sort](/templates/lists#default-weight--date--linktitle--filepath)). Example: `{{with .Next}}{{.Permalink}}{{end}}`. Calling `.Next` from the first page returns `nil`. +: Points up to the next [regular page](/variables/site/#site-pages) (sorted by Hugo's [default sort](/templates/lists#default-weight--date--linktitle--filepath)). Example: `{{ with .Next }}{{ .Permalink }}{{ end }}`. Calling `.Next` from the first page returns `nil`. .NextInSection -: Points up to the next [regular page](/variables/site/#site-pages) below the same top level section (e.g. in `/blog`)). Pages are sorted by Hugo's [default sort](/templates/lists#default-weight--date--linktitle--filepath). Example: `{{with .NextInSection}}{{.Permalink}}{{end}}`. Calling `.NextInSection` from the first page returns `nil`. +: Points up to the next [regular page](/variables/site/#site-pages) below the same top level section (e.g. in `/blog`)). Pages are sorted by Hugo's [default sort](/templates/lists#default-weight--date--linktitle--filepath). Example: `{{ with .NextInSection }}{{ .Permalink }}{{ end }}`. Calling `.NextInSection` from the first page returns `nil`. .OutputFormats : contains all formats, including the current format, for a given page. Can be combined the with [`.Get` function](/functions/get/) to grab a specific format. (See [Output Formats](/templates/output-formats/).) .Pages : a collection of associated pages. This value will be `nil` within - the context of regular content pages. See [`.Pages`]({{< relref "page.md#pages" >}}). + the context of regular content pages. See [`.Pages`](#pages). .Permalink : the Permanent link for this page; see [Permalinks](/content-management/urls/) @@ -120,10 +112,10 @@ See also `.ExpiryDate`, `.Date`, `.PublishDate`, and [`.GitInfo`][gitinfo]. : the slice of strings that results from splitting .Plain into words, as defined in Go's [strings.Fields](https://pkg.go.dev/strings#Fields). .Prev -: Points down to the previous [regular page](/variables/site/#site-pages) (sorted by Hugo's [default sort](/templates/lists#default-weight--date--linktitle--filepath)). Example: `{{if .Prev}}{{.Prev.Permalink}}{{end}}`. Calling `.Prev` from the last page returns `nil`. +: Points down to the previous [regular page](/variables/site/#site-pages) (sorted by Hugo's [default sort](/templates/lists#default-weight--date--linktitle--filepath)). Example: `{{ if .Prev }}{{ .Prev.Permalink }}{{ end }}`. Calling `.Prev` from the last page returns `nil`. .PrevInSection -: Points down to the previous [regular page](/variables/site/#site-pages) below the same top level section (e.g. `/blog`). Pages are sorted by Hugo's [default sort](/templates/lists#default-weight--date--linktitle--filepath). Example: `{{if .PrevInSection}}{{.PrevInSection.Permalink}}{{end}}`. Calling `.PrevInSection` from the last page returns `nil`. +: Points down to the previous [regular page](/variables/site/#site-pages) below the same top level section (e.g. `/blog`). Pages are sorted by Hugo's [default sort](/templates/lists#default-weight--date--linktitle--filepath). Example: `{{ if .PrevInSection }}{{ .PrevInSection.Permalink }}{{ end }}`. Calling `.PrevInSection` from the last page returns `nil`. .PublishDate : the date on which the content was or will be published; `.Publishdate` pulls from the `publishdate` field in a content's front matter. See also `.ExpiryDate`, `.Date`, and `.Lastmod`. @@ -184,6 +176,14 @@ https://remarkjs.com) .WordCount : the number of words in the content. +## Writable Page-scoped Variables + +[.Scratch][scratch] +: returns a Scratch to store and manipulate data. In contrast to the [`.Store`][store] method, this scratch is reset on server rebuilds. + +[.Store][store] +: returns a Scratch to store and manipulate data. In contrast to the [`.Scratch`][scratch] method, this scratch is not reset on server rebuilds. + ## Section Variables and Methods Also see [Sections](/content-management/sections/). @@ -199,53 +199,92 @@ aliased form `.Pages`. {{< getcontent path="readfiles/pages-vs-site-pages.md" >}} +## Page Fragments + +{{< new-in "0.111.0" >}} + +The `.Fragments` method returns a list of fragments for the current page. + +.Headings +: A recursive list of headings for the current page. Can be used to generate a table of contents. + +{{< todo >}}add .Headings toc example{{< /todo >}} + +.Identifiers +: A sorted list of identifiers for the current page. Can be used to check if a page contains a specific identifier or if a page contains duplicate identifiers: + +```go-html-template +{{ if .Fragments.Identifiers.Contains "my-identifier" }} +

      Page contains identifier "my-identifier"

      +{{ end }} + +{{ if gt (.Fragments.Identifiers.Count "my-identifier") 1 }} +

      Page contains duplicate "my-identifier" fragments

      +{{ end }} +``` + +.HeadingsMap +: Holds a map of headings for the current page. Can be used to start the table of contents from a specific heading. + +Also see the [Go Doc](https://pkg.go.dev/github.com/gohugoio/hugo@v0.111.0/markup/tableofcontents#Fragments) for the return type. + +### Fragments in hooks and shortcodes + +`.Fragments` are safe to call from render hooks, even on the page you're on (`.Page.Fragments`). For shortcodes we recommend that all `.Fragments` usage is nested inside the `{{}}` shortcode delimiter (`{{%/**/%}}` takes part in the ToC creation so it's easy to end up in a situation where you bite yourself in the tail). + + +## The global page function + +{{< new-in "0.111.1" >}} + +Hugo almost always passes a `Page` as the data context into the top level template (e.g. `single.html`) (the one exception is the multihost sitemap template). This means that you can access the current page with the `.` variable in the template. + +But when you're deeply nested inside `.Render`, partial etc., accessing that `Page` object isn't always practical or possible. + +For this reason, Hugo provides a global `page` function that you can use to access the current page from anywhere in any template. + +```go-html-template +{{ page.Title }} +``` + +There are one caveat with this, and this isn't new, but it's worth mentioning here: There are situations in Hugo where you may see a cached value, e.g. when using `partialCached` or in a shortcode. + ## Page-level Params 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 +{{< code-toggle file="content/example.md" fm=true copy=false >}} +title: Example categories: [one] tags: [two,three,four] -``` +{{< /code-toggle >}} With the above front matter, the `tags` and `categories` taxonomies are accessible via the following: * `.Params.tags` * `.Params.categories` -{{% note "Casing of Params" %}} -Page-level `.Params` are *only* accessible in lowercase. -{{% /note %}} +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: -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 ---- -... +{{< code-toggle file="content/example.md" fm=true copy=false >}} +title: Example affiliatelink: "http://www.my-book-link.here" recommendedby: "My Mother" -... ---- +{{< /code-toggle >}} + +These fields would then be accessible to via `.Params.affiliatelink` and `.Params.recommendedby`. + +```go-html-template +

      Buy this book

      +

      It was recommended by {{ .Params.recommendedby }}.

      ``` -These fields would then be accessible to the `/themes/yourtheme/layouts/review/single.html` template through `.Params.affiliatelink` and `.Params.recommendedby`, respectively. +This template would render as follows: -Two common situations where this type of front matter field could be introduced is as a value of a certain attribute like `href=""` or by itself to be displayed as text to the website's visitors. - -{{< code file="/themes/yourtheme/layouts/review/single.html" >}} -

      Buy this book

      -

      It was recommended by {{ .Params.recommendedby }}.

      -{{< /code >}} - -This template would render as follows, assuming you've set [`uglyURLs`](/content-management/urls/) to `false` in your [site `config`](/getting-started/configuration/): - -{{< output file="yourbaseurl/review/book01/index.html" >}} +```html

      Buy this book

      It was recommended by my Mother.

      -{{< /output >}} +``` {{% note %}} See [Archetypes](/content-management/archetypes/) for consistency of `Params` across pieces of content. @@ -265,37 +304,22 @@ 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 ---- +{{< code-toggle file="content/example.md" fm=true copy=false >}} +title: Example author: given_name: John family_name: Feminella display_name: John Feminella ---- -``` +{{< /code-toggle >}} + `.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: - flavor: chocolate ---- -``` - -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 -``` - [gitinfo]: /variables/git/ [File Variables]: /variables/files/ -[bundle]: {{< relref "content-management/page-bundles" >}} +[bundle]: /content-management/page-bundles +[scratch]: /functions/scratch +[store]: /functions/store diff --git a/content/en/variables/pages.md b/content/en/variables/pages.md index 61036dd74..15904de95 100644 --- a/content/en/variables/pages.md +++ b/content/en/variables/pages.md @@ -1,18 +1,13 @@ --- title: Pages Methods -linktitle: description: Pages is the core page collection in Hugo and has many useful methods. -date: 2019-10-20 categories: [variables and params] keywords: [pages] -draft: false menu: docs: - title: "methods defined on a page collection" - parent: "variables" + parent: variables weight: 21 weight: 21 -sections_weight: 20 aliases: [/pages] toc: true --- @@ -23,8 +18,8 @@ Also see [List templates](/templates/lists) for an overview of sort methods. `.Next` and `.Prev` on `Pages` work similar to the methods with the same names on `.Page`, but are more flexible (and slightly slower) as they can be used on any page collection. -`.Next` points **up** to the next page relative to the page sent in as the argument. Example: `{{with .Site.RegularPages.Next . }}{{.RelPermalink}}{{end}}`. Calling `.Next` with the first page in the collection returns `nil`. +`.Next` points **up** to the next page relative to the page sent in as the argument. Example: `{{ with .Site.RegularPages.Next . }}{{ .RelPermalink }}{{ end }}`. Calling `.Next` with the first page in the collection returns `nil`. ## .Prev PAGE -`.Prev` points **down** to the previous page relative to the page sent in as the argument. Example: `{{with .Site.RegularPages.Prev . }}{{.RelPermalink}}{{end}}`. Calling `.Prev` with the last page in the collection returns `nil`. +`.Prev` points **down** to the previous page relative to the page sent in as the argument. Example: `{{ with .Site.RegularPages.Prev . }}{{ .RelPermalink }}{{ end }}`. Calling `.Prev` with the last page in the collection returns `nil`. diff --git a/content/en/variables/shortcodes.md b/content/en/variables/shortcodes.md index a7c9e475b..3d4185b45 100644 --- a/content/en/variables/shortcodes.md +++ b/content/en/variables/shortcodes.md @@ -1,19 +1,13 @@ --- title: Shortcode Variables -linktitle: Shortcode Variables description: Shortcodes can access page variables and also have their own specific built-in variables. -date: 2017-03-12 -publishdate: 2017-03-12 categories: [variables and params] keywords: [shortcodes] menu: docs: - parent: "variables" + parent: variables weight: 20 weight: 20 -sections_weight: 20 -aliases: [] -toc: false --- [Shortcodes][shortcodes] have access to parameters delimited in the shortcode declaration via [`.Get`][getfunction], page- and site-level variables, and also the following shortcode-specific fields: @@ -39,9 +33,13 @@ toc: false .Inner : represents the content between the opening and closing shortcode tags when a [closing shortcode][markdownshortcode] is used -[getfunction]: /functions/get/ -[markdownshortcode]: /content-management/shortcodes/#shortcodes-with-markdown -[shortcodes]: /templates/shortcode-templates/ +.Scratch +: returns a writable [`Scratch`][scratch] to store and manipulate data which will be attached to the shortcode context. This scratch is reset on server rebuilds. .InnerDeindent {{< new-in "0.100.0" >}} : Gets the `.Inner` with any indentation removed. This is what's used in the built-in `{{}}` shortcode. + +[getfunction]: /functions/get/ +[markdownshortcode]: /content-management/shortcodes/#shortcodes-with-markdown +[shortcodes]: /templates/shortcode-templates/ +[scratch]: /functions/scratch diff --git a/content/en/variables/site.md b/content/en/variables/site.md index 34239ad44..71111eb83 100644 --- a/content/en/variables/site.md +++ b/content/en/variables/site.md @@ -1,19 +1,13 @@ --- title: Site Variables -linktitle: Site Variables description: Many, but not all, site-wide variables are defined in your site's configuration. However, Hugo provides a number of built-in variables for convenient access to global values in your templates. -date: 2017-02-01 -publishdate: 2017-02-01 -lastmod: 2017-02-01 categories: [variables and params] keywords: [global,site] -draft: false menu: docs: - parent: "variables" + parent: variables weight: 10 weight: 10 -sections_weight: 10 aliases: [/variables/site-variables/] toc: true --- @@ -84,16 +78,16 @@ All the methods below, e.g. `.Site.RegularPages` can also be reached via the glo : all the menus in the site. .Site.Pages -: array of all content ordered by Date with the newest first. This array contains only the pages in the current language. See [`.Site.Pages`]({{< relref "site.md#site-pages" >}}). +: array of all content ordered by Date with the newest first. This array contains only the pages in the current language. See [`.Site.Pages`](#site-pages). .Site.RegularPages -: a shortcut to the *regular* page collection. `.Site.RegularPages` is equivalent to `where .Site.Pages "Kind" "page"`. See [`.Site.Pages`]({{< relref "site.md#site-pages" >}}). +: a shortcut to the *regular* page collection. `.Site.RegularPages` is equivalent to `where .Site.Pages "Kind" "page"`. See [`.Site.Pages`](#site-pages). .Site.Sections : top-level directories of the site. .Site.Taxonomies -: the [taxonomies](/taxonomies/usage/) for the entire site. Also see section [Use `.Site.Taxonomies` Outside of Taxonomy Templates](/variables/taxonomy/#use-sitetaxonomies-outside-of-taxonomy-templates). +: the [taxonomies](/content-management/taxonomies/) for the entire site. Also see section [Access taxonomy data from any template](/variables/taxonomy/#access-taxonomy-data-from-any-template). .Site.Title : a string representing the title of the site. @@ -117,7 +111,7 @@ baseURL = "https://yoursite.example.com/" You can use `.Site.Params` in a [partial template](/templates/partials/) to call the default site description: {{< code file="layouts/partials/head.html" >}} - + {{< /code >}} ## The `.Site.Pages` Variable {#site-pages} diff --git a/content/en/variables/sitemap.md b/content/en/variables/sitemap.md index 24700182a..b0b080d00 100644 --- a/content/en/variables/sitemap.md +++ b/content/en/variables/sitemap.md @@ -2,19 +2,13 @@ title: Sitemap Variables linktitle: Sitemap Variables description: -date: 2017-03-12 -publishdate: 2017-03-12 categories: [variables and params] keywords: [sitemap] -draft: false menu: docs: - parent: "variables" + parent: variables weight: 80 weight: 80 -sections_weight: 80 -aliases: [] -toc: false --- A sitemap is a `Page` and therefore has all the [page variables][pagevars] available to use sitemap templates. They also have the following sitemap-specific variables available to them: diff --git a/content/en/variables/taxonomy.md b/content/en/variables/taxonomy.md index 901769b31..63b552328 100644 --- a/content/en/variables/taxonomy.md +++ b/content/en/variables/taxonomy.md @@ -1,16 +1,14 @@ --- title: Taxonomy Variables -linktitle: description: Hugo's taxonomy system exposes variables to taxonomy and term templates. categories: [variables and params] keywords: [taxonomy,term] menu: docs: - parent: "variables" + parent: variables weight: 30 toc: true weight: 30 -aliases: [] --- ## Taxonomy templates @@ -124,7 +122,7 @@ For example, to render the entire taxonomy data structure as a nested unordered diff --git a/data/docs.json b/data/docs.json index c55c27347..6efb03f8f 100644 --- a/data/docs.json +++ b/data/docs.json @@ -3493,7 +3493,7 @@ ] }, "Uniq": { - "Description": "Uniq takes returns a new list with all duplicate elements in the list l removed.\nduplicate elements removed.", + "Description": "Uniq returns a new list with duplicate elements in the list l removed.", "Args": [ "l" ], @@ -3602,6 +3602,20 @@ ] } }, + "css": { + "Quoted": { + "Description": "", + "Args": null, + "Aliases": null, + "Examples": null + }, + "Unquoted": { + "Description": "", + "Args": null, + "Aliases": null, + "Examples": null + } + }, "data": { "GetCSV": { "Description": "GetCSV expects the separator sep and one or n-parts of a URL to a resource which\ncan either be a local or a remote one.\nThe data separator can be a comma, semi-colon, pipe, etc, but only one character.\nIf you provide multiple parts for the URL they will be joined together to the final URL.\nGetCSV returns nil or a slice slice to use in a short code.", @@ -4782,6 +4796,12 @@ "Aliases": null, "Examples": null }, + "GetIdentity": { + "Description": "", + "Args": null, + "Aliases": null, + "Examples": null + }, "Home": { "Description": "", "Args": null, @@ -4913,6 +4933,12 @@ ] ] }, + "ContainsNonSpace": { + "Description": "", + "Args": null, + "Aliases": null, + "Examples": null + }, "Count": { "Description": "Count counts the number of non-overlapping instances of substr in s.\nIf substr is an empty string, Count returns 1 + the number of Unicode code points in s.", "Args": [ @@ -5468,6 +5494,7 @@ "Markdownify": { "Description": "Markdownify renders s from Markdown to HTML.", "Args": [ + "ctx", "s" ], "Aliases": [ diff --git a/go.mod b/go.mod index 33f818ad6..07badfeaf 100644 --- a/go.mod +++ b/go.mod @@ -2,4 +2,4 @@ module github.com/gohugoio/hugoDocs go 1.16 -require github.com/gohugoio/gohugoioTheme v0.0.0-20230124135550-462d5fe4a87f // indirect +require github.com/gohugoio/gohugoioTheme v0.0.0-20230418063032-99f9185b8e11 // indirect diff --git a/go.sum b/go.sum index ea0d2dcbe..6783cb92e 100644 --- a/go.sum +++ b/go.sum @@ -59,3 +59,7 @@ github.com/gohugoio/gohugoioTheme v0.0.0-20230120185049-2c3c4d0ba232 h1:bEojKgKI github.com/gohugoio/gohugoioTheme v0.0.0-20230120185049-2c3c4d0ba232/go.mod h1:GOYeAPQJ/ok8z7oz1cjfcSlsFpXrmx6VkzQ5RpnyhZM= github.com/gohugoio/gohugoioTheme v0.0.0-20230124135550-462d5fe4a87f h1:8wI3zOTWQG15aKkbAZQaoGnUQff46hO95opQndBHRE4= github.com/gohugoio/gohugoioTheme v0.0.0-20230124135550-462d5fe4a87f/go.mod h1:GOYeAPQJ/ok8z7oz1cjfcSlsFpXrmx6VkzQ5RpnyhZM= +github.com/gohugoio/gohugoioTheme v0.0.0-20230330081257-7a8c9614432c h1:TyHgmowfiMyxKrqTdRxm/yWIFeN7XRh7Hm6/dOG6yDA= +github.com/gohugoio/gohugoioTheme v0.0.0-20230330081257-7a8c9614432c/go.mod h1:GOYeAPQJ/ok8z7oz1cjfcSlsFpXrmx6VkzQ5RpnyhZM= +github.com/gohugoio/gohugoioTheme v0.0.0-20230418063032-99f9185b8e11 h1:mDcricMewd66x8QjKqNun7Div7iYVLtl8s1dVs9VnB8= +github.com/gohugoio/gohugoioTheme v0.0.0-20230418063032-99f9185b8e11/go.mod h1:GOYeAPQJ/ok8z7oz1cjfcSlsFpXrmx6VkzQ5RpnyhZM= diff --git a/hugo.toml b/hugo.toml index da6bd9534..5bed0ab2b 100644 --- a/hugo.toml +++ b/hugo.toml @@ -65,7 +65,17 @@ disableAliases = true toLower = false [[related.indices]] name = "keywords" - weight = 100 + weight = 60 + [[related.indices]] + # Can be used as a front matter slice to link to other page fragments (headings) using their ID. + # This isn't particular useful in the current docs, but we're planning on getting a auto generated + # reference section with a better ID setup. + # For now, we just use it to give pages with same headings some similarity score. + name = "fragmentrefs" + type = "fragments" + applyFilter = false + weight = 60 + cardinalityThreshold = 50 [[related.indices]] name = "date" weight = 10 diff --git a/layouts/shortcodes/code-toggle.html b/layouts/shortcodes/code-toggle.html index 113d85a1f..b4cfaaa20 100644 --- a/layouts/shortcodes/code-toggle.html +++ b/layouts/shortcodes/code-toggle.html @@ -1,87 +1,66 @@ {{- /* Renders syntax-highlighted configuration data in JSON, TOML, and YAML formats. -@param {string} config - Section of site.Data.docs.config to render. - Example: markup.highlight - Default: "" -@param {bool} copy - Display a copy button. - Default: true -@param {string} file - File name to display above the rendered code. - Default: "" -@param {bool} fm - Does Inner represent front matter? - Default: false -@param {string} Inner - Content between opening and closing shortcode tags. - Default: "" -@param {bool} skipHeader - Omit top level key(s) when rendering a section of site.Data.docs.config. - Default: false +@param {string} [config] The section of site.Data.docs.config to render. +@param {bool} [copy=true] If true, display a copy to clipboard button. +@param {string} [file] The file name to display above the rendered code. +@param {bool} [fm=false] If true, render the code as front matter. +@param {bool} [skipHeader=false] If false, omit top level key(s) when rendering a section of site.Data.docs.config. + @returns {template.HTML} -*/ -}} +*/}} -{{- /* Initialize. */ -}} -{{- $config := "" -}} -{{- $copy := true -}} -{{- $file := "" -}} -{{- $fm := false -}} -{{- $skipHeader := false -}} +{{- /* Initialize. */}} +{{- $config := "" }} +{{- $copy := true }} +{{- $file := "" }} +{{- $fm := false }} +{{- $skipHeader := false }} -{{- /* Get parameters, defend against string booleans. */ -}} -{{- if .Params -}} - {{- $config = .Get "config" -}} - {{- $file = .Get "file" -}} - {{- if (isset .Params "copy") -}} - {{- if in (slice true "true") (.Get "copy") -}} - {{- $copy = true -}} - {{- else -}} - {{- $copy = false -}} - {{- end -}} - {{- end -}} - {{- if (isset .Params "fm") -}} - {{- if in (slice true "true") (.Get "fm") -}} - {{- $fm = true -}} - {{- else -}} - {{- $fm = false -}} - {{- end -}} - {{- end -}} - {{- if (isset .Params "skipHeader") -}} - {{- if in (slice true "true") (.Get "skipHeader") -}} - {{- $skipHeader = true -}} - {{- else -}} - {{- $skipHeader = false -}} - {{- end -}} - {{- end -}} -{{- end -}} +{{- /* Get parameters. */}} +{{- $config = .Get "config" }} +{{- $file = .Get "file" }} +{{- if in (slice "false" false 0) (.Get "copy") }} + {{- $copy = false }} +{{- else if in (slice "true" true 1) (.Get "copy")}} + {{- $copy = true }} +{{- end }} +{{- if in (slice "false" false 0) (.Get "fm") }} + {{- $fm = false }} +{{- else if in (slice "true" true 1) (.Get "fm")}} + {{- $fm = true }} +{{- end }} +{{- if in (slice "false" false 0) (.Get "skipHeader") }} + {{- $skipHeader = false }} +{{- else if in (slice "true" true 1) (.Get "skipHeader")}} + {{- $skipHeader = true }} +{{- end }} -{{- /* Define constants. */ -}} -{{- $delimiters := dict "toml" "+++" "yaml" "---" -}} -{{- $langs := slice "yaml" "toml" "json" -}} -{{- $placeHolder := "#-hugo-placeholder-#" -}} +{{- /* Define constants. */}} +{{- $delimiters := dict "toml" "+++" "yaml" "---" }} +{{- $langs := slice "yaml" "toml" "json" }} +{{- $placeHolder := "#-hugo-placeholder-#" }} -{{- /* Render. */ -}} -{{- $code := "" -}} -{{- with $config -}} - {{- $file = $file | default "config" -}} - {{- $sections := (split . ".") -}} - {{- $configSection := index $.Site.Data.docs.config $sections -}} - {{- $code = dict $sections $configSection -}} - {{- if $skipHeader -}} - {{- $code = $configSection -}} - {{- end -}} -{{- else -}} - {{- $code = $.Inner -}} +{{- /* Render. */}} +{{- $code := "" }} +{{- with $config }} + {{- $file = $file | default "config" }} + {{- $sections := (split . ".") }} + {{- $configSection := index $.Site.Data.docs.config $sections }} + {{- $code = dict $sections $configSection }} + {{- if $skipHeader }} + {{- $code = $configSection }} + {{- end }} +{{- else }} + {{- $code = $.Inner }} {{- end }}
      {{- with $file }}
      - {{- . -}}{{- if not $fm -}}.{{- end -}} + {{ . }}{{ if not $fm }}.{{ end }}
      - {{- end -}} + {{- end }} {{- range $langs }} - {{- /* Functionality located within filesaver.js The copy here is located in the css with .copy class so it can be replaced with JS on success */ -}} - {{- end -}} + {{- /* Functionality located within filesaver.js The copy here is located in the css with .copy class so it can be replaced with JS on success */}} + {{- end }} {{- end }}
      diff --git a/layouts/shortcodes/code.html b/layouts/shortcodes/code.html index 0ee25149d..31ca27596 100644 --- a/layouts/shortcodes/code.html +++ b/layouts/shortcodes/code.html @@ -1,26 +1,39 @@ -{{ $file := .Get "file" }} -{{ $codeLang := "" }} -{{ $suffix := findRE "(\\.[^.]+)$" $file 1 }} -{{ with $suffix }} -{{ $codeLang = (index . 0 | strings.TrimPrefix ".") }} -{{ end }} -{{ with .Get "codeLang" }}{{ $codeLang = . }}{{ end }} -{{ if eq $codeLang "html" }} -{{ $codeLang = "go-html-template" }} -{{ end }} +{{- /* +Renders syntax highlighted code. + +@param {bool} [copy=true] If true, display a copy to clipboard button. +@param {string} [file] The file name to display above the rendered code. +@param {string} [lang] The code language of the inner content. + +@returns {template.HTML} +*/}} + +{{- /* Initialize. */}} +{{- $copy := true }} +{{- $file := " " }} +{{- $lang := "" }} + +{{- /* Get parameters. */}} +{{- $file = .Get "file" }} +{{- $lang = or (.Get "lang") (path.Ext $file | strings.TrimPrefix ".") "text" }} +{{- if in (slice "false" false 0) (.Get "copy") }} + {{- $copy = false }} +{{- else if in (slice "true" true 1) (.Get "copy")}} + {{- $copy = true }} +{{- end }} + +{{- /* Use the go-html-template Chroma lexer for HTML. */}} +{{- if eq $lang "html" }} + {{- $lang = "go-html-template" }} +{{- end }} + +{{- /* Render. */}}
      - {{- with $file -}} -
      {{ . }}
      - {{- end -}} - - {{ if ne (.Get "copy") "false" }} - - {{/* Functionality located within filesaver.js The copy here is located in the css with .copy class so it can be replaced with JS on success */}} - {{ end }} -
      - {{ $inner := trim .Inner "\n" | safeHTML }} - {{ if .Get "nocode" }}{{ $inner }}{{ else }}{{ with $codeLang }}{{ highlight $inner . "" }}{{ else }}
      {{ $inner }}
      {{ end }}{{ end }} -
      - +
      {{ or $file "nbsp;" }}
      + {{- if $copy }} + + {{- end }} +
      + {{- highlight (trim .Inner "\n\r") $lang }} +
      diff --git a/layouts/shortcodes/content-tree.html b/layouts/shortcodes/content-tree.html deleted file mode 100644 index 0cb527cb5..000000000 --- a/layouts/shortcodes/content-tree.html +++ /dev/null @@ -1,14 +0,0 @@ -
      -
      
      -        ├── blog
      -        │   ├── _index.md [section]
      -        │   ├── first-post.md [page]
      -        │   └── second-post
      -        │       ├── index.md [page bundle]
      -        │       └── photo.jpg [page resource]
      -        └── tags
      -            ├── _index.md [taxonomy]
      -            └── funny
      -                └── _index.md [term]
      -    
      -
      \ No newline at end of file diff --git a/layouts/shortcodes/directoryindex.html b/layouts/shortcodes/directoryindex.html deleted file mode 100644 index 37e7d3ad1..000000000 --- a/layouts/shortcodes/directoryindex.html +++ /dev/null @@ -1,13 +0,0 @@ -{{- $pathURL := .Get "pathURL" -}} -{{- $path := .Get "path" -}} -{{- $files := readDir $path -}} - - - -{{- range $files }} - - - - -{{- end }} -
      Size in bytesName
      {{ .Size }} {{ .Name }}
      diff --git a/layouts/shortcodes/docfile.html b/layouts/shortcodes/docfile.html deleted file mode 100644 index 2f982aae8..000000000 --- a/layouts/shortcodes/docfile.html +++ /dev/null @@ -1,11 +0,0 @@ -{{ $file := .Get 0}} -{{ $filepath := $file }} -{{ $syntax := index (split $file ".") 1 }} -{{ $syntaxoverride := eq (len .Params) 2 }} -
      -
      {{$filepath}}
      - -
      {{- readFile $file -}}
      -
      diff --git a/layouts/shortcodes/exfile.html b/layouts/shortcodes/exfile.html deleted file mode 100644 index 226782957..000000000 --- a/layouts/shortcodes/exfile.html +++ /dev/null @@ -1,12 +0,0 @@ -{{ $file := .Get 0}} -{{ $filepath := replace $file "static/" ""}} -{{ $syntax := index (split $file ".") 1 }} -{{ $syntaxoverride := eq (len .Params) 2 }} -
      -
      {{$filepath}}
      - -
      {{- readFile $file -}}
      - Source -
      diff --git a/layouts/shortcodes/exfm.html b/layouts/shortcodes/exfm.html deleted file mode 100644 index c0429bbe1..000000000 --- a/layouts/shortcodes/exfm.html +++ /dev/null @@ -1,13 +0,0 @@ - -{{ $file := .Get 0}} -{{ $filepath := replace $file "static/" ""}} -{{ $syntax := index (split $file ".") 1 }} -{{ $syntaxoverride := eq (len .Params) 2 }} -
      -
      {{$filepath}}
      - -
      {{- readFile $file -}}
      - Source -
      \ No newline at end of file diff --git a/layouts/shortcodes/gh.html b/layouts/shortcodes/gh.html deleted file mode 100644 index 981f4b838..000000000 --- a/layouts/shortcodes/gh.html +++ /dev/null @@ -1,9 +0,0 @@ -{{ range .Params }} - {{ if eq (substr . 0 1) "@" }} - {{ . }} - {{ else if eq (substr . 0 2) "0x" }} - {{ substr . 2 6 }} - {{ else }} - #{{ . }} - {{ end }} -{{ end }} diff --git a/layouts/shortcodes/ghrepo.html b/layouts/shortcodes/ghrepo.html deleted file mode 100644 index e9df40d6a..000000000 --- a/layouts/shortcodes/ghrepo.html +++ /dev/null @@ -1 +0,0 @@ -GitHub repository \ No newline at end of file diff --git a/layouts/shortcodes/nohighlight.html b/layouts/shortcodes/nohighlight.html deleted file mode 100644 index 238234f17..000000000 --- a/layouts/shortcodes/nohighlight.html +++ /dev/null @@ -1 +0,0 @@ -
      {{ .Inner }}
      \ No newline at end of file diff --git a/layouts/shortcodes/note.html b/layouts/shortcodes/note.html deleted file mode 100644 index 24d2cd0b2..000000000 --- a/layouts/shortcodes/note.html +++ /dev/null @@ -1,9 +0,0 @@ -{{ $_hugo_config := `{ "version": 1 }` }} - diff --git a/layouts/shortcodes/output.html b/layouts/shortcodes/output.html deleted file mode 100644 index e51d284bb..000000000 --- a/layouts/shortcodes/output.html +++ /dev/null @@ -1,8 +0,0 @@ -{{$file := .Get "file"}} -{{$icon := index (split $file ".") 1 }} -
      -
      {{$file}}
      -
      -
      {{- .Inner | string -}}
      -
      -
      \ No newline at end of file diff --git a/layouts/shortcodes/tip.html b/layouts/shortcodes/tip.html deleted file mode 100644 index 139e3376b..000000000 --- a/layouts/shortcodes/tip.html +++ /dev/null @@ -1,9 +0,0 @@ -{{ $_hugo_config := `{ "version": 1 }` }} - diff --git a/layouts/shortcodes/warning.html b/layouts/shortcodes/warning.html deleted file mode 100644 index c9147be64..000000000 --- a/layouts/shortcodes/warning.html +++ /dev/null @@ -1,9 +0,0 @@ -{{ $_hugo_config := `{ "version": 1 }` }} - diff --git a/layouts/shortcodes/yt.html b/layouts/shortcodes/yt.html deleted file mode 100644 index 6915cec5f..000000000 --- a/layouts/shortcodes/yt.html +++ /dev/null @@ -1,11 +0,0 @@ -
      - - {{if (.Get "thumbnail")}} -
      - {{else}} -
      - {{end}} -
      -{{ if (.Get "description") }} -
      {{ .Get "description" | markdownify }}
      -{{ end }} \ No newline at end of file diff --git a/netlify.toml b/netlify.toml index d99f6d223..a07e29a94 100644 --- a/netlify.toml +++ b/netlify.toml @@ -3,7 +3,7 @@ publish = "public" command = "hugo --gc --minify" [context.production.environment] -HUGO_VERSION = "0.110.0" +HUGO_VERSION = "0.111.3" HUGO_ENV = "production" HUGO_ENABLEGITINFO = "true" @@ -11,20 +11,20 @@ HUGO_ENABLEGITINFO = "true" command = "hugo --gc --minify --enableGitInfo" [context.split1.environment] -HUGO_VERSION = "0.110.0" +HUGO_VERSION = "0.111.3" HUGO_ENV = "production" [context.deploy-preview] command = "hugo --gc --minify --buildFuture -b $DEPLOY_PRIME_URL" [context.deploy-preview.environment] -HUGO_VERSION = "0.110.0" +HUGO_VERSION = "0.111.3" [context.branch-deploy] command = "hugo --gc --minify -b $DEPLOY_PRIME_URL" [context.branch-deploy.environment] -HUGO_VERSION = "0.110.0" +HUGO_VERSION = "0.111.3" [context.next.environment] HUGO_ENABLEGITINFO = "true" diff --git a/static/images/hosting-and-deployment/deployment-with-nanobox/hugo-server.png b/static/images/hosting-and-deployment/deployment-with-nanobox/hugo-server.png deleted file mode 100644 index cc909af2c..000000000 Binary files a/static/images/hosting-and-deployment/deployment-with-nanobox/hugo-server.png and /dev/null differ diff --git a/static/images/hosting-and-deployment/deployment-with-nanobox/hugo-with-nanobox.png b/static/images/hosting-and-deployment/deployment-with-nanobox/hugo-with-nanobox.png deleted file mode 100644 index 2cbc45e7e..000000000 Binary files a/static/images/hosting-and-deployment/deployment-with-nanobox/hugo-with-nanobox.png and /dev/null differ diff --git a/static/images/hosting-and-deployment/deployment-with-nanobox/nanobox-deploy-dry-run.png b/static/images/hosting-and-deployment/deployment-with-nanobox/nanobox-deploy-dry-run.png deleted file mode 100644 index 4dd7ebc9d..000000000 Binary files a/static/images/hosting-and-deployment/deployment-with-nanobox/nanobox-deploy-dry-run.png and /dev/null differ diff --git a/static/images/hosting-and-deployment/deployment-with-nanobox/nanobox-run.png b/static/images/hosting-and-deployment/deployment-with-nanobox/nanobox-run.png deleted file mode 100644 index 29a31e2c2..000000000 Binary files a/static/images/hosting-and-deployment/deployment-with-nanobox/nanobox-run.png and /dev/null differ diff --git a/static/images/hosting-and-deployment/deployment-with-wercker/adding-a-github-pages-step.png b/static/images/hosting-and-deployment/deployment-with-wercker/adding-a-github-pages-step.png deleted file mode 100644 index 19ec945cd..000000000 Binary files a/static/images/hosting-and-deployment/deployment-with-wercker/adding-a-github-pages-step.png and /dev/null differ diff --git a/static/images/hosting-and-deployment/deployment-with-wercker/adding-the-project-to-github.png b/static/images/hosting-and-deployment/deployment-with-wercker/adding-the-project-to-github.png deleted file mode 100644 index 785fc1290..000000000 Binary files a/static/images/hosting-and-deployment/deployment-with-wercker/adding-the-project-to-github.png and /dev/null differ diff --git a/static/images/hosting-and-deployment/deployment-with-wercker/and-we-ve-got-an-app.png b/static/images/hosting-and-deployment/deployment-with-wercker/and-we-ve-got-an-app.png deleted file mode 100644 index 98eecb299..000000000 Binary files a/static/images/hosting-and-deployment/deployment-with-wercker/and-we-ve-got-an-app.png and /dev/null differ diff --git a/static/images/hosting-and-deployment/deployment-with-wercker/configure-the-deploy-step.png b/static/images/hosting-and-deployment/deployment-with-wercker/configure-the-deploy-step.png deleted file mode 100644 index 26ec22370..000000000 Binary files a/static/images/hosting-and-deployment/deployment-with-wercker/configure-the-deploy-step.png and /dev/null differ diff --git a/static/images/hosting-and-deployment/deployment-with-wercker/creating-a-basic-hugo-site.png b/static/images/hosting-and-deployment/deployment-with-wercker/creating-a-basic-hugo-site.png deleted file mode 100644 index b9e53d0bc..000000000 Binary files a/static/images/hosting-and-deployment/deployment-with-wercker/creating-a-basic-hugo-site.png and /dev/null differ diff --git a/static/images/hosting-and-deployment/deployment-with-wercker/public-or-not.png b/static/images/hosting-and-deployment/deployment-with-wercker/public-or-not.png deleted file mode 100644 index 439b224e8..000000000 Binary files a/static/images/hosting-and-deployment/deployment-with-wercker/public-or-not.png and /dev/null differ diff --git a/static/images/hosting-and-deployment/deployment-with-wercker/using-hugo-build.png b/static/images/hosting-and-deployment/deployment-with-wercker/using-hugo-build.png deleted file mode 100644 index 754eab984..000000000 Binary files a/static/images/hosting-and-deployment/deployment-with-wercker/using-hugo-build.png and /dev/null differ diff --git a/static/images/hosting-and-deployment/deployment-with-wercker/wercker-access.png b/static/images/hosting-and-deployment/deployment-with-wercker/wercker-access.png deleted file mode 100644 index 170488456..000000000 Binary files a/static/images/hosting-and-deployment/deployment-with-wercker/wercker-access.png and /dev/null differ diff --git a/static/images/hosting-and-deployment/deployment-with-wercker/wercker-account-settings.png b/static/images/hosting-and-deployment/deployment-with-wercker/wercker-account-settings.png deleted file mode 100644 index d93505af7..000000000 Binary files a/static/images/hosting-and-deployment/deployment-with-wercker/wercker-account-settings.png and /dev/null differ diff --git a/static/images/hosting-and-deployment/deployment-with-wercker/wercker-add-app.png b/static/images/hosting-and-deployment/deployment-with-wercker/wercker-add-app.png deleted file mode 100644 index dc854b4da..000000000 Binary files a/static/images/hosting-and-deployment/deployment-with-wercker/wercker-add-app.png and /dev/null differ diff --git a/static/images/hosting-and-deployment/deployment-with-wercker/wercker-git-connections.png b/static/images/hosting-and-deployment/deployment-with-wercker/wercker-git-connections.png deleted file mode 100644 index 2359fb3b3..000000000 Binary files a/static/images/hosting-and-deployment/deployment-with-wercker/wercker-git-connections.png and /dev/null differ diff --git a/static/images/hosting-and-deployment/deployment-with-wercker/wercker-search.png b/static/images/hosting-and-deployment/deployment-with-wercker/wercker-search.png deleted file mode 100644 index 40abf82ad..000000000 Binary files a/static/images/hosting-and-deployment/deployment-with-wercker/wercker-search.png and /dev/null differ diff --git a/static/images/hosting-and-deployment/deployment-with-wercker/wercker-select-owner.png b/static/images/hosting-and-deployment/deployment-with-wercker/wercker-select-owner.png deleted file mode 100644 index d44a70de3..000000000 Binary files a/static/images/hosting-and-deployment/deployment-with-wercker/wercker-select-owner.png and /dev/null differ diff --git a/static/images/hosting-and-deployment/deployment-with-wercker/wercker-select-repository.png b/static/images/hosting-and-deployment/deployment-with-wercker/wercker-select-repository.png deleted file mode 100644 index 45c395f8d..000000000 Binary files a/static/images/hosting-and-deployment/deployment-with-wercker/wercker-select-repository.png and /dev/null differ diff --git a/static/images/hosting-and-deployment/deployment-with-wercker/wercker-sign-up-page.png b/static/images/hosting-and-deployment/deployment-with-wercker/wercker-sign-up-page.png deleted file mode 100644 index 41b82036f..000000000 Binary files a/static/images/hosting-and-deployment/deployment-with-wercker/wercker-sign-up-page.png and /dev/null differ diff --git a/static/images/hosting-and-deployment/deployment-with-wercker/wercker-sign-up.png b/static/images/hosting-and-deployment/deployment-with-wercker/wercker-sign-up.png deleted file mode 100644 index c2de857a3..000000000 Binary files a/static/images/hosting-and-deployment/deployment-with-wercker/wercker-sign-up.png and /dev/null differ diff --git a/static/images/hosting-and-deployment/deployment-with-wercker/werckeryml.png b/static/images/hosting-and-deployment/deployment-with-wercker/werckeryml.png deleted file mode 100644 index ee6054dda..000000000 Binary files a/static/images/hosting-and-deployment/deployment-with-wercker/werckeryml.png and /dev/null differ