Merge commit '35dec7c96f7ee3eb17dd444f7067f0c776fb56ae'

This commit is contained in:
Bjørn Erik Pedersen
2023-12-04 15:24:01 +01:00
810 changed files with 24147 additions and 7766 deletions

View File

@@ -1,62 +1,124 @@
---
title: Frequently asked questions
linkTitle: Frequently asked questions
description: Solutions to some common Hugo problems.
linkTitle: FAQs
description: These questions are frequently asked by new users.
categories: [troubleshooting]
keywords: [faq]
menu:
docs:
parent: troubleshooting
weight: 20
weight: 20
keywords: [faqs]
toc: true
aliases: [/faq/]
weight: 70
weight: 70
# Use level 6 headings for each question.
---
{{% note %}}
**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 %}}
Hugos [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.
## I can't see my content
These are just a few of the questions most frequently asked by new users.
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).
###### An error message indicates that a feature is not available. Why?
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.
Hugo is available in two editions: standard and extended. With the extended edition you can (a) encode to the WebP format when processing images, and (b) transpile Sass to CSS using the embedded LibSass transpiler. The extended edition is not required to use the Dart Sass transpiler.
## Can I set configuration variables via OS environment?
When you attempt to perform either of the operations above with the standard edition, Hugo throws this error:
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:
```bash
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
```go-html-template
Error: 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 resolve, uninstall the standard edition, then install the extended edition. See the [installation] section for details.
To confirm, run `hugo version` and look for the word `extended`.
###### 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 instead of an _index.md file. See&nbsp;[details](/content-management/page-bundles/).
###### What is the difference between an index.md file and an _index.md file?
A directory with an index.md file is a [leaf bundle]. A directory with an _index.md file is a [branch bundle]. See&nbsp;[details](/content-management/page-bundles/).
[branch bundle]: /getting-started/glossary/#branch-bundle
[leaf bundle]: /getting-started/glossary/#leaf-bundle
###### Why is my partial template not rendered as expected? {#foo}
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&nbsp;[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&nbsp;[details](/templates/pagination/#list-paginator-pages).
###### Why are there two ways to call a shortcode?
Use the `{{%/* shortcode */%}}` notation if the shortcode template, or the content between the opening and closing shortcode tags, contains markdown. Otherwise use the\
`{{</* shortcode */>}}` notation. See&nbsp;[details](/content-management/shortcodes/).
###### Can I use environment variables to control configuration?
Yes. See&nbsp;[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.
###### Which page methods trigger content rendering?
The following methods on a `Page` object triggering content rendering: `Content`, `FuzzyWordCount`, `Len`, `Plain`, `PlainWords`, `ReadingTime`, `Summary`, `Truncated`, and `WordCount`.
{{% 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
[installation]: /installation
[requesting help]: https://discourse.gohugo.io/t/requesting-help/9132