mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-21 20:46:30 -05:00
Squashed 'docs/' changes from 686c7b6eb..7ef2dbce4
7ef2dbce4 Cleanup RSS templates page 0e23d5e1a Fix multilingual permalinks example b3c342b07 Update faq.md f73109ae2 Regen CLI docs ac6ee2027 Fix minor nitpicks (#2233) f24fcffe1 Mention the Giscus comments system (#2234) 418fa981e Remove reference to Ghost migration tool 94a76df29 Adjust table layout e263ad6b9 content: Fix typos fd1eb26b5 Update featured image in digital.gov showcase d3d946555 Correct directory description bbe1dff56 Use sentence case for heading acfa0be54 Add hosting provider fetch depth to GitInfo variables page d78c427e6 Fix typo 751517fea Fix spelling mistake cdd77aa9a Update content for v0.118.0 c77d09b1c Format netlify.toml d5a6c4f51 netlify: Hugo 0.118.1 8c717301a Revert "netlify: Hugo 0.118.0" a9b2ef5c2 netlify: Hugo 0.118.0 61959591c Merge commit '77b976dd92b4f66657d83d875aef0c617df492d9' 95f2029a1 docs: Regen docs helper fd57ba960 markup/goldmark: Add CJK extension 2bfb3bf4c docshelper: Improve template lookup order descriptions b0baa890e cache: Hide IsResourceDir from the exported config b4b071ea0 docs: Replace docs.json with docs.yaml git-subtree-dir: docs git-subtree-split: 7ef2dbce4ad728d32c218761c6cfbe2f58f8da16
This commit is contained in:
parent
77b976dd92
commit
9aec42c545
19 changed files with 320 additions and 165 deletions
|
@ -131,4 +131,4 @@ enableDNT
|
||||||
: Enabling this for the vimeo shortcode, the Vimeo player will be blocked from tracking any session data, including all cookies and stats.
|
: Enabling this for the vimeo shortcode, the Vimeo player will be blocked from tracking any session data, including all cookies and stats.
|
||||||
|
|
||||||
simple
|
simple
|
||||||
: If simple mode is enabled, the video thumbnail is fetched from Vimeo's servers and it is overlayed with a play button. If the user clicks to play the video, it will open in a new tab directly on Vimeo's website.
|
: If simple mode is enabled, the video thumbnail is fetched from Vimeo's servers and it is overlaid with a play button. If the user clicks to play the video, it will open in a new tab directly on Vimeo's website.
|
||||||
|
|
|
@ -21,7 +21,7 @@ hugo gen chromastyles [flags] [args]
|
||||||
|
|
||||||
```
|
```
|
||||||
-h, --help help for chromastyles
|
-h, --help help for chromastyles
|
||||||
--highlightStyle string style used for highlighting lines (see https://github.com/alecthomas/chroma) (default "bg:#ffffcc")
|
--highlightStyle string style used for highlighting lines (see https://github.com/alecthomas/chroma)
|
||||||
--linesStyle string style used for line numbers (see https://github.com/alecthomas/chroma)
|
--linesStyle string style used for line numbers (see https://github.com/alecthomas/chroma)
|
||||||
--style string highlighter style (see https://xyproto.github.io/splash/docs/) (default "friendly")
|
--style string highlighter style (see https://xyproto.github.io/splash/docs/) (default "friendly")
|
||||||
```
|
```
|
||||||
|
|
|
@ -12,7 +12,7 @@ Generate Markdown documentation for the Hugo CLI.
|
||||||
Generate Markdown documentation for the Hugo CLI.
|
Generate Markdown documentation for the Hugo CLI.
|
||||||
This command is, mostly, used to create up-to-date documentation
|
This command is, mostly, used to create up-to-date documentation
|
||||||
of Hugo's command-line interface for https://gohugo.io/.
|
of Hugo's command-line interface for https://gohugo.io/.
|
||||||
|
|
||||||
It creates one Markdown file per command with front matter suitable
|
It creates one Markdown file per command with front matter suitable
|
||||||
for rendering in Hugo.
|
for rendering in Hugo.
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,12 @@ Install a specific version:
|
||||||
|
|
||||||
hugo mod get github.com/gohugoio/testshortcodes@v0.3.0
|
hugo mod get github.com/gohugoio/testshortcodes@v0.3.0
|
||||||
|
|
||||||
Install the latest versions of all module dependencies:
|
Install the latest versions of all direct module dependencies:
|
||||||
|
|
||||||
|
hugo mod get
|
||||||
|
hugo mod get ./... (recursive)
|
||||||
|
|
||||||
|
Install the latest versions of all module dependencies (direct and indirect):
|
||||||
|
|
||||||
hugo mod get -u
|
hugo mod get -u
|
||||||
hugo mod get -u ./... (recursive)
|
hugo mod get -u ./... (recursive)
|
||||||
|
|
|
@ -48,6 +48,7 @@ These are some alternatives to Disqus:
|
||||||
|
|
||||||
* [Cactus Comments](https://cactus.chat/docs/integrations/hugo/) (Open Source, Matrix appservice, Docker install)
|
* [Cactus Comments](https://cactus.chat/docs/integrations/hugo/) (Open Source, Matrix appservice, Docker install)
|
||||||
* [Commento](https://commento.io/) (Open Source, available as a service, local install, or docker image)
|
* [Commento](https://commento.io/) (Open Source, available as a service, local install, or docker image)
|
||||||
|
* [Giscus](https://giscus.app/) (Open source, comments system powered by GitHub Discussions)
|
||||||
* [Graph Comment](https://graphcomment.com/)
|
* [Graph Comment](https://graphcomment.com/)
|
||||||
* [Hyvor Talk](https://talk.hyvor.com/) (Available as a service)
|
* [Hyvor Talk](https://talk.hyvor.com/) (Available as a service)
|
||||||
* [IntenseDebate](https://intensedebate.com/)
|
* [IntenseDebate](https://intensedebate.com/)
|
||||||
|
|
|
@ -272,7 +272,7 @@ In the example above, on the second line, we have reversed width and height to r
|
||||||
|
|
||||||
### Anchor
|
### Anchor
|
||||||
|
|
||||||
When using the [`Crop`] or [`Fill`] method, the _anchor_ determines the placement of the crop box. You may specify `TopLeft`, `Top`, `TopRight`, `Left`, `Center`,`Right`, `BottomLeft`, `Bottom`, `BottomRight`, or `Smart`.
|
When using the [`Crop`] or [`Fill`] method, the _anchor_ determines the placement of the crop box. You may specify `TopLeft`, `Top`, `TopRight`, `Left`, `Center`, `Right`, `BottomLeft`, `Bottom`, `BottomRight`, or `Smart`.
|
||||||
|
|
||||||
The default value is `Smart`, which uses [Smartcrop] image analysis to determine the optimal placement of the crop box. You may override the default value in the [site configuration].
|
The default value is `Smart`, which uses [Smartcrop] image analysis to determine the optimal placement of the crop box. You may override the default value in the [site configuration].
|
||||||
|
|
||||||
|
|
|
@ -102,11 +102,11 @@ With this content structure:
|
||||||
```text
|
```text
|
||||||
content/
|
content/
|
||||||
├── posts/
|
├── posts/
|
||||||
│ ├── bash-in-slow-motion.md
|
│ ├── bash-in-slow-motion.md
|
||||||
│ └── tls-in-a-nutshell.md
|
│ └── tls-in-a-nutshell.md
|
||||||
├── tutorials/
|
├── tutorials/
|
||||||
│ ├── git-for-beginners.md
|
│ ├── git-for-beginners.md
|
||||||
│ └── javascript-bundling-with-hugo.md
|
│ └── javascript-bundling-with-hugo.md
|
||||||
└── _index.md
|
└── _index.md
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -165,15 +165,15 @@ With this content structure:
|
||||||
|
|
||||||
```text
|
```text
|
||||||
content/
|
content/
|
||||||
├── de/
|
├── en/
|
||||||
│ ├── books/
|
│ ├── books/
|
||||||
│ │ ├── les-miserables.md
|
│ │ ├── les-miserables.md
|
||||||
│ │ └── the-hunchback-of-notre-dame.md
|
│ │ └── the-hunchback-of-notre-dame.md
|
||||||
│ └── _index.md
|
│ └── _index.md
|
||||||
└── en/
|
└── es/
|
||||||
├── books/
|
├── books/
|
||||||
│ ├── les-miserables.md
|
│ ├── les-miserables.md
|
||||||
│ └── the-hunchback-of-notre-dame.md
|
│ └── the-hunchback-of-notre-dame.md
|
||||||
└── _index.md
|
└── _index.md
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -197,7 +197,7 @@ books = "/books/:slug/"
|
||||||
books = "/books/"
|
books = "/books/"
|
||||||
|
|
||||||
[languages.es]
|
[languages.es]
|
||||||
contentDir = 'content/de'
|
contentDir = 'content/es'
|
||||||
languageCode = 'es-ES'
|
languageCode = 'es-ES'
|
||||||
languageDirection = 'ltr'
|
languageDirection = 'ltr'
|
||||||
languageName = 'Español'
|
languageName = 'Español'
|
||||||
|
@ -215,21 +215,21 @@ The structure of the published site will be:
|
||||||
```text
|
```text
|
||||||
public/
|
public/
|
||||||
├── en/
|
├── en/
|
||||||
│ ├── books/
|
│ ├── books/
|
||||||
│ │ ├── les-miserables/
|
│ │ ├── les-miserables/
|
||||||
│ │ │ └── index.html
|
│ │ │ └── index.html
|
||||||
│ │ ├── the-hunchback-of-notre-dame/
|
│ │ ├── the-hunchback-of-notre-dame/
|
||||||
│ │ │ └── index.html
|
│ │ │ └── index.html
|
||||||
│ │ └── index.html
|
│ │ └── index.html
|
||||||
│ └── index.html
|
│ └── index.html
|
||||||
├── es/
|
├── es/
|
||||||
│ ├── libros/
|
│ ├── libros/
|
||||||
│ │ ├── les-miserables/
|
│ │ ├── les-miserables/
|
||||||
│ │ │ └── index.html
|
│ │ │ └── index.html
|
||||||
│ │ ├── the-hunchback-of-notre-dame/
|
│ │ ├── the-hunchback-of-notre-dame/
|
||||||
│ │ │ └── index.html
|
│ │ │ └── index.html
|
||||||
│ │ └── index.html
|
│ │ └── index.html
|
||||||
│ └── index.html
|
│ └── index.html
|
||||||
└── index.html
|
└── index.html
|
||||||
````
|
````
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ Below are all markup related configuration in Hugo with their default settings:
|
||||||
|
|
||||||
## Goldmark
|
## Goldmark
|
||||||
|
|
||||||
[Goldmark](https://github.com/yuin/goldmark/) is from Hugo 0.60 the default library used for Markdown. It's fast, it's [CommonMark](https://spec.commonmark.org/0.29/) compliant and it's very flexible.
|
[Goldmark](https://github.com/yuin/goldmark/) is from Hugo 0.60 the default library used for Markdown. It's fast, it's [CommonMark](https://spec.commonmark.org/current/) compliant and it's very flexible.
|
||||||
|
|
||||||
This is the default configuration:
|
This is the default configuration:
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
---
|
---
|
||||||
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.
|
description: Each Hugo project is a directory, with subdirectories that contribute to the content, structure, behavior, and presentation of your site.
|
||||||
categories: [fundamentals,getting started]
|
categories: [fundamentals,getting started]
|
||||||
keywords: [source, organization, directories]
|
keywords: [source, organization, directories]
|
||||||
menu:
|
menu:
|
||||||
|
@ -12,80 +12,202 @@ aliases: [/overview/source-directory/]
|
||||||
toc: true
|
toc: true
|
||||||
---
|
---
|
||||||
|
|
||||||
## New site scaffolding
|
## Site skeleton
|
||||||
|
|
||||||
{{< youtube sB0HLHjgQ7E >}}
|
Hugo generates a project skeleton when you create a new site. For example, this command:
|
||||||
|
|
||||||
Running `hugo new site example` from the command line creates a directory structure with the following elements:
|
```text
|
||||||
|
hugo new site my-site
|
||||||
|
```
|
||||||
|
|
||||||
|
Creates this directory structure:
|
||||||
|
|
||||||
```txt
|
```txt
|
||||||
example/
|
my-site/
|
||||||
├── archetypes/
|
├── archetypes/
|
||||||
│ └── default.md
|
│ └── default.md
|
||||||
├── assets/
|
├── assets/
|
||||||
├── content/
|
├── content/
|
||||||
├── data/
|
├── data/
|
||||||
|
├── i18n/
|
||||||
├── layouts/
|
├── layouts/
|
||||||
├── public/
|
|
||||||
├── static/
|
├── static/
|
||||||
├── themes/
|
├── themes/
|
||||||
└── hugo.toml
|
└── hugo.toml <-- site configuration
|
||||||
```
|
```
|
||||||
|
|
||||||
## Directory structure explained
|
Depending on requirements, you may wish to organize your site configuration into subdirectories:
|
||||||
|
|
||||||
The following is a high-level overview of each of the directories with links to each of their respective sections within the Hugo docs.
|
```txt
|
||||||
|
my-site/
|
||||||
|
├── archetypes/
|
||||||
|
│ └── default.md
|
||||||
|
├── assets/
|
||||||
|
├── config/ <-- site configuration
|
||||||
|
│ └── _default/
|
||||||
|
│ └── hugo.toml
|
||||||
|
├── content/
|
||||||
|
├── data/
|
||||||
|
├── i18n/
|
||||||
|
├── layouts/
|
||||||
|
├── static/
|
||||||
|
└── themes/
|
||||||
|
```
|
||||||
|
|
||||||
[`archetypes`](/content-management/archetypes/)
|
When you build your site, Hugo creates a `public` directory, and typically a `resources` directory as well:
|
||||||
: You can create new content files in Hugo using the `hugo new content` command.
|
|
||||||
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`]
|
```txt
|
||||||
: 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.
|
my-site/
|
||||||
|
├── archetypes/
|
||||||
|
│ └── default.md
|
||||||
|
├── assets/
|
||||||
|
├── config/
|
||||||
|
│ └── _default/
|
||||||
|
│ └── hugo.toml
|
||||||
|
├── content/
|
||||||
|
├── data/
|
||||||
|
├── i18n/
|
||||||
|
├── layouts/
|
||||||
|
├── public/ <-- created when you build your site
|
||||||
|
├── resources/ <-- created when you build your site
|
||||||
|
├── static/
|
||||||
|
└── themes/
|
||||||
|
```
|
||||||
|
|
||||||
[`config`](/getting-started/configuration/)
|
## Directories
|
||||||
: Hugo ships with a large number of [configuration directives].
|
|
||||||
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: the `config` directory is not created by default.
|
Each of the subdirectories contributes to the content, structure, behavior, or presentation of your site.
|
||||||
|
|
||||||
[`content`]
|
archetypes
|
||||||
: 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].
|
: The `archetypes` directory contains templates for new content. See [details](/content-management/archetypes/).
|
||||||
|
|
||||||
[`data`](/templates/data-templates/)
|
assets
|
||||||
: This directory is used to store configuration files that can be
|
: The `assets` directory contains global resources typically passed through an asset pipeline. This includes resources such as images, CSS, Sass, JavaScript, and TypeScript. See [details](/hugo-pipes/introduction/).
|
||||||
used by Hugo when generating your website. You can write these files in YAML, JSON, or TOML format. In addition to the files you add to this folder, you can also create [data templates] that pull from dynamic content.
|
|
||||||
|
|
||||||
[`layouts`]
|
config
|
||||||
: Stores templates in the form of `.html` files that specify how views of your content will be rendered into a static website. Templates include [list pages][lists], your [homepage], [taxonomy templates], [partials], [single page templates][singles], and more.
|
: The `config` directory contains your site configuration, possibly split into multiple subdirectories and files. For projects with minimal configuration or projects that do not need to behave differently in different environments, a single configuration file named `hugo.toml` in the root of the project is sufficient. See [details](/getting-started/configuration/#configuration-directory).
|
||||||
|
|
||||||
[`static`]
|
content
|
||||||
: Stores all the static content: images, CSS, JavaScript, etc. When Hugo builds your site, all assets inside your static directory are copied over as-is. A good example of using the `static` folder is for [verifying site ownership on Google Search Console][searchconsole], where you want Hugo to copy over a complete HTML file without modifying its content.
|
: The `content` directory contains the markup files (typically markdown) and page resources that comprise the content of your site. See [details](/content-management/organization/).
|
||||||
|
|
||||||
|
data
|
||||||
|
: The `data` directory contains data files (JSON, TOML, YAML, or XML) that augment content, configuration, localization, and navigation. See [details](/templates/data-templates/).
|
||||||
|
|
||||||
|
i18n
|
||||||
|
: The `i18n` directory contains translation tables for multilingual sites. See [details](/content-management/multilingual/).
|
||||||
|
|
||||||
|
layouts
|
||||||
|
: The layouts directory contains templates to transform content, data, and resources into a complete website. See [details](/templates/).
|
||||||
|
|
||||||
|
public
|
||||||
|
: The `public` directory contains the published website, generated when you run the `hugo` command. Hugo recreates this directory and its content as needed. See [details](/getting-started/usage/#build-your-site).
|
||||||
|
|
||||||
|
resources
|
||||||
|
: The `resources` directory contains cached output from Hugo's asset pipelines, generated when you run the `hugo` or `hugo server` commands. By default this cache directory includes CSS and images. Hugo recreates this directory and its content as needed.
|
||||||
|
|
||||||
|
static
|
||||||
|
: The `static` directory contains files that will be copied to the public directory when you build your site. For example: `favicon.ico`, `robots.txt`, and files that verify site ownership. Before the introduction of [page bundles](/getting-started/glossary/#page-bundle) and [asset pipelines](/hugo-pipes/introduction/), the `static` directory was also used for images, CSS, and JavaScript. See [details](/content-management/static-files/).
|
||||||
|
|
||||||
|
themes
|
||||||
|
: The `themes` directory contains one or more [themes](/getting-started/glossary/#theme), each in its own subdirectory.
|
||||||
|
|
||||||
|
## Union file system
|
||||||
|
|
||||||
|
Hugo creates a union file system, allowing you to mount two or more directories to the same location. For example, let's say your home directory contains a Hugo project in one directory, and shared content in another:
|
||||||
|
|
||||||
|
```text
|
||||||
|
home/
|
||||||
|
└── user/
|
||||||
|
├── my-site/
|
||||||
|
│ ├── content/
|
||||||
|
│ │ ├── books/
|
||||||
|
│ │ │ ├── _index.md
|
||||||
|
│ │ │ ├── book-1.md
|
||||||
|
│ │ │ └── book-2.md
|
||||||
|
│ │ └── _index.md
|
||||||
|
│ ├── themes/
|
||||||
|
│ │ └── my-theme/
|
||||||
|
│ └── hugo.toml
|
||||||
|
└── shared-content/
|
||||||
|
└── films/
|
||||||
|
├── _index.md
|
||||||
|
├── film-1.md
|
||||||
|
└── film-2.md
|
||||||
|
```
|
||||||
|
|
||||||
|
You can include the shared content when you build your site using mounts. In your site configuration:
|
||||||
|
|
||||||
|
{{< code-toggle file=hugo copy=false >}}
|
||||||
|
[[module.mounts]]
|
||||||
|
source = 'content'
|
||||||
|
target = 'content'
|
||||||
|
|
||||||
|
[[module.mounts]]
|
||||||
|
source = '/home/user/shared-content'
|
||||||
|
target = 'content'
|
||||||
|
{{< /code-toggle >}}
|
||||||
|
|
||||||
{{% note %}}
|
{{% note %}}
|
||||||
From **Hugo 0.31** you can have multiple static directories.
|
When you overlay one directory on top of another, you must mount both directories.
|
||||||
|
|
||||||
|
If you think you need a symbolic link in your project directory, use Hugo's union file system instead.
|
||||||
{{% /note %}}
|
{{% /note %}}
|
||||||
|
|
||||||
[`resources`]
|
After mounting, the union file system has this structure:
|
||||||
: Caches some files to speed up generation. Can be also used by template authors to distribute built Sass files, so you don't have to have the preprocessor installed. Note: resources directory is not created by default.
|
|
||||||
|
|
||||||
[archetypes]: /content-management/archetypes/
|
```text
|
||||||
[`assets`]: /hugo-pipes/introduction#asset-directory
|
home/
|
||||||
[configuration directives]: /getting-started/configuration/#all-configuration-settings
|
└── user/
|
||||||
[`content`]: /content-management/organization/
|
└── my-site/
|
||||||
[content section]: /content-management/sections/
|
├── content/
|
||||||
[content types]: /content-management/types/
|
│ ├── books/
|
||||||
[data templates]: /templates/data-templates/
|
│ │ ├── _index.md
|
||||||
[homepage]: /templates/homepage/
|
│ │ ├── book-1.md
|
||||||
[`layouts`]: /templates/
|
│ │ └── book-2.md
|
||||||
[`static`]: /content-management/static-files/
|
│ ├── films/
|
||||||
[`resources`]: /getting-started/configuration/#configure-file-caches
|
│ │ ├── _index.md
|
||||||
[lists]: /templates/lists/
|
│ │ ├── film-1.md
|
||||||
[pagevars]: /variables/page/
|
│ │ └── film-2.md
|
||||||
[partials]: /templates/partials/
|
│ └── _index.md
|
||||||
[searchconsole]: https://support.google.com/webmasters/answer/9008080#zippy=%2Chtml-file-upload
|
├── themes/
|
||||||
[singles]: /templates/single-page-templates/
|
│ └── my-theme/
|
||||||
[taxonomies]: /content-management/taxonomies/
|
└── hugo.toml
|
||||||
[taxonomy templates]: /templates/taxonomy-templates/
|
```
|
||||||
[types]: /content-management/types/
|
|
||||||
|
{{% note %}}
|
||||||
|
When two or more files have the same path, the order of precedence follows the order of the mounts. For example, if the shared content directory contains `books/book-1.md`, it will be ignored because the project's content directory was mounted first.
|
||||||
|
{{% /note %}}
|
||||||
|
|
||||||
|
You can mount directories to `archetypes`, `assets`, `content`, `data`, `i18n`, `layouts`, and `static`. See [details](/hugo-modules/configuration/#module-configuration-mounts).
|
||||||
|
|
||||||
|
You can also mount directories from Git repositories using Hugo Modules. See [details](/hugo-modules/).
|
||||||
|
|
||||||
|
|
||||||
|
## Theme skeleton
|
||||||
|
|
||||||
|
Hugo generates a functional theme skeleton when you create a new theme. For example, this command:
|
||||||
|
|
||||||
|
```text
|
||||||
|
hugo new theme my-theme
|
||||||
|
```
|
||||||
|
|
||||||
|
Creates this directory structure (subdirectories not shown):
|
||||||
|
|
||||||
|
```text
|
||||||
|
my-theme/
|
||||||
|
├── archetypes/
|
||||||
|
├── assets/
|
||||||
|
├── content/
|
||||||
|
├── data/
|
||||||
|
├── i18n/
|
||||||
|
├── layouts/
|
||||||
|
├── static/
|
||||||
|
├── LICENSE
|
||||||
|
├── README.md
|
||||||
|
├── hugo.toml
|
||||||
|
└── theme.toml
|
||||||
|
```
|
||||||
|
|
||||||
|
Using the union file system described above, Hugo mounts each of these directories to the corresponding location in the project. When two files have the same path, the file in the project directory takes precedence. This allows you, for example, to override a theme's template by placing a copy in the same location within the project directory.
|
||||||
|
|
||||||
|
If you are simultaneously using components from two or more themes or modules, and there's a path collision, the first mount takes precedence.
|
||||||
|
|
|
@ -130,7 +130,7 @@ Used within a [template action](#template-action) and associated with an [object
|
||||||
|
|
||||||
### module
|
### module
|
||||||
|
|
||||||
Like a [theme](#theme), a module is a packaged combination of [archetypes](#archetype), assets, content, data, [templates](#template), translations, or configuration settings. A module may serve as the basis for a new site, or to augment an existing site. See [details](/hugo-modules/).
|
Like a [theme](#theme), a module is a packaged combination of [archetypes](#archetype), assets, content, data, [templates](#template), translation tables, static files, or configuration settings. A module may serve as the basis for a new site, or to augment an existing site. See [details](/hugo-modules/).
|
||||||
|
|
||||||
### object
|
### object
|
||||||
|
|
||||||
|
@ -192,9 +192,9 @@ A [template](#template) that overrides standard markdown rendering. See [details
|
||||||
|
|
||||||
### resource
|
### resource
|
||||||
|
|
||||||
Any file consumed by the build process to augment or generate content, structure, behavior, or presentation. For example: images, videos, content snippets, CSS, Sass, Javascript, and data.
|
Any file consumed by the build process to augment or generate content, structure, behavior, or presentation. For example: images, videos, content snippets, CSS, Sass, JavaScript, and data.
|
||||||
|
|
||||||
Hugo supports three types of resources: page resources (located in a [page bundle](/getting-started/glossary/#page-bundle)), global resources (located in the assets directory), and remote resources (typically accessed via https).
|
Hugo supports three types of resources: page resources (located in a [page bundle](/getting-started/glossary/#page-bundle)), global resources (located in the assets directory), and remote resources (typically accessed via HTTPS).
|
||||||
|
|
||||||
### scalar
|
### scalar
|
||||||
|
|
||||||
|
@ -230,7 +230,7 @@ Content with the "taxonomy" [page kind](#page-kind). Typically a listing of [ter
|
||||||
|
|
||||||
### template
|
### template
|
||||||
|
|
||||||
An HTML file with [template actions](#template-action), located within the layouts directory of a project, theme, or module. See [details](/templates/).
|
A file with [template actions](#template-action), located within the layouts directory of a project, theme, or module. See [details](/templates/).
|
||||||
|
|
||||||
### template action
|
### template action
|
||||||
|
|
||||||
|
@ -246,7 +246,7 @@ Content with the "term" [page kind](#page-kind). Typically a listing of [regular
|
||||||
|
|
||||||
### theme
|
### theme
|
||||||
|
|
||||||
A packaged combination of [archetypes](#archetype), assets, content, data, [templates](#template), translations, or configuration settings. A theme may serve as the basis for a new site, or to augment an existing site. See also [module](#module).
|
A packaged combination of [archetypes](#archetype), assets, content, data, [templates](#template), translation tables, static files, or configuration settings. A theme may serve as the basis for a new site, or to augment an existing site. See also [module](#module).
|
||||||
|
|
||||||
### token
|
### token
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,7 @@ Here you will be redirected to login in your GitHub account to get permissions.
|
||||||
7. For which GitHub repository would you like to set up a GitHub workflow? (format: user/repository)
|
7. For which GitHub repository would you like to set up a GitHub workflow? (format: user/repository)
|
||||||
|
|
||||||
Include the repository you will use in the format above (Account/Repo)
|
Include the repository you will use in the format above (Account/Repo)
|
||||||
Firebase script with retrive credentials, create a service account you can later manage in your GitHub settings.
|
Firebase script with retrieve credentials, create a service account you can later manage in your GitHub settings.
|
||||||
|
|
||||||
8. Set up the workflow to run a build script before every deploy?
|
8. Set up the workflow to run a build script before every deploy?
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
---
|
---
|
||||||
title: Host on GitHub Pages
|
title: Host on GitHub Pages
|
||||||
description: Deploy Hugo as a GitHub Pages project or personal/organizational site and automate the whole process with Github Actions
|
description: Deploy Hugo as a GitHub Pages project or personal/organizational site and automate the whole process with GitHub Actions
|
||||||
categories: [hosting and deployment]
|
categories: [hosting and deployment]
|
||||||
keywords: [github,git,deployment,hosting]
|
keywords: [github,git,deployment,hosting]
|
||||||
menu:
|
menu:
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 64 KiB After Width: | Height: | Size: 48 KiB |
|
@ -1,6 +1,6 @@
|
||||||
---
|
---
|
||||||
title: RSS templates
|
title: RSS templates
|
||||||
description: Hugo ships with its own RSS 2.0 template that requires almost no configuration, or you can create your own RSS templates.
|
description: Use the built-in RSS template, or create your own.
|
||||||
keywords: [rss, xml, templates]
|
keywords: [rss, xml, templates]
|
||||||
categories: [templates]
|
categories: [templates]
|
||||||
menu:
|
menu:
|
||||||
|
@ -11,75 +11,81 @@ weight: 160
|
||||||
toc: true
|
toc: true
|
||||||
---
|
---
|
||||||
|
|
||||||
## RSS template lookup order
|
## Configuration
|
||||||
|
|
||||||
See [Template Lookup Order](/templates/lookup-order/) for the complete reference.
|
By default, when you build your site, Hugo generates RSS feeds for home, section, taxonomy, and term pages. Control feed generation in your site configuration. For example, to generate feeds for home and section pages, but not for taxonomy and term pages:
|
||||||
|
|
||||||
{{% note %}}
|
{{< code-toggle file=hugo copy=false >}}
|
||||||
Hugo ships with its own [RSS 2.0 template](#the-embedded-rssxml-template). The embedded template will be sufficient for most use cases.
|
[outputs]
|
||||||
{{% /note %}}
|
home = ['html', 'rss']
|
||||||
|
section = ['html', 'rss']
|
||||||
RSS pages are of the type `Page` and have all the [page variables](/variables/page/) available to use in the templates.
|
taxonomy = ['html']
|
||||||
|
term = ['html']
|
||||||
### Section RSS
|
|
||||||
|
|
||||||
A [section’s][section] RSS will be rendered at `/<SECTION>/index.xml` (e.g., [https://spf13.com/project/index.xml](https://spf13.com/project/index.xml)).
|
|
||||||
|
|
||||||
Hugo provides the ability for you to define any RSS type you wish and can have different RSS files for each section and taxonomy.
|
|
||||||
|
|
||||||
## Lookup order for RSS templates
|
|
||||||
|
|
||||||
The table below shows the RSS template lookup order for the different page kinds. The first listing shows the lookup order when running with a theme (`demoTheme`).
|
|
||||||
|
|
||||||
{{< datatable-filtered "output" "layouts" "OutputFormat == RSS" "Example" "OutputFormat" "Suffix" "Template Lookup Order" >}}
|
|
||||||
|
|
||||||
## Configure RSS
|
|
||||||
|
|
||||||
By default, Hugo will create an unlimited number of RSS entries. You can limit the number of articles included in the built-in RSS templates by assigning a numeric value to `rssLimit:` field in your project's configuration file.
|
|
||||||
|
|
||||||
The following values will also be included in the RSS output if specified:
|
|
||||||
|
|
||||||
{{< code-toggle file="hugo" >}}
|
|
||||||
languageCode = "en-us"
|
|
||||||
copyright = "This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License."
|
|
||||||
|
|
||||||
[author]
|
|
||||||
name = "My Name Here"
|
|
||||||
{{< /code-toggle >}}
|
{{< /code-toggle >}}
|
||||||
|
|
||||||
## The embedded rss.xml template
|
To disable feed generation for all [page kinds]:
|
||||||
|
|
||||||
This is the default RSS template that ships with Hugo:
|
{{< code-toggle file=hugo copy=false >}}
|
||||||
|
disableKinds = ['rss']
|
||||||
|
{{< /code-toggle >}}
|
||||||
|
|
||||||
<https://github.com/gohugoio/hugo/blob/master/tpl/tplimpl/embedded/templates/_default/rss.xml>
|
By default, the number of items in each feed is unlimited. Change this as needed in your site configuration:
|
||||||
|
|
||||||
## Reference your RSS feed in `<head>`
|
{{< code-toggle file=hugo copy=false >}}
|
||||||
|
[services.rss]
|
||||||
|
limit = 42
|
||||||
|
{{< /code-toggle >}}
|
||||||
|
|
||||||
In your `header.html` template, you can specify your RSS feed in your `<head></head>` tag using Hugo's [Output Formats][Output Formats] like this:
|
Set `limit` to `-1` to generate an unlimited number of items per feed.
|
||||||
|
|
||||||
```go-html-template
|
The built-in RSS template will render the following values, if present, from your site configuration:
|
||||||
{{ range .AlternativeOutputFormats -}}
|
|
||||||
{{ printf `<link rel="%s" type="%s" href="%s" title="%s" />` .Rel .MediaType.Type .Permalink $.Site.Title | safeHTML }}
|
|
||||||
{{ end -}}
|
|
||||||
```
|
|
||||||
|
|
||||||
If you only want the RSS link, you can query the formats:
|
{{< code-toggle file=hugo copy=false >}}
|
||||||
|
copyright = '© 2023 ABC Widgets, Inc.'
|
||||||
|
[author]
|
||||||
|
name = 'John Doe'
|
||||||
|
email = 'jdoe@example.org'
|
||||||
|
{{< /code-toggle >}}
|
||||||
|
|
||||||
|
## Include feed reference
|
||||||
|
|
||||||
|
To include a feed reference in the `head` element of your rendered pages, place this within the `head` element of your templates:
|
||||||
|
|
||||||
```go-html-template
|
```go-html-template
|
||||||
{{ with .OutputFormats.Get "rss" -}}
|
{{ with .OutputFormats.Get "rss" -}}
|
||||||
{{ printf `<link rel="%s" type="%s" href="%s" title="%s" />` .Rel .MediaType.Type .Permalink $.Site.Title | safeHTML }}
|
{{ printf `<link rel=%q type=%q href=%q title=%q>` .Rel .MediaType.Type .Permalink site.Title | safeHTML }}
|
||||||
{{ end -}}
|
{{ end }}
|
||||||
```
|
```
|
||||||
|
|
||||||
Either of the two snippets above will generate the below `link` tag on the site homepage for RSS output:
|
Hugo will render this to:
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<link rel="alternate" type="application/rss+xml" href="https://example.com/index.xml" title="Site Title">
|
<link rel="alternate" type="application/rss+xml" href="https://example.org/index.xml" title="ABC Widgets">
|
||||||
```
|
```
|
||||||
|
|
||||||
_We are assuming `BaseURL` to be `https://example.com/` and `$.Site.Title` to be `"Site Title"` in this example._
|
## Custom templates
|
||||||
|
|
||||||
[embedded]: #the-embedded-rss-xml
|
Override Hugo's [built-in RSS template] by creating one or more of your own, following the naming conventions as shown in the [template lookup order table].
|
||||||
[RSS 2.0]: https://cyber.harvard.edu/rss/rss.html "RSS 2.0 Specification"
|
|
||||||
[section]: /content-management/sections/
|
For example, to use different templates for home, section, taxonomy, and term pages:
|
||||||
[Output Formats]: /templates/output-formats/#link-to-output-formats
|
|
||||||
|
```text
|
||||||
|
layouts/
|
||||||
|
└── _default/
|
||||||
|
├── home.rss.xml
|
||||||
|
├── section.rss.xml
|
||||||
|
├── taxonomy.rss.xml
|
||||||
|
└── term.rss.xml
|
||||||
|
```
|
||||||
|
|
||||||
|
RSS templates receive the `.Page` and `.Site` objects in context.
|
||||||
|
|
||||||
|
[built-in RSS template]: https://github.com/gohugoio/hugo/blob/master/tpl/tplimpl/embedded/templates/_default/rss.xml
|
||||||
|
[page kinds]: /getting-started/glossary/#page-kind
|
||||||
|
[template lookup order table]: #template-lookup-order
|
||||||
|
|
||||||
|
## Template lookup order
|
||||||
|
|
||||||
|
The table below shows the RSS template lookup order for the different page kinds. The first listing shows the lookup order when running with a theme (`demoTheme`).
|
||||||
|
|
||||||
|
{{< datatable-filtered "output" "layouts" "OutputFormat == rss" "Example" "OutputFormat" "Suffix" "Template Lookup Order" >}}
|
||||||
|
|
|
@ -27,10 +27,6 @@ Alternatively, you can use the new [Jekyll import command](/commands/hugo_import
|
||||||
- [JekyllToHugo](https://github.com/fredrikloch/JekyllToHugo) - A Small script for converting Jekyll blog posts to a Hugo site.
|
- [JekyllToHugo](https://github.com/fredrikloch/JekyllToHugo) - A Small script for converting Jekyll blog posts to a Hugo site.
|
||||||
- [ConvertToHugo](https://github.com/coderzh/ConvertToHugo) - Convert your blog from Jekyll to Hugo.
|
- [ConvertToHugo](https://github.com/coderzh/ConvertToHugo) - Convert your blog from Jekyll to Hugo.
|
||||||
|
|
||||||
## Ghost
|
|
||||||
|
|
||||||
- [ghostToHugo](https://github.com/jbarone/ghostToHugo) - Convert Ghost blog posts and export them to Hugo.
|
|
||||||
|
|
||||||
## Octopress
|
## Octopress
|
||||||
|
|
||||||
- [octohug](https://github.com/codebrane/octohug) - Octopress to Hugo migrator.
|
- [octohug](https://github.com/codebrane/octohug) - Octopress to Hugo migrator.
|
||||||
|
|
|
@ -36,7 +36,7 @@ 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 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:
|
* 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
|
* 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)
|
* 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:
|
Also see this Twitter thread:
|
||||||
|
@ -47,7 +47,7 @@ Also see this Twitter thread:
|
||||||
|
|
||||||
## Can I use the latest Hugo version on Netlify?
|
## Can I use the latest Hugo version on Netlify?
|
||||||
|
|
||||||
Yes you can! Read [this](/hosting-and-deployment/hosting-on-netlify/#configure-hugo-version-in-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"
|
## I get "... this feature is not available in your current Hugo version"
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ Hugo's Git integrations should be fairly performant but *can* increase your buil
|
||||||
|
|
||||||
1. The Hugo site must be in a Git-enabled directory.
|
1. The Hugo site must be in a Git-enabled directory.
|
||||||
2. The Git executable must be installed and in your system `PATH`.
|
2. The Git executable must be installed and in your system `PATH`.
|
||||||
3. The `.GitInfo` feature must be enabled in your Hugo project by passing `--enableGitInfo` flag on the command line or by setting `enableGitInfo` to `true` in your [site's configuration file][configuration].
|
3. The `.GitInfo` feature must be enabled in your Hugo project by passing `--enableGitInfo` flag on the command line or by setting `enableGitInfo` to `true` in your [site's configuration file][configuration].
|
||||||
|
|
||||||
## The `.GitInfo` object
|
## The `.GitInfo` object
|
||||||
|
|
||||||
|
@ -49,3 +49,24 @@ The `GitInfo` object contains the following fields:
|
||||||
If the `.GitInfo` feature is enabled, `.Lastmod` (on `Page`) is fetched from Git i.e. `.GitInfo.AuthorDate`. This behavior can be changed by adding your own [front matter configuration for dates](/getting-started/configuration/#configure-front-matter).
|
If the `.GitInfo` feature is enabled, `.Lastmod` (on `Page`) is fetched from Git i.e. `.GitInfo.AuthorDate`. This behavior can be changed by adding your own [front matter configuration for dates](/getting-started/configuration/#configure-front-matter).
|
||||||
|
|
||||||
[configuration]: /getting-started/configuration/
|
[configuration]: /getting-started/configuration/
|
||||||
|
|
||||||
|
## Hosting considerations
|
||||||
|
|
||||||
|
On the site host, your repository must be "deep-cloned," so the returned `.GitInfo` data will be accurate. Otherwise, your site may display only data from your latest commit. Where it's not possible to configure a host's cloning depth, you must handle this through CI/CD (*e.g.*, a
|
||||||
|
GitHub Action or GitLab CI/CD). See the following table:
|
||||||
|
|
||||||
|
| Hosting service | Clone depth | Configurable? |
|
||||||
|
| :-------------- | :---------- | :-----------: |
|
||||||
|
| Cloudflare Pages | Shallow | ✔️ [^CFP] |
|
||||||
|
| DigitalOcean App Platform | Deep | ❌ |
|
||||||
|
| GitHub Pages | Shallow | ✔️ [^GHP] |
|
||||||
|
| GitLab Pages | Shallow | ✔️ [^GLP] |
|
||||||
|
| Netlify | Deep | ❌ |
|
||||||
|
| Render | Shallow | ❌ |
|
||||||
|
| Vercel | Shallow | ❌ |
|
||||||
|
|
||||||
|
[^CFP]: To configure a Cloudflare Pages site for deep cloning, preface the site's normal Hugo build command with `git fetch --unshallow &&` (*e.g.*, `git fetch --unshallow && hugo`).
|
||||||
|
|
||||||
|
[^GHP]: You can configure the GitHub Action to do a deep clone by specifying `fetch-depth: 0` in the applicable "checkout" step of your workflow file, as shown in the Hugo documentation's [example workflow file](/hosting-and-deployment/hosting-on-github/#procedure).
|
||||||
|
|
||||||
|
[^GLP]: You can configure the GitLab Runner's clone depth [as explained in the GitLab documentation](https://docs.gitlab.com/ee/ci/large_repositories/#shallow-cloning); see also the Hugo documentation's [example workflow file](https://gohugo.io/hosting-and-deployment/hosting-on-gitlab/#configure-gitlab-cicd).
|
||||||
|
|
|
@ -1018,6 +1018,10 @@ config:
|
||||||
defaultMarkdownHandler: goldmark
|
defaultMarkdownHandler: goldmark
|
||||||
goldmark:
|
goldmark:
|
||||||
extensions:
|
extensions:
|
||||||
|
cjk:
|
||||||
|
eastAsianLineBreaks: false
|
||||||
|
enable: false
|
||||||
|
escapedSpace: false
|
||||||
definitionList: true
|
definitionList: true
|
||||||
footnote: true
|
footnote: true
|
||||||
linkify: true
|
linkify: true
|
||||||
|
|
30
netlify.toml
30
netlify.toml
|
@ -1,30 +1,30 @@
|
||||||
[build]
|
[build]
|
||||||
publish = "public"
|
publish = "public"
|
||||||
command = "hugo --gc --minify"
|
command = "hugo --gc --minify"
|
||||||
|
|
||||||
[build.environment]
|
[build.environment]
|
||||||
HUGO_VERSION = "0.117.0"
|
HUGO_VERSION = "0.118.2"
|
||||||
|
|
||||||
[context.production.environment]
|
[context.production.environment]
|
||||||
HUGO_ENV = "production"
|
HUGO_ENV = "production"
|
||||||
HUGO_ENABLEGITINFO = "true"
|
HUGO_ENABLEGITINFO = "true"
|
||||||
|
|
||||||
[context.split1]
|
[context.split1]
|
||||||
command = "hugo --gc --minify --enableGitInfo"
|
command = "hugo --gc --minify --enableGitInfo"
|
||||||
|
|
||||||
[context.split1.environment]
|
[context.split1.environment]
|
||||||
HUGO_ENV = "production"
|
HUGO_ENV = "production"
|
||||||
|
|
||||||
[context.deploy-preview]
|
[context.deploy-preview]
|
||||||
command = "hugo --gc --minify --buildFuture -b $DEPLOY_PRIME_URL"
|
command = "hugo --gc --minify --buildFuture -b $DEPLOY_PRIME_URL"
|
||||||
|
|
||||||
[context.branch-deploy]
|
[context.branch-deploy]
|
||||||
command = "hugo --gc --minify -b $DEPLOY_PRIME_URL"
|
command = "hugo --gc --minify -b $DEPLOY_PRIME_URL"
|
||||||
|
|
||||||
[context.next.environment]
|
[context.next.environment]
|
||||||
HUGO_ENABLEGITINFO = "true"
|
HUGO_ENABLEGITINFO = "true"
|
||||||
|
|
||||||
[[redirects]]
|
[[redirects]]
|
||||||
from = "/npmjs/*"
|
from = "/npmjs/*"
|
||||||
to = "/npmjs/"
|
to = "/npmjs/"
|
||||||
status = 200
|
status = 200
|
||||||
|
|
Loading…
Reference in a new issue