| 1 |
--- |
| 2 |
title: Frequently asked questions |
| 3 |
linkTitle: FAQs |
| 4 |
description: These questions are frequently asked by new users. |
| 5 |
categories: [] |
| 6 |
keywords: [] |
| 7 |
--- |
| 8 |
|
| 9 |
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. |
| 10 |
|
| 11 |
These are just a few of the questions most frequently asked by new users. |
| 12 |
|
| 13 |
An error message indicates that a feature is not available. Why? |
| 14 |
: When you attempt to use a feature that is not available in the edition that you installed, Hugo throws this error: |
| 15 |
|
| 16 |
```go-html-template |
| 17 |
this feature is not available in this edition of Hugo |
| 18 |
``` |
| 19 |
|
| 20 |
To resolve, install a different edition. See the [installation][] section for details. |
| 21 |
|
| 22 |
Why do I see "Page Not Found" when visiting the home page? |
| 23 |
: In the `content/_index.md` file: |
| 24 |
|
| 25 |
- Is `draft` set to `true`? |
| 26 |
- Is the `date` in the future? |
| 27 |
- Is the `publishDate` in the future? |
| 28 |
- Is the `expiryDate` in the past? |
| 29 |
|
| 30 |
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`. |
| 31 |
|
| 32 |
Why is a given page not published? |
| 33 |
: In the `content/section/page.md` file, or in the `content/section/page/index.md` file: |
| 34 |
|
| 35 |
- Is `draft` set to `true`? |
| 36 |
- Is the `date` in the future? |
| 37 |
- Is the `publishDate` in the future? |
| 38 |
- Is the `expiryDate` in the past? |
| 39 |
|
| 40 |
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`. |
| 41 |
|
| 42 |
Why can't I see any of a page's descendants? |
| 43 |
: You may have an `index.md` file instead of an `_index.md` file. See [details][page bundles]. |
| 44 |
|
| 45 |
What is the difference between an `index.md` file and an `_index.md` file? |
| 46 |
: A directory with an `index.md file` is a [leaf bundle](g). A directory with an `_index.md` file is a [branch bundle](g). See [details][page bundles]. |
| 47 |
|
| 48 |
Why is my _partial_ template not rendered as expected? |
| 49 |
: You may have neglected to pass the required [context](g) when calling the _partial_ template. For example: |
| 50 |
|
| 51 |
```go-html-template |
| 52 |
{{/* incorrect */}} |
| 53 |
{{ partial "pagination.html" }} |
| 54 |
|
| 55 |
{{/* correct */}} |
| 56 |
{{ partial "pagination.html" . }} |
| 57 |
``` |
| 58 |
|
| 59 |
In a template, what's the difference between `:=` and `=` when assigning values to variables? |
| 60 |
: Use `:=` to initialize a variable, and use `=` to assign a value to a variable that has been previously initialized. See [details][variables]. |
| 61 |
|
| 62 |
When I paginate a list page, why is the page collection not filtered as specified? |
| 63 |
: You are probably invoking the [`Paginate`][] or [`Paginator`][] method more than once on the same page. See [details][pagination]. |
| 64 |
|
| 65 |
Why are there two ways to call a shortcode? |
| 66 |
: Use the `{{%/* shortcode */%}}` notation if the _shortcode_ template, or the content between the opening and closing shortcode tags, contains Markdown. Otherwise use the\ |
| 67 |
`{{</* shortcode */>}}` notation. See [details][notation]. |
| 68 |
|
| 69 |
Can I use environment variables to control configuration? |
| 70 |
: Yes. See [details][environment-variables]. |
| 71 |
|
| 72 |
Why am I seeing inconsistent output from one build to the next? |
| 73 |
: 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. |
| 74 |
|
| 75 |
Why isn't Hugo's development server detecting file changes? |
| 76 |
: In its default configuration, Hugo's file watcher may not be able detect file changes when: |
| 77 |
|
| 78 |
- Running Hugo within Windows Subsystem for Linux (WSL/WSL2) with project files on a Windows partition |
| 79 |
- Running Hugo locally with project files on a removable drive |
| 80 |
- Running Hugo locally with project files on a storage server accessed via the NFS, SMB, or CIFS protocols |
| 81 |
|
| 82 |
In these cases, instead of monitoring native file system events, use the `--poll` command line flag. For example, to poll the project files every 700 milliseconds, use `--poll 700ms`. |
| 83 |
|
| 84 |
Why is my page Store missing a value? |
| 85 |
: The [`Store`][] method on a `Page` object creates a persistent data structure for storing and manipulating keyed values on the given page. Values are often set within a _shortcode_ template, a _partial_ template called by a _shortcode_ template, or by a _render hook_ template. In all three cases, the stored values are not determinate until Hugo renders the page content. |
| 86 |
|
| 87 |
If you need to access a stored value from a parent template, and the parent template has not yet rendered the page content, you can trigger content rendering by assigning the returned value to a [noop](g) variable: |
| 88 |
|
| 89 |
```go-html-template |
| 90 |
{{ $noop := .Content }} |
| 91 |
{{ .Store.Get "mykey" }} |
| 92 |
``` |
| 93 |
|
| 94 |
You can trigger content rendering with other methods as well. See next FAQ. |
| 95 |
|
| 96 |
Which page methods trigger content rendering? |
| 97 |
: The following methods on a `Page` object trigger content rendering: `Content`, `ContentWithoutSummary`, `FuzzyWordCount`, `Len`, `Plain`, `PlainWords`, `ReadingTime`, `Summary`, `Truncated`, and `WordCount`. |
| 98 |
|
| 99 |
> [!NOTE] |
| 100 |
> 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. |
| 101 |
|
| 102 |
[`Paginate`]: /methods/page/paginate/ |
| 103 |
[`Paginator`]: /methods/page/paginator/ |
| 104 |
[`Store`]: /methods/page/store/ |
| 105 |
[environment-variables]: /configuration/introduction/#environment-variables |
| 106 |
[forum]: https://discourse.gohugo.io |
| 107 |
[installation]: /installation/ |
| 108 |
[notation]: /content-management/shortcodes/#notation |
| 109 |
[page bundles]: /content-management/page-bundles/ |
| 110 |
[pagination]: /templates/pagination/ |
| 111 |
[requesting help]: https://discourse.gohugo.io/t/requesting-help/9132 |
| 112 |
[variables]: https://pkg.go.dev/text/template#hdr-Variables |