diff --git a/.cspell.json b/.cspell.json index e9b15cc918a..ae469d64611 100644 --- a/.cspell.json +++ b/.cspell.json @@ -116,14 +116,18 @@ "dring", "getenv", "gohugo", + "inor", "jdoe", "milli", "rgba", "rsmith", "stringifier", "struct", + "tdewolff", "tjones", "toclevels", - "vals" + "vals", + "xfeff", + "zgotmplz" ] } diff --git a/content/en/templates/template-debugging.md b/content/en/templates/template-debugging.md deleted file mode 100644 index fd400018b2f..00000000000 --- a/content/en/templates/template-debugging.md +++ /dev/null @@ -1,72 +0,0 @@ ---- -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. -categories: [templates] -keywords: [debugging,troubleshooting] -menu: - docs: - parent: templates - weight: 240 -weight: 240 ---- - -Here are some snippets you can add to your template to answer some common questions. - -These snippets use the `printf` function available in all Go templates. This function is an alias to the Go function, [fmt.Printf](https://pkg.go.dev/fmt). - -## What variables are available in this context? - -You can use the template syntax, `$.`, to get the top-level template context from anywhere in your template. This will print out all the values under, `.Site`. - -```go-html-template -{{ printf "%#v" $.Site }} -``` - -This will print out the value of `.Permalink`: - -```go-html-template -{{ printf "%#v" .Permalink }} -``` - -This will print out a list of all the variables scoped to the current context -(`.`, aka ["the dot"][tempintro]). - -```go-html-template -{{ printf "%#v" . }} -``` - -When developing a [homepage], what does one of the pages you're looping through look like? - -```go-html-template -{{ range .Pages }} - {{/* The context, ".", is now each one of the pages as it goes through the loop */}} - {{ printf "%#v" . }} -{{ end }} -``` - -In some cases it might be more helpful to use the following snippet on the current context to get a pretty printed view of what you're able to work with: - -```go-html-template -
{{ . | jsonify (dict "indent" " ") }}
-``` - -Note that Hugo will throw an error if you attempt to use this construct to display context that includes a page collection (e.g., the context passed to home, section, taxonomy, and term templates). - -## Why am I showing no defined variables? - -Check that you are passing variables in the `partial` function: - -```go-html-template -{{ partial "header.html" }} -``` - -This example will render the header partial, but the header partial will not have access to any contextual variables. You need to pass variables explicitly. For example, note the addition of ["the dot"][tempintro]. - -```go-html-template -{{ partial "header.html" . }} -``` - -The dot (`.`) is considered fundamental to understanding Hugo templating. For more information, see [Introduction to Hugo Templating][tempintro]. - -[homepage]: /templates/homepage/ -[tempintro]: /templates/introduction/ diff --git a/content/en/troubleshooting/_index.md b/content/en/troubleshooting/_index.md index 49c7f7e61a0..f777d51ec6c 100644 --- a/content/en/troubleshooting/_index.md +++ b/content/en/troubleshooting/_index.md @@ -1,7 +1,7 @@ --- -title: Troubleshoot +title: Troubleshooting linkTitle: Overview -description: Frequently asked questions and known issues pulled from the Hugo Discuss forum. +description: Use these techniques when troubleshooting your site. categories: [] keywords: [] menu: @@ -10,9 +10,6 @@ menu: parent: troubleshooting weight: 10 weight: 10 -aliases: [/troubleshooting/faqs/,/faqs/] --- -The Troubleshooting section includes known issues, recent workarounds, and FAQs pulled from the [Hugo Discussion Forum][forum]. - -[forum]: https://discourse.gohugo.io +Use these techniques when troubleshooting your site. diff --git a/content/en/troubleshooting/audit/index.md b/content/en/troubleshooting/audit/index.md new file mode 100644 index 00000000000..28db344ea0d --- /dev/null +++ b/content/en/troubleshooting/audit/index.md @@ -0,0 +1,73 @@ +--- +title: Site audit +linkTitle: Audit +description: Run this audit before deploying your production site. +categories: [troubleshooting] +keywords: [] +menu: + docs: + parent: troubleshooting + weight: 20 +weight: 20 +--- + +There are several conditions that can produce errors in your published site which are not detected during the build. Run this audit before your final build. + +{{< code copy=true >}} +HUGO_MINIFY_TDEWOLFF_HTML_KEEPCOMMENTS=true HUGO_ENABLEMISSINGTRANSLATIONPLACEHOLDERS=true hugo && grep -inorE "<\!-- raw HTML omitted -->|ZgotmplZ|\[i18n\]|\(\)|(<nil>)|hahahugo" public/ +{{< /code >}} + +_Tested with GNU Bash 5.1 and GNU grep 3.7._ + +## Example output + +![site audit terminal output](screen-capture.png) + +## Explanation + +### Environment variables + +`HUGO_MINIFY_TDEWOLFF_HTML_KEEPCOMMENTS=true` +: Retain HTML comments even if minification is enabled. This takes precedence over `minify.tdewolff.html.keepComments` in the site configuration. If you minify without keeping HTML comments when performing this audit, you will not be able to detect when raw HTML has been omitted. + +`HUGO_ENABLEMISSINGTRANSLATIONPLACEHOLDERS=true` +: Show a placeholder instead of the default value or an empty string if a translation is missing. This takes precedence over `enableMissingTranslationPlaceholders` in the site configuration. + +### Grep options + +`-i, --ignore-case` +: Ignore case distinctions in patterns and input data, so that characters that differ only in case match each other. + +`-n, --line-number` +: Prefix each line of output with the 1-based line number within its input file. + +`-o, --only-matching` +: Print only the matched (non-empty) parts of a matching line, with each such part on a separate output line. + +`-r, --recursive` +: Read all files under each directory, recursively, following symbolic links only if they are on the command line. + +`-E, --extended-regexp` +: Interpret PATTERNS as extended regular expressions. + +### Patterns + +`` +: By default, Hugo strips raw HTML from your markdown prior to rendering, and leaves this HTML comment in its place. + +`ZgotmplZ` +: ZgotmplZ is a special value that indicates that unsafe content reached a CSS or URL context at runtime. For more information see. See [details]. + +[details]: https://pkg.go.dev/html/template + +`[i18n]` +: This is the placeholder produced instead of the default value or an empty string if a translation is missing. + +`()` +: This string will appear in the rendered HTML when passing a nil value to the `printf` function. + +`(<nil>)` +: Same as above when the value returned from the `printf` function has not been passed through `safeHTML`. + +`HAHAHUGO` +: Under certain conditions a rendered shortcode may include all or a portion of the string HAHAHUGOSHORTCODE in either uppercase or lowercase. This is difficult to detect in all circumstances because, but a case-insensitive search of the output for `HAHAHUGO` is likely to catch the majority of cases without producing false positives. diff --git a/content/en/troubleshooting/audit/screen-capture.png b/content/en/troubleshooting/audit/screen-capture.png new file mode 100644 index 00000000000..221abfff078 Binary files /dev/null and b/content/en/troubleshooting/audit/screen-capture.png differ diff --git a/content/en/troubleshooting/build-performance.md b/content/en/troubleshooting/build-performance.md deleted file mode 100644 index abbd61a0bb7..00000000000 --- a/content/en/troubleshooting/build-performance.md +++ /dev/null @@ -1,90 +0,0 @@ ---- -title: Build performance -description: An overview of features used for diagnosing and improving performance issues in site builds. -categories: [troubleshooting] -keywords: [] -menu: - docs: - parent: troubleshooting - weight: 30 -weight: 30 -toc: true ---- - -## Template metrics - -Hugo is a very fast static site generator, but it is possible to write -inefficient templates. Hugo's _template metrics_ feature is extremely helpful -in pinpointing which templates are executed most often and how long those -executions take **in terms of CPU time**. - -| Metric Name | Description | -| ------------------- | -------------------------------------------------------------- | -| cumulative duration | The cumulative time spent executing a given template. | -| average duration | The average time spent executing a given template. | -| maximum duration | The maximum time a single execution took for a given template. | -| count | The number of times a template was executed. | -| template | The template name. | - -```txt -▶ hugo --templateMetrics -Started building sites ... - -Built site for language en: -0 draft content -0 future content -0 expired content -2 regular pages created -22 other pages created -0 non-page files copied -0 paginator pages created -4 tags created -3 categories created -total in 18 ms - -Template Metrics: - - cumulative average maximum - duration duration duration count template - ---------- -------- -------- ----- -------- - 6.419663ms 583.605µs 994.374µs 11 _internal/_default/rss.xml - 4.718511ms 1.572837ms 3.880742ms 3 indexes/category.html - 4.642666ms 2.321333ms 3.282842ms 2 posts/single.html - 4.364445ms 396.767µs 2.451372ms 11 partials/header.html - 2.346069ms 586.517µs 903.343µs 4 indexes/tag.html - 2.330919ms 211.901µs 2.281342ms 11 partials/header.includes.html - 1.238976ms 103.248µs 446.084µs 12 posts/li.html - 972.16µs 972.16µs 972.16µs 1 _internal/_default/sitemap.xml - 953.597µs 953.597µs 953.597µs 1 index.html - 822.263µs 822.263µs 822.263µs 1 indexes/post.html - 567.498µs 51.59µs 112.205µs 11 partials/navbar.html - 348.22µs 31.656µs 88.249µs 11 partials/meta.html - 346.782µs 173.391µs 276.176µs 2 posts/summary.html - 235.184µs 21.38µs 124.383µs 11 partials/footer.copyright.html - 132.003µs 12µs 117.999µs 11 partials/menu.html - 72.547µs 6.595µs 63.764µs 11 partials/footer.html -``` - -{{% note %}} -**A note about parallelism** - -Hugo builds pages in parallel where multiple pages are generated -simultaneously. Because of this parallelism, the sum of "cumulative duration" -values is usually greater than the actual time it takes to build a site. -{{% /note %}} - -## Cached partials - -Some `partial` templates such as sidebars or menus are executed many times -during a site build. Depending on the content within the `partial` template and -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. - -{{% 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. -{{% /note %}} - -[partialCached]: /functions/partials/includecached diff --git a/content/en/troubleshooting/deprecation.md b/content/en/troubleshooting/deprecation.md new file mode 100644 index 00000000000..79ddcc03f69 --- /dev/null +++ b/content/en/troubleshooting/deprecation.md @@ -0,0 +1,51 @@ +--- +title: Deprecation +description: The Hugo project follows a formal and consistent process to deprecate functions, methods, and configuration settings. +categories: [troubleshooting] +keywords: [] +menu: + docs: + parent: troubleshooting + weight: 50 +weight: 50 +--- + +When a project _deprecates_ something, they are telling its users: + +1. Don't use Thing One anymore. +2. Use Thing Two instead. +3. We're going to remove Thing One at some point in the future. + +[article]: https://en.wikipedia.org/wiki/Deprecation + +Think of deprecation as a statement of intent. This Wikipedia [article] describes common reasons for deprecation: + +- The feature has been replaced by a more powerful alternative. +- The feature contains a design flaw. +- The feature is considered extraneous, and will be removed in the future in order to simplify the system as a whole. +- A future version of the software will make major structural changes, making it impossible or impractical to support older features. +- Standardization or increased consistency in naming. +- A feature that once was available only independently is now combined with its co-feature. + + +After the project team deprecates something in code, Hugo will: + +1. Log an INFO message for 6 minor releases[^1] +2. Log a WARN message for another 6 minor releases +3. Log an ERROR message and fail the build thereafter + +To see the INFO messages, you must use the `--logLevel` command line flag: + +```text +hugo --logLevel info +``` + +To limit the output to deprecation notices: + +```text +hugo --logLevel info | grep deprecate +``` + +Run the above command every time you upgrade Hugo. + +[^1]: For example, v0.1.1 => v0.2.0 is a minor release. diff --git a/content/en/troubleshooting/faq.md b/content/en/troubleshooting/faq.md deleted file mode 100644 index 736ed5e4315..00000000000 --- a/content/en/troubleshooting/faq.md +++ /dev/null @@ -1,62 +0,0 @@ ---- -title: Frequently asked questions -linkTitle: Frequently asked questions -description: Solutions to some common Hugo problems. -categories: [troubleshooting] -keywords: [faqs] -menu: - docs: - parent: troubleshooting - weight: 20 -weight: 20 -toc: true -aliases: [/faq/] ---- - -{{% note %}} -The answers/solutions presented below are short, and may not be enough to solve your problem. Visit [Hugo Discourse](https://discourse.gohugo.io/) and use the search. It that does not help, start a new topic and ask your questions. -{{% /note %}} - -## I can't see my content - -Is your Markdown file [in draft mode](/content-management/front-matter/#front-matter-variables)? When testing, run `hugo server` with the `-D` or `--buildDrafts` [switch](/getting-started/usage/#draft-future-and-expired-content). - -Is your Markdown file part of a [leaf bundle](/content-management/page-bundles/)? If there is an `index.md` file in the same or any parent directory then other Markdown files will not be rendered as individual pages. - -## Can I set configuration variables via OS environment? - -Yes you can! See [Configure with Environment Variables](/getting-started/configuration/#configure-with-environment-variables). - -## How do I schedule posts? - -1. Set `publishDate` in the page [front matter](/content-management/front-matter/) to a datetime in the future. If you want the creation and publication datetime to be the same, it's also sufficient to only set `date`[^date-hierarchy]. -2. Build and publish at intervals. - -How to automate the "publish at intervals" part depends on your situation: - -* If you deploy from your own PC/server, you can automate with [Cron](https://en.wikipedia.org/wiki/Cron) or similar. -* If your site is hosted on a service similar to [Netlify](https://www.netlify.com/) you can: - * Use a service such as [ifttt](https://ifttt.com/date_and_time) to schedule the updates; or - * Set up a deploy hook which you can run with a cron service to deploy your site at intervals, such as [cron-job.org](https://cron-job.org/) (both Netlify and Cloudflare Pages support deploy hooks) - -Also see this Twitter thread: - -{{< tweet user="ChrisShort" id="962380712027590657" >}} - -[^date-hierarchy]: See [Configure Dates](/getting-started/configuration/#configure-dates) for the order in which the different date variables are complemented by each other when not explicitly set. - -## Can I use the latest Hugo version on Netlify? - -[Yes you can](/hosting-and-deployment/hosting-on-netlify/#configure-hugo-version-in-netlify)!. - -## I get "... this feature is not available in your current Hugo version" - -If you process `SCSS` or `Sass` to `CSS` in your Hugo project with `libsass` as the transpiler or if you convert images to the `webp` format, you need the Hugo `extended` version, or else you may see an error message similar to the below: - -```sh -error: failed to transform resource: TOCSS: failed to transform "scss/main.scss" (text/x-scss): this feature is not available in your current Hugo version -``` - -We release two set of binaries for technical reasons. The extended version is not what you get by default for some installation methods. On the [release page](https://github.com/gohugoio/hugo/releases), look for archives with `extended` in the name. To build `hugo-extended`, use `go install --tags extended` - -To confirm, run `hugo version` and look for the word `extended`. diff --git a/content/en/troubleshooting/faqs.md b/content/en/troubleshooting/faqs.md new file mode 100644 index 00000000000..772569f5165 --- /dev/null +++ b/content/en/troubleshooting/faqs.md @@ -0,0 +1,85 @@ +--- +title: Frequently asked questions +linkTitle: FAQs +description: These questions are frequently asked by new users. +categories: [troubleshooting] +keywords: [faq] +menu: + docs: + parent: troubleshooting + weight: 70 +weight: 70 +--- + +Hugo’s [forum] is an active community of users and developers who answer questions, share knowledge, and provide examples. A quick search of over 20,000 topics will often answer your question. Please be sure to read about [requesting help] before asking your first question. + +These are just a few of the questions most frequently asked by new users. + +Why do I see "Page Not Found" when visiting the home page? +: In the content/_index.md file: + + - Is `draft` set to `true`? + - Is the `date` in the future? + - Is the `publishDate` in the future? + - Is the `expiryDate` in the past? + +: If the answer to any of these questions is yes, either change the field values, or use one of these command line flags: `--buildDrafts`, `--buildFuture`, or `--buildExpired`. + +Why is a given section not published? +: In the content/section/_index.md file: + + - Is `draft` set to `true`? + - Is the `date` in the future? + - Is the `publishDate` in the future? + - Is the `expiryDate` in the past? + +: If the answer to any of these questions is yes, either change the field values, or use one of these command line flags: `--buildDrafts`, `--buildFuture`, or `--buildExpired`. + +Why is a given page not published? +: In the content/section/page.md file, or in the content/section/page/index.md file: + + - Is `draft` set to `true`? + - Is the `date` in the future? + - Is the `publishDate` in the future? + - Is the `expiryDate` in the past? + +: If the answer to any of these questions is yes, either change the field values, or use one of these command line flags: `--buildDrafts`, `--buildFuture`, or `--buildExpired`. + +Why can't I see any of a page's descendants? +: You may have an index.md file (leaf bundle) instead of an _index.md file (branch bundle). See [details](/content-management/page-bundles/). + +Why is my partial template not rendering as expected? +: You may have neglected to pass the required [context] when calling the partial. For example: + +```go-html-template +{{/* incorrect */}} +{{ partial "_internal/pagination.html" }} + +{{/* correct */}} +{{ partial "_internal/pagination.html" . }} +``` + +In a template, what's the difference between `:=` and `=` when assigning values to variables? +: Use `:=` to initialize a variable, and use `=` to assign a value to a variable that has been previously initialized. See [details](https://pkg.go.dev/text/template#hdr-Variables). + +When I paginate a list page, why is the page collection not filtered as specified? +: You are probably invoking the [`Paginate`] or [`Paginator`] method more than once on the same page. See [details](/templates/pagination/#list-paginator-pages). + +Can I use environment variables to control configuration? +: Yes. See [details](/getting-started/configuration/#configure-with-environment-variables). + +Why am I seeing inconsistent output from one build to the next? +: The most common causes are page collisions (publishing two pages to the same path) and the effects of concurrency. Use the `--printPathWarnings` command line flag to check for page collisions, and create a topic on the [forum] if you suspect concurrency problems. + +{{% note %}} +For other questions please visit the [forum]. A quick search of over 20,000 topics will often answer your question. Please be sure to read about [requesting help] before asking your first question. + +[forum]: https://discourse.gohugo.io +[requesting help]: https://discourse.gohugo.io/t/requesting-help/9132 +{{% /note %}} + +[`Paginate`]: /methods/page/paginate +[`Paginator`]: /methods/page/paginator +[context]: /getting-started/glossary/#context +[forum]: https://discourse.gohugo.io +[requesting help]: https://discourse.gohugo.io/t/requesting-help/9132 diff --git a/content/en/troubleshooting/inspection.md b/content/en/troubleshooting/inspection.md new file mode 100644 index 00000000000..82622915361 --- /dev/null +++ b/content/en/troubleshooting/inspection.md @@ -0,0 +1,72 @@ +--- +title: Data inspection +linkTitle: Inspection +description: Use template functions to inspect values and data structures. +categories: [troubleshooting] +keywords: [] +menu: + docs: + parent: troubleshooting + weight: 40 +weight: 40 +--- + +Use the [`jsonify`] function to inspect a data structure: + +```go-html-template +
{{ jsonify (dict "indent" "  ") .Params }}
+``` + +```text +{ + "date": "2023-11-10T15:10:42-08:00", + "draft": false, + "iscjklanguage": false, + "lastmod": "2023-11-10T15:10:42-08:00", + "publishdate": "2023-11-10T15:10:42-08:00", + "tags": [ + "foo", + "bar" + ], + "title": "My first post" +} +``` + +{{% note %}} +Hugo will throw an error if you attempt to use the construct above to display context that includes a page collection. For example, in a home page template, this will fail: + +`{{ jsonify (dict "indent" " ") . }}` +{{% /note %}} + +Use the [`debug.Dump`] function to inspect data types: + +```go-html-template +
{{ debug.Dump .Params }}
+``` + +```text +maps.Params{ + "date": time.Time{}, + "draft": false, + "iscjklanguage": false, + "lastmod": time.Time{}, + "publishdate": time.Time{}, + "tags": []string{ + "foo", + "bar", + }, + "title": "My first post", +} +``` + +Use the [`printf`] function (render) or [`warnf`] function (log to console) to inspect simple data structures. The layout string below displays both value and data type. + +```go-html-template +{{ $value := 42 }} +{{ printf "%[1]v (%[1]T)" $value }} → 42 (int) +``` + +[`jsonify`]: /functions/encoding/jsonify +[`debug.Dump`]: /functions/debug/dump +[`printf`]: /functions/fmt/printf +[`warnf`]: /functions/fmt/warnf diff --git a/content/en/troubleshooting/logging.md b/content/en/troubleshooting/logging.md new file mode 100644 index 00000000000..8879c18463c --- /dev/null +++ b/content/en/troubleshooting/logging.md @@ -0,0 +1,56 @@ +--- +title: Logging +description: Enable logging to inspect events while building your site. +categories: [troubleshooting] +keywords: [] +menu: + docs: + parent: troubleshooting + weight: 30 +weight: 30 +toc: true +--- + +## Command line + +Enable console logging with the `--logLevel` command line flag. + +Hugo has four logging levels: + +error +: Display error messages only. + +```sh +hugo --logLevel error +``` + +warn +: Display warning and error messages. + +```sh +hugo --logLevel warn +``` + +info +: Display information, warning, and error messages. + +```sh +hugo --logLevel info +``` + +debug +: Display debug, information, warning, and error messages. + +```sh +hugo --logLevel debug +``` + +{{% note %}} +If you do not specify a logging level with the `--logLevel` flag, warnings and errors are always displayed. +{{% /note %}} + +## Template functions + +You can also use template functions to print warnings or errors to the console. These functions are typically used to report data validation errors, missing files, etc. + +{{< list-pages-in-section path=/functions/fmt filter=functions_fmt_logging filterType=include >}} diff --git a/content/en/troubleshooting/performance.md b/content/en/troubleshooting/performance.md new file mode 100644 index 00000000000..c918b28c8b3 --- /dev/null +++ b/content/en/troubleshooting/performance.md @@ -0,0 +1,93 @@ +--- +title: Performance +description: Use template metrics and timers to identify opportunities to improve performance. +categories: [troubleshooting] +keywords: [] +menu: + docs: + parent: troubleshooting + weight: 60 +weight: 60 +toc: true +--- + +## Template metrics + +Hugo is fast, but inefficient templates impede performance. Enable template metrics to determine which templates take the most time, and to identify caching opportunties: + +```sh +hugo --templateMetrics --templateMetricsHints +``` + +The result will look something like this: + +```text +Template Metrics: + + cumulative average maximum cache percent cached total + duration duration duration potential cached count count template + ---------- -------- -------- --------- ------- ------ ----- -------- + 36.037476822s 135.990478ms 225.765245ms 11 0 0 265 partials/head.html + 35.920040902s 164.018451ms 233.475072ms 0 0 0 219 articles/single.html + 34.163268129s 128.917992ms 224.816751ms 23 0 0 265 partials/head/meta/opengraph.html + 1.041227437s 3.92916ms 186.303376ms 47 0 0 265 partials/head/meta/schema.html + 805.628827ms 27.780304ms 114.678523ms 0 0 0 29 _default/list.html + 624.08354ms 15.221549ms 108.420729ms 8 0 0 41 partials/utilities/render-page-collection.html + 545.968801ms 775.523µs 105.045775ms 0 0 0 704 _default/summary.html + 334.680981ms 1.262947ms 127.412027ms 100 0 0 265 partials/head/js.html + 272.763205ms 2.050851ms 24.371757ms 0 0 0 133 _default/_markup/render-codeblock.html + 230.490038ms 8.865001ms 177.4615ms 0 0 0 26 shortcodes/template.html + 176.921913ms 176.921913ms 176.921913ms 0 0 0 1 examples.tmpl + 163.951469ms 14.904679ms 70.267953ms 0 0 0 11 articles/list.html + 153.07021ms 577.623µs 73.593597ms 100 0 0 265 partials/head/init.html + 150.910984ms 150.910984ms 150.910984ms 0 0 0 1 _default/single.html + 146.785804ms 146.785804ms 146.785804ms 0 0 0 1 _default/contact.html + 115.364617ms 115.364617ms 115.364617ms 0 0 0 1 authors/term.html + 87.392071ms 329.781µs 10.687132ms 100 0 0 265 partials/head/css.html + 86.803122ms 86.803122ms 86.803122ms 0 0 0 1 _default/home.html +``` + +From left to right, the columns represent: + +cumulative duration +: The cumulative time spent executing the template. + +average duration +: The average time spent executing the template. + +maximum duration +: The maximum time spent executing the template. + +cache potential +: Displayed as a percentage, any partial template with a 100% cache potential should be called with the [`partialCached`] function instead of the [`partial`] function. See the [caching](#caching) section below. + +percent cached +: The number of times the rendered templated was cached divided by the number of times the template was executed. + +cached count +: The number of times the rendered templated was cached. + +total count +: The number of times the template was executed. + +template +: The path to the template, relative to the layouts directory. + +[`partial`]: /functions/partials/include +[`partialCached`]: /functions/partials/includecached + +{{% note %}} +Hugo builds pages in parallel where multiple pages are generated simultaneously. Because of this parallelism, the sum of "cumulative duration" values is usually greater than the actual time it takes to build a site. +{{% /note %}} + +## Caching + +Some partial templates such as sidebars or menus are executed many times during a site build. Depending on the content within the partial template and the desired output, the template may benefit from caching to reduce the number of executions. The [`partialCached`] template function provides caching capabilities for partial templates. + +{{% 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. +{{% /note %}} + +## Timers + +Use the `debug.Timer` function to determine execution time for a block of code, useful for finding performance bottle necks in templates. See [details](/functions/debug/timer/). diff --git a/data/page_filters.yaml b/data/page_filters.yaml index 673b762fa26..2a3a8625d5f 100644 --- a/data/page_filters.yaml +++ b/data/page_filters.yaml @@ -8,6 +8,10 @@ # # {{< list-pages-in-section path=/functions/images filter=functions_images_no_filters filterType=exclude >}} +functions_fmt_logging: + - /functions/fmt/errorf + - /functions/fmt/erroridf + - /functions/fmt/warnf functions_images_no_filters: - /functions/images/filter - /functions/images/config