Debian Codegraph @

docs/content/en/troubleshooting/audit/index.md

raw
1 ---
2 title: Site audit
3 linkTitle: Audit
4 description: Run this audit before deploying your production site.
5 categories: []
6 keywords: []
7 ---
8
9 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.
10
11 ```sh {copy=true}
12 HUGO_MINIFY_TDEWOLFF_HTML_KEEPCOMMENTS=true HUGO_ENABLEMISSINGTRANSLATIONPLACEHOLDERS=true hugo && grep -inorE "<\!-- raw HTML omitted -->|ZgotmplZ|\[i18n\]|\(<nil>\)|(&lt;nil&gt;)|hahahugo" public/
13 ```
14
15 _Tested with GNU Bash 5.1 and GNU grep 3.7._
16
17 ## Example output
18
19 ![site audit terminal output](screen-capture.png)
20
21 ## Explanation
22
23 The command above uses these environment variables, `grep` options, and patterns.
24
25 ### Environment variables
26
27 `HUGO_MINIFY_TDEWOLFF_HTML_KEEPCOMMENTS=true`
28 : Retain HTML comments even if minification is enabled. This takes precedence over `minify.tdewolff.html.keepComments` in your project 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.
29
30 `HUGO_ENABLEMISSINGTRANSLATIONPLACEHOLDERS=true`
31 : Show a placeholder instead of the default value or an empty string if a translation is missing. This takes precedence over `enableMissingTranslationPlaceholders` in your project configuration.
32
33 ### Grep options
34
35 `-i, --ignore-case`
36 : Ignore case distinctions in patterns and input data, so that characters that differ only in case match each other.
37
38 `-n, --line-number`
39 : Prefix each line of output with the 1-based line number within its input file.
40
41 `-o, --only-matching`
42 : Print only the matched (non-empty) parts of a matching line, with each such part on a separate output line.
43
44 `-r, --recursive`
45 : Read all files under each directory, recursively, following symbolic links only if they are on the command line.
46
47 `-E, --extended-regexp`
48 : Interpret PATTERNS as extended regular expressions.
49
50 ### Patterns
51
52 `<!-- raw HTML omitted -->`
53 : By default, Hugo strips raw HTML from your Markdown prior to rendering, and leaves this HTML comment in its place.
54
55 `ZgotmplZ`
56 : ZgotmplZ is a special value that indicates that unsafe content reached a CSS or URL context at runtime. See [details][].
57
58 `[i18n]`
59 : This is the placeholder produced instead of the default value or an empty string if a translation is missing.
60
61 `(<nil>)`
62 : This string will appear in the rendered HTML when passing a `nil` value to the `printf` function.
63
64 `(&lt;nil&gt;)`
65 : Same as above when the value returned from the `printf` function has not been passed through the [`safe.HTML`][] function.
66
67 `HAHAHUGO`
68 : Under certain conditions a rendered shortcode may include all or a portion of the string H&#xfeff;AHAHUGOSHORTCODE in either uppercase or lowercase. This is difficult to detect in all circumstances, but a case-insensitive search of the output for `HAHAHUGO` is likely to catch the majority of cases without producing false positives.
69
70 [`safe.HTML`]: /functions/safe/html/
71 [details]: https://pkg.go.dev/html/template