Merge commit '87de22d7464e239c775fbd48ebce1665d5b1e80d'

This commit is contained in:
Bjørn Erik Pedersen
2023-07-29 11:17:28 +02:00
177 changed files with 1623 additions and 1556 deletions

View File

@@ -1,14 +1,15 @@
---
title: Get Started
linktitle: Get Started Overview
title: Getting started
linkTitle: Overview
description: Quick start and guides for installing Hugo on your preferred operating system.
categories: [getting started]
keywords: [usage,docs]
menu:
docs:
identifier: getting-started-overview
parent: getting-started
weight: 1
weight: 0001
weight: 10
weight: 10
aliases: [/overview/introduction/]
---

View File

@@ -1,14 +1,18 @@
---
title: Configure Markup
title: Configure markup
description: How to handle Markdown and other markup related configuration.
categories: [getting started,fundamentals]
categories: [fundamentals, getting started]
keywords: [configuration,highlighting]
weight: 65
menu:
docs:
parent: getting-started
weight: 50
weight: 50
slug: configuration-markup
toc: true
---
## Configure Markup
## Configure markup
See [Goldmark](#goldmark) for settings related to the default Markdown handler in Hugo.
@@ -91,7 +95,7 @@ For `style`, see these galleries:
For CSS, see [Generate Syntax Highlighter CSS](/content-management/syntax-highlighting/#generate-syntax-highlighter-css).
### Table Of Contents
### Table of contents
{{< code-toggle config="markup.tableOfContents" />}}
@@ -106,6 +110,6 @@ endLevel
ordered
: Whether or not to generate an ordered list instead of an unordered list.
## Markdown Render Hooks
## Markdown render hooks
See [Markdown Render Hooks](/templates/render-hooks/).

View File

@@ -1,25 +1,24 @@
---
title: Configure Hugo
linktitle: Configuration
linkTitle: Configuration
description: How to configure your Hugo site.
categories: [getting started,fundamentals]
categories: [fundamentals,getting started]
keywords: [configuration,toml,yaml,json]
menu:
docs:
parent: getting-started
weight: 60
weight: 60
weight: 40
weight: 40
aliases: [/overview/source-directory/,/overview/configuration/]
toc: true
---
## Configuration File
## Configuration file
Hugo uses the `hugo.toml`, `hugo.yaml`, or `hugo.json` (if found in the
site root) as the default site configuration file.
The user can choose to override that default with one or more site config files
using the command-line `--config` switch.
The user can choose to override that default with one or more site configuration files using the command-line `--config` switch.
Examples:
@@ -29,18 +28,18 @@ hugo --config a.toml,b.toml,c.toml
```
{{% note %}}
Multiple site config files can be specified as a comma-separated string to the `--config` switch.
Multiple site configuration files can be specified as a comma-separated string to the `--config` switch.
{{% /note %}}
## hugo.toml vs config.toml
In Hugo 0.110.0 we changed the default config base filename to `hugo`, e.g. `hugo.toml`. We will still look for `config.toml` etc., but we recommend you eventually rename it (but you need to wait if you want to support older Hugo versions). The main reason we're doing this is to make it easier for code editors and build tools to identify this as a Hugo configuration file and project.
In Hugo 0.110.0 we changed the default configuration base file name to `hugo`, e.g. `hugo.toml`. We will still look for `config.toml` etc., but we recommend you eventually rename it (but you need to wait if you want to support older Hugo versions). The main reason we're doing this is to make it easier for code editors and build tools to identify this as a Hugo configuration file and project.
{{< new-in "0.110.0" >}}
## Configuration Directory
## Configuration directory
In addition to using a single site config file, one can use the `configDir` directory (default to `config/`) to maintain easier organization and environment specific settings.
In addition to using a single site configuration file, one can use the `configDir` directory (default to `config/`) to maintain easier organization and environment specific settings.
- Each file represents a configuration root object, such as `params.toml` for `[Params]`, `menu(s).toml` for `[Menu]`, `languages.toml` for `[Languages]` etc...
- Each file's content must be top-level, for example:
@@ -57,7 +56,6 @@ foo = "bar"
- Each directory holds a group of files containing settings unique to an environment.
- Files can be localized to become language specific.
```txt
├── config
│ ├── _default
@@ -83,23 +81,23 @@ Let's take an example to understand this better. Let's say you are using Google
- `G-SSSSSSSS` for staging
This is how you need to configure your `hugo.toml` files considering the above scenario:
1. In `_default/hugo.toml` you don't need to mention `googleAnalytics` parameter at all. This ensures that no Google Analytics code is loaded in your development server i.e. when you run `hugo server`. This works since, by default Hugo sets `Environment=development` when you run `hugo server` which uses the config files from `_default` folder
1. In `_default/hugo.toml` you don't need to mention `googleAnalytics` parameter at all. This ensures that no Google Analytics code is loaded in your development server i.e. when you run `hugo server`. This works since, by default Hugo sets `Environment=development` when you run `hugo server` which uses the configuration files from `_default` folder
2. In `production/hugo.toml` you just need to have one line:
```googleAnalytics = "G-PPPPPPPP"```
```googleAnalytics = "G-PPPPPPPP"```
You don't need to mention all other parameters like `title`, `baseURL`, `theme` etc. again in this config file. You need to mention only those parameters which are different or new for the production environment. This is due to the fact that Hugo is going to __merge__ this on top of `_default/hugo.toml`. Now when you run `hugo` (build command), by default hugo sets `Environment=production`, so the `G-PPPPPPPP` analytics code will be there in your production website
You don't need to mention all other parameters like `title`, `baseURL`, `theme` etc. again in this configuration file. You need to mention only those parameters which are different or new for the production environment. This is due to the fact that Hugo is going to __merge__ this on top of `_default/hugo.toml`. Now when you run `hugo` (build command), by default hugo sets `Environment=production`, so the `G-PPPPPPPP` analytics code will be there in your production website
3. Similarly in `staging/hugo.toml` you just need to have one line:
```googleAnalytics = "G-SSSSSSSS"```
```googleAnalytics = "G-SSSSSSSS"```
Now you need to tell Hugo that you are using the staging environment. So your build command should be `hugo --environment staging` which will load the `G-SSSSSSSS` analytics code in your staging website
Now you need to tell Hugo that you are using the staging environment. So your build command should be `hugo --environment staging` which will load the `G-SSSSSSSS` analytics code in your staging website
{{% note %}}
Default environments are __development__ with `hugo server` and __production__ with `hugo`.
{{%/ note %}}
## Merge Configuration from Themes
## Merge configuration from themes
The configuration value for `_merge` can be one of:
@@ -116,10 +114,9 @@ Note that you don't need to be so verbose as in the default setup below; a `_mer
{{< code-toggle config="mergeStrategy" skipHeader=true />}}
## All Configuration Settings
## All configuration settings
The following is the full list of Hugo-defined variables. Users may choose to override those values in their site
config file(s).
The following is the full list of Hugo-defined variables. Users may choose to override those values in their site configuration file(s).
### archetypeDir
@@ -165,7 +162,7 @@ See [Configure File Caches](#configure-file-caches)
### cascade
Pass down default configuration values (front matter) to pages in the content tree. The options in site config is the same as in page front matter, see [Front Matter Cascade](/content-management/front-matter#front-matter-cascade).
Pass down default configuration values (front matter) to pages in the content tree. The options in site configuration is the same as in page front matter, see [Front Matter Cascade](/content-management/front-matter#front-matter-cascade).
### canonifyURLs
@@ -205,25 +202,25 @@ Content without language indicator will default to this language.
### defaultContentLanguageInSubdir
**Default value:** false
**Default value:** false
Render the default content language in subdir, e.g. `content/en/`. The site root `/` will then redirect to `/en/`.
### disableAliases
**Default value:** false
**Default value:** false
Will disable generation of alias redirects. Note that even if `disableAliases` is set, the aliases themselves are preserved on the page. The motivation with this is to be able to generate 301 redirects in an `.htaccess`, a Netlify `_redirects` file or similar using a custom output format.
### disableHugoGeneratorInject
**Default value:** false
**Default value:** false
Hugo will, by default, inject a generator meta tag in the HTML head on the _home page only_. You can turn it off, but we would really appreciate if you don't, as this is a good way to watch Hugo's popularity on the rise.
### disableKinds
**Default value:** []
**Default value:** []
Enable disabling of all pages of the specified *Kinds*. Allowed values in this list: `"page"`, `"home"`, `"section"`, `"taxonomy"`, `"term"`, `"RSS"`, `"sitemap"`, `"robotsTXT"`, `"404"`.
@@ -235,37 +232,37 @@ Disable automatic live reloading of browser window.
### disablePathToLower
**Default value:** false
**Default value:** false
Do not convert the url/path to lowercase.
### enableEmoji
**Default value:** false
**Default value:** false
Enable Emoji emoticons support for page content; see the [Emoji Cheat Sheet](https://www.webpagefx.com/tools/emoji-cheat-sheet/).
### enableGitInfo
**Default value:** false
**Default value:** false
Enable `.GitInfo` object for each page (if the Hugo site is versioned by Git). This will then update the `Lastmod` parameter for each page using the last git commit date for that content file.
### enableInlineShortcodes
**Default value:** false
**Default value:** false
Enable inline shortcode support. See [Inline Shortcodes](/templates/shortcode-templates/#inline-shortcodes).
### enableMissingTranslationPlaceholders
**Default value:** false
**Default value:** false
Show a placeholder instead of the default value or an empty string if a translation is missing.
### enableRobotsTXT
**Default value:** false
**Default value:** false
Enable generation of `robots.txt` file.
@@ -275,7 +272,7 @@ See [Front matter Configuration](#configure-front-matter).
### googleAnalytics
**Default value:** ""
**Default value:** ""
Google Analytics tracking ID.
@@ -287,11 +284,11 @@ If true, auto-detect Chinese/Japanese/Korean Languages in the content. This will
### imaging
See [Image Processing Config](/content-management/image-processing/#imaging-configuration).
See [image processing configuration](/content-management/image-processing/#imaging-configuration).
### languageCode
**Default value:** ""
**Default value:** ""
A language tag as defined by [RFC 5646](https://datatracker.ietf.org/doc/html/rfc5646). This value is used to populate:
@@ -324,7 +321,7 @@ See [Configure Minify](#configure-minify)
### module
Module config see [Module Config](/hugo-modules/configuration/).
Module configuration see [module configuration](/hugo-modules/configuration/).
### newContentEditor
@@ -436,11 +433,11 @@ See [Configure Taxonomies](/content-management/taxonomies#configure-taxonomies).
### theme
: See [Module Config](/hugo-modules/configuration/#module-config-imports) for how to import a theme.
: See [module configuration](/hugo-modules/configuration/#module-configuration-imports) for how to import a theme.
### themesDir
**Default value:** "themes"
**Default value:** "themes"
The directory where Hugo reads the themes from.
@@ -448,11 +445,11 @@ The directory where Hugo reads the themes from.
**Default value:** "30s"
Timeout for generating page contents, specified as a [duration](https://pkg.go.dev/time#Duration) or in milliseconds. *Note:*&nbsp;this is used to bail out of recursive content generation. You might need to raise this limit if your pages are slow to generate (e.g., because they require large image processing or depend on remote contents).
Timeout for generating page contents, specified as a [duration](https://pkg.go.dev/time#Duration) or in seconds. *Note:*&nbsp;this is used to bail out of recursive content generation. You might need to raise this limit if your pages are slow to generate (e.g., because they require large image processing or depend on remote contents).
### timeZone
The time zone (or location), e.g. `Europe/Oslo`, used to parse front matter dates without such information and in the [`time` function](/functions/time/). The list of valid values may be system dependent, but should include `UTC`, `Local`, and any location in the [IANA Time Zone database](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones).
The time zone (or location), e.g. `Europe/Oslo`, used to parse front matter dates without such information and in the [`time` function](/functions/time/). The list of valid values may be system dependent, but should include `UTC`, `Local`, and any location in the [IANA Time Zone database](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones).
### title
@@ -460,7 +457,7 @@ Site title.
### titleCaseStyle
**Default value:** "AP"
**Default value:** "ap"
See [Configure Title Case](#configure-title-case)
@@ -490,53 +487,73 @@ enableemoji: true
```
{{% /note %}}
## Configure Build
## Configure build
The `build` configuration section contains global build-related configuration options.
{{< code-toggle file="hugo" >}}
[build]
useResourceCacheWhen="fallback"
writeStats = false
noJSConfigInAssets = false
[[build.cachebusters]]
source = "assets/watching/hugo_stats\\.json"
target = "styles\\.css"
[[build.cachebusters]]
source = "(postcss|tailwind)\\.config\\.js"
target = "css"
[[build.cachebusters]]
source = "assets/.*\\.(js|ts|jsx|tsx)"
target = "js"
[[build.cachebusters]]
source = "assets/.*\\.(.*)$"
target = "$1"
noJSConfigInAssets = false
useResourceCacheWhen = 'fallback'
[build.buildStats]
disableClasses = false
disableIDs = false
disableTags = false
enable = false
[[build.cachebusters]]
source = 'assets/.*\.(js|ts|jsx|tsx)'
target = '(js|scripts|javascript)'
[[build.cachebusters]]
source = 'assets/.*\.(css|sass|scss)$'
target = '(css|styles|scss|sass)'
[[build.cachebusters]]
source = '(postcss|tailwind)\.config\.js'
target = '(css|styles|scss|sass)'
[[build.cachebusters]]
source = 'assets/.*\.(.*)$'
target = '$1'
{{< /code-toggle >}}
buildStats {{< new-in "0.115.1" >}}
: When enabled, creates a `hugo_stats.json` file in the root of your project. This file contains arrays of the `class` attributes, `id` attributes, and tags of every HTML element within your published site. Use this file as data source when [removing unused CSS] from your site. This process is also known as pruning, purging, or tree shaking.
useResourceCacheWhen
: When to use the cached resources in `/resources/_gen` for PostCSS and ToCSS. Valid values are `never`, `always` and `fallback`. The last value means that the cache will be tried if PostCSS/extended version is not available.
[removing unused CSS]: http://localhost:1313/hugo-pipes/postprocess/#css-purging-with-postcss
writeStats
: When enabled, a file named `hugo_stats.json` will be written to your project root with some aggregated data about the build, e.g. list of HTML entities published to be used to do [CSS pruning](/hugo-pipes/postprocess/#css-purging-with-postcss). If you're only using this for the production build, you should consider placing it below [config/production](/getting-started/configuration/#configuration-directory). It's also worth mentioning that, due to the nature of the partial server builds, new HTML entities will be added when you add or change them while the server is running, but the old values will not be removed until you restart the server or run a regular `hugo` build.
Exclude `class` attributes, `id` attributes, or tags from `hugo_stats.json` with the `disableClasses`, `disableIDs`, and `disableTags` keys.
**Note** that the prime use case for this is purging of unused CSS; it is built for speed and there may be false positives (e.g., detection of HTML elements that are not HTML elements).
{{% note %}}
With v0.115.0 and earlier this feature was enabled by setting `writeStats` to `true`. Although still functional, the `writeStats` key will be deprecated in a future release.
noJSConfigInAssets
: Turn off writing a `jsconfig.json` into your `/assets` folder with mapping of imports from running [js.Build](https://gohugo.io/hugo-pipes/js). This file is intended to help with intellisense/navigation inside code editors such as [VS Code](https://code.visualstudio.com/). Note that if you do not use `js.Build`, no file will be written.
Given that CSS purging is typically limited to production builds, place the `buildStats` object below [config/production].
[config/production]: /getting-started/configuration/#configuration-directory
Built for speed, there may be "false positive" detections (e.g., HTML elements that are not HTML elements) while parsing the published site. These "false positives" are infrequent and inconsequential.
{{% /note %}}
Due to the nature of partial server builds, new HTML entities are added while the server is running, but old values will not be removed until you restart the server or run a regular `hugo` build.
cachebusters
: See [Configure Cache Busters](#configure-cache-busters)
## Configure Cache Busters
noJSConfigInAssets
: Turn off writing a `jsconfig.json` into your `/assets` folder with mapping of imports from running [js.Build](/hugo-pipes/js). This file is intended to help with intellisense/navigation inside code editors such as [VS Code](https://code.visualstudio.com/). Note that if you do not use `js.Build`, no file will be written.
useResourceCacheWhen
: When to use the cached resources in `/resources/_gen` for PostCSS and ToCSS. Valid values are `never`, `always` and `fallback`. The last value means that the cache will be tried if PostCSS/extended version is not available.
## Configure cache busters
{{< new-in "0.112.0" >}}
The `build.cachebusters` configuration option was added to support development using Tailwind 3.x's JIT compiler where a `build` config may look like this:
The `build.cachebusters` configuration option was added to support development using Tailwind 3.x's JIT compiler where a `build` configuration may look like this:
<!-- TODO (jmm) writeStats => build.buildStats -->
{{< code-toggle file="hugo" >}}
[build]
writeStats = true
[build.buildStats]
enable = true
[[build.cachebusters]]
source = "assets/watching/hugo_stats\\.json"
target = "styles\\.css"
@@ -559,7 +576,7 @@ source
target
: A regexp matching the keys in the resource cache that should be expired when `source` changes. You can use the matching regexp groups from `source` in the expression, e.g. `$1`.
## Configure Server
## Configure server
This is only relevant when running `hugo server`, and it allows to set HTTP headers during development, which allows you to test out your Content Security Policy and similar. The configuration format matches [Netlify's](https://docs.netlify.com/routing/headers/#syntax-for-the-netlify-configuration-file) with slightly more powerful [Glob matching](https://github.com/gobwas/glob):
@@ -579,7 +596,6 @@ Content-Security-Policy = "script-src localhost:1313"
Since this is "development only", it may make sense to put it below the `development` environment:
{{< code-toggle file="config/development/server">}}
[[headers]]
for = "/**"
@@ -604,13 +620,13 @@ status = 200
force = false
{{< /code-toggle >}}
Setting `force=true` will make a redirect even if there is existing content in the path. Note that before Hugo 0.76 `force` was the default behavior, but this is inline with how Netlify does it.
Setting `force=true` will make a redirect even if there is existing content in the path. Note that before Hugo 0.76 `force` was the default behavior, but this is inline with how Netlify does it.
## 404 Server Error Page {#_404-server-error-page}
## 404 server error page {#_404-server-error-page}
{{< new-in "0.103.0" >}}
Hugo will, by default, render all 404 errors when running `hugo server` with the `404.html` template. Note that if you have already added one or more redirects to your [Server Config](#configure-server), you need to add the 404 redirect explicitly, e.g:
Hugo will, by default, render all 404 errors when running `hugo server` with the `404.html` template. Note that if you have already added one or more redirects to your [server configuration](#configure-server), you need to add the 404 redirect explicitly, e.g:
{{< code-toggle file="config/development/server" copy=false >}}
[[redirects]]
@@ -619,13 +635,13 @@ to = "/404.html"
status = 404
{{< /code-toggle >}}
## Configure Title Case
## Configure title case
Set `titleCaseStyle` to specify the title style used by the [title](/functions/title/) template function and the automatic section titles in Hugo.
Set `titleCaseStyle` to specify the title style used by the [title](/functions/title/) template function and the automatic section titles in Hugo.
Can be one of:
* `ap` (default), the capitalization rules in the [Associated Press (AP) Stylebook]
* `ap` (default), the capitalization rules in the [Associated Press (AP) Stylebook]
* `chicago`, the [Chicago Manual of Style]
* `go`, Go's convention of capitalizing every word.
* `firstupper`, capitalize the first letter of the first word.
@@ -635,12 +651,12 @@ Can be one of:
[Chicago Manual of Style]: https://www.chicagomanualofstyle.org/home.html
[site configuration]: /getting-started/configuration/#configure-title-case
## Configuration Environment Variables
## Configuration environment variables
HUGO_NUMWORKERMULTIPLIER
: Can be set to increase or reduce the number of workers used in parallel processing in Hugo. If not set, the number of logical CPUs will be used.
## Configuration Lookup Order
## Configuration lookup order
Similar to the template [lookup order], Hugo has a default set of rules for searching for a configuration file in the root of your website's source directory as a default behavior:
@@ -650,8 +666,7 @@ Similar to the template [lookup order], Hugo has a default set of rules for sear
In your configuration file, you can direct Hugo as to how you want your website rendered, control your website's menus, and arbitrarily define site-wide parameters specific to your project.
## Example Configuration
## Example configuration
The following is a typical example of a configuration file. The values nested under `params:` will populate the [`.Site.Params`] variable for use in [templates]:
@@ -670,9 +685,9 @@ params:
SidebarRecentLimit: 5
{{< /code-toggle >}}
## Configure with Environment Variables
## Configure with environment variables
In addition to the 3 config options already mentioned, configuration key-values can be defined through operating system environment variables.
In addition to the 3 configuration options already mentioned, configuration key-values can be defined through operating system environment variables.
For example, the following command will effectively set a website's title on Unix-like systems:
@@ -685,18 +700,18 @@ This is really useful if you use a service such as Netlify to deploy your site.
{{% note %}}
Names must be prefixed with `HUGO_` and the configuration key must be set in uppercase when setting operating system environment variables.
To set config params, prefix the name with `HUGO_PARAMS_`
To set configuration parameters, prefix the name with `HUGO_PARAMS_`
{{% /note %}}
If you are using snake_cased variable names, the above will not work. Hugo determines the delimiter to use by the first character after `HUGO`. This allows you to define environment variables on the form `HUGOxPARAMSxAPI_KEY=abcdefgh`, using any [allowed](https://stackoverflow.com/questions/2821043/allowed-characters-in-linux-environment-variable-names#:~:text=So%20names%20may%20contain%20any,not%20begin%20with%20a%20digit.) delimiter.
{{< todo >}}
Test and document setting params via JSON env var.
Test and document setting parameters via JSON env var.
{{< /todo >}}
## Ignore Content and Data Files when Rendering
## Ignore content and data files when rendering
**Note:** This works, but we recommend you use the newer and more powerful [includeFiles and excludeFiles](https://gohugo.io/hugo-modules/configuration/#module-config-mounts) mount options.
**Note:** This works, but we recommend you use the newer and more powerful [includeFiles and excludeFiles](/hugo-modules/configuration/#module-configuration-mounts) mount options.
To exclude specific files from the `content`, `data`, and `i18n` directories when rendering your site, set `ignoreFiles` to one or more regular expressions to match against the absolute file path.
@@ -712,9 +727,9 @@ To ignore a file using the absolute file path:
ignoreFiles = ['^/home/user/project/content/test\.md$']
{{< /code-toggle >}}
## Configure Front Matter
## Configure front matter
### Configure Dates
### Configure dates
Dates are important in Hugo, and you can configure how Hugo assigns dates to your content pages. You do this by adding a `frontmatter` section to your `hugo.toml`.
@@ -737,11 +752,10 @@ date = ["myDate", ":default"]
The `:default` is a shortcut to the default settings. The above will set `.Date` to the date value in `myDate` if present, if not we will look in `date`,`publishDate`, `lastmod` and pick the first valid date.
In the list to the right, values starting with ":" are date handlers with a special meaning (see below). The others are just names of date parameters (case insensitive) in your front matter configuration. Also note that Hugo have some built-in aliases to the above: `lastmod` => `modified`, `publishDate` => `pubdate`, `published` and `expiryDate` => `unpublishdate`. With that, as an example, using `pubDate` as a date in front matter, will, by default, be assigned to `.PublishDate`.
In the list to the right, values starting with ":" are date handlers with a special meaning (see below). The others are just names of date parameters (case insensitive) in your front matter configuration. Also note that Hugo have some built-in aliases to the above: `lastmod` => `modified`, `publishDate` => `pubdate`, `published` and `expiryDate` => `unpublishdate`. With that, as an example, using `pubDate` as a date in front matter, will, by default, be assigned to `.PublishDate`.
The special date handlers are:
`:fileModTime`
: Fetches the date from the content file's last modification timestamp.
@@ -752,12 +766,10 @@ An example:
lastmod = ["lastmod", ":fileModTime", ":default"]
{{< /code-toggle >}}
The above will try first to extract the value for `.Lastmod` starting with the `lastmod` front matter parameter, then the content file's modification timestamp. The last, `:default` should not be needed here, but Hugo will finally look for a valid date in `:git`, `date` and then `publishDate`.
`:filename`
: Fetches the date from the content file's filename. For example, `2018-02-22-mypage.md` will extract the date `2018-02-22`. Also, if `slug` is not set, `mypage` will be used as the value for `.Slug`.
: Fetches the date from the content file's file name. For example, `2018-02-22-mypage.md` will extract the date `2018-02-22`. Also, if `slug` is not set, `mypage` will be used as the value for `.Slug`.
An example:
@@ -766,23 +778,22 @@ An example:
date = [":filename", ":default"]
{{< /code-toggle >}}
The above will try first to extract the value for `.Date` from the filename, then it will look in front matter parameters `date`, `publishDate` and lastly `lastmod`.
The above will try first to extract the value for `.Date` from the file name, then it will look in front matter parameters `date`, `publishDate` and lastly `lastmod`.
`:git`
: This is the Git author date for the last revision of this content file. This will only be set if `--enableGitInfo` is set or `enableGitInfo = true` is set in site config.
: This is the Git author date for the last revision of this content file. This will only be set if `--enableGitInfo` is set or `enableGitInfo = true` is set in site configuration.
## Configure Additional Output Formats
## Configure additional output formats
Hugo v0.20 introduced the ability to render your content to multiple output formats (e.g., to JSON, AMP html, or CSV). See [Output Formats] for information on how to add these values to your Hugo project's configuration file.
## Configure Minify
## Configure minify
Default configuration:
{{< code-toggle config="minify" />}}
## Configure File Caches
## Configure file caches
Since Hugo 0.52 you can configure more than just the `cacheDir`. This is the default configuration:
@@ -813,13 +824,13 @@ You can override any of these cache settings in your own `hugo.toml`.
### The keywords explained
`:cacheDir`
: This is the value of the `cacheDir` config option if set (can also be set via OS env variable `HUGO_CACHEDIR`). It will fall back to `/opt/build/cache/hugo_cache/` on Netlify, or a `hugo_cache_$USER` directory below the OS temp dir for the others. This means that if you run your builds on Netlify, all caches configured with `:cacheDir` will be saved and restored on the next build. For other CI vendors, please read their documentation. For an CircleCI example, see [this configuration](https://github.com/bep/hugo-sass-test/blob/6c3960a8f4b90e8938228688bc49bdcdd6b2d99e/.circleci/config.yml).
: This is the value of the `cacheDir` configuration option if set (can also be set via OS env variable `HUGO_CACHEDIR`). It will fall back to `/opt/build/cache/hugo_cache/` on Netlify, or a `hugo_cache_$USER` directory below the OS temp dir for the others. This means that if you run your builds on Netlify, all caches configured with `:cacheDir` will be saved and restored on the next build. For other CI vendors, please read their documentation. For an CircleCI example, see [this configuration](https://github.com/bep/hugo-sass-test/blob/6c3960a8f4b90e8938228688bc49bdcdd6b2d99e/.circleci/config.yml).
`:project`
: The base directory name of the current Hugo project. This means that, in its default setting, every project will have separated file caches, which means that when you do `hugo --gc` you will not touch files related to other Hugo projects running on the same PC.
`:resourceDir`
: This is the value of the `resourceDir` config option.
: This is the value of the `resourceDir` configuration option.
maxAge
: This is the duration before a cache entry will be evicted, -1 means forever and 0 effectively turns that particular cache off. Uses Go's `time.Duration`, so valid values are `"10s"` (10 seconds), `"10m"` (10 minutes) and `"10h"` (10 hours).
@@ -827,7 +838,7 @@ maxAge
dir
: The absolute path to where the files for this cache will be stored. Allowed starting placeholders are `:cacheDir` and `:resourceDir` (see above).
## Configuration Format Specs
## Configuration format specs
- [TOML Spec][toml]
- [YAML Spec][yaml]

View File

@@ -1,18 +1,18 @@
---
title: Directory Structure
title: Directory structure
description: Hugo's CLI scaffolds a project directory structure and then takes that single directory and uses it as the input to create a complete website.
categories: [getting started,fundamentals]
categories: [fundamentals,getting started]
keywords: [source, organization, directories]
menu:
docs:
parent: getting-started
weight: 50
weight: 50
weight: 30
weight: 30
aliases: [/overview/source-directory/]
toc: true
---
## New Site Scaffolding
## New site scaffolding
{{< youtube sB0HLHjgQ7E >}}
@@ -32,23 +32,23 @@ example/
└── hugo.toml
```
## Directory Structure Explained
## Directory structure explained
The following is a high-level overview of each of the directories with links to each of their respective sections within the Hugo docs.
[`archetypes`](/content-management/archetypes/)
: You can create new content files in Hugo using the `hugo new` command.
By default, Hugo will create new content files with at least `date`, `title` (inferred from the filename), and `draft = true`. This saves time and promotes consistency for sites using multiple content types. You can create your own [archetypes] with custom preconfigured front matter fields as well.
By default, Hugo will create new content files with at least `date`, `title` (inferred from the file name), and `draft = true`. This saves time and promotes consistency for sites using multiple content types. You can create your own [archetypes] with custom preconfigured front matter fields as well.
[`assets`]
: Stores all the files which need be processed by [Hugo Pipes](/hugo-pipes/). Only the files whose `.Permalink` or `.RelPermalink` are used will be published to the `public` directory.
[`config`](/getting-started/configuration/)
: Hugo ships with a large number of [configuration directives].
The [config directory](/getting-started/configuration/#configuration-directory) is where those directives are stored as JSON, YAML, or TOML files. Every root setting object can stand as its own file and structured by environments.
The [configuration directory](/getting-started/configuration/#configuration-directory) is where those directives are stored as JSON, YAML, or TOML files. Every root setting object can stand as its own file and structured by environments.
Projects with minimal settings and no need for environment awareness can use a single `hugo.toml` file at its root.
Many sites may need little to no configuration, but Hugo ships with a large number of [configuration directives] for more granular directions on how you want Hugo to build your website. Note: config directory is not created by default.
Many sites may need little to no configuration, but Hugo ships with a large number of [configuration directives] for more granular directions on how you want Hugo to build your website. Note: the `config` directory is not created by default.
[`content`]
: All content for your website will live inside this directory. Each top-level folder in Hugo is considered a [content section]. For example, if your site has three main sections---`blog`, `articles`, and `tutorials`---you will have three directories at `content/blog`, `content/articles`, and `content/tutorials`. Hugo uses sections to assign default [content types].
@@ -86,7 +86,6 @@ From **Hugo 0.31** you can have multiple static directories.
[partials]: /templates/partials/
[searchconsole]: https://support.google.com/webmasters/answer/9008080#zippy=%2Chtml-file-upload
[singles]: /templates/single-page-templates/
[starters]: /tools/starter-kits/
[taxonomies]: /content-management/taxonomies/
[taxonomy templates]: /templates/taxonomy-templates/
[types]: /content-management/types/

View File

@@ -1,12 +1,12 @@
---
title: External Learning Resources
title: External learning resources
description: A list of tutorials and books on Hugo.
keywords: [books, tutorials, learning, usage]
menu:
docs:
parent: getting-started
weight: 70
weight: 70
weight: 60
weight: 60
---
## Books

View File

@@ -1,13 +1,13 @@
---
title: Quick Start
title: Quick start
description: Learn to create a Hugo site in minutes.
categories: [getting started]
keywords: [quick start,usage]
menu:
docs:
parent: getting-started
weight: 10
weight: 10
weight: 20
weight: 20
toc: true
aliases: [/quickstart/,/overview/quickstart/]
---
@@ -39,9 +39,10 @@ You must also be comfortable working from the command line.
- Do not use Windows PowerShell
- Run these commands from [PowerShell] or a Linux terminal such as WSL or Git Bash
PowerShell and Windows PowerShell are different applications.
PowerShell and Windows PowerShell [are different applications].
[PowerShell]: https://learn.microsoft.com/en-us/powershell/scripting/install/installing-powershell-on-windows
[are different applications]: https://learn.microsoft.com/en-us/powershell/scripting/whats-new/differences-from-windows-powershell?view=powershell-7.3
{{% /note %}}
Run these commands to create a Hugo site with the [Ananke] theme. The next section provides an explanation of each command.
@@ -50,7 +51,7 @@ Run these commands to create a Hugo site with the [Ananke] theme. The next secti
hugo new site quickstart
cd quickstart
git init
git submodule add https://github.com/theNewDynamic/gohugo-theme-ananke themes/ananke
git submodule add https://github.com/theNewDynamic/gohugo-theme-ananke.git themes/ananke
echo "theme = 'ananke'" >> hugo.toml
hugo server
```
@@ -80,7 +81,7 @@ git init
Clone the [Ananke] theme into the `themes` directory, adding it to your project as a [Git submodule].
```text
git submodule add https://github.com/theNewDynamic/gohugo-theme-ananke themes/ananke
git submodule add https://github.com/theNewDynamic/gohugo-theme-ananke.git themes/ananke
```
Append a line to the site configuration file, indicating the current theme.

View File

@@ -6,8 +6,8 @@ keywords: [usage,livereload,command,flags]
menu:
docs:
parent: getting-started
weight: 40
weight: 40
weight: 30
weight: 30
aliases: [/overview/usage/,/extras/livereload/,/doc/usage/,/usage/]
toc: true
---