mirror of
https://github.com/gohugoio/hugo.git
synced 2026-08-24 15:28:54 +00:00
@@ -84,7 +84,7 @@ Similar to the [lookup order for templates][lookup] in your `layouts` directory,
|
||||
If you wish to use archetypes that ship with a theme, the `theme` field must be specified in your [configuration file](/getting-started/configuration/).
|
||||
{{% /note %}}
|
||||
|
||||
## Choosing Your Archetype's Front Matter Format
|
||||
## Choose Your Archetype's Front Matter Format
|
||||
|
||||
By default, `hugo new` content files include front matter in the TOML format regardless of the format used in `archetypes/*.md`.
|
||||
|
||||
@@ -94,7 +94,7 @@ You can specify a different default format in your site [configuration file][] f
|
||||
|
||||
Default archetypes are convenient if your content's front matter stays consistent across multiple [content sections][sections].
|
||||
|
||||
### Creating the Default Archetype
|
||||
### Create the Default Archetype
|
||||
|
||||
When you create a new Hugo project using `hugo new site`, you'll notice that Hugo has already scaffolded a file at `archetypes/default.md`.
|
||||
|
||||
@@ -113,7 +113,7 @@ categories = ["web development"]
|
||||
If you get an `EOF error` when using `hugo new`, add a carriage return after the closing `+++` or `---` for your TOML or YAML front matter, respectively. (See the [troubleshooting article on EOF errors](/troubleshooting/eof-error/) for more information.)
|
||||
{{% /warning %}}
|
||||
|
||||
### Using the Default Archetype
|
||||
### Use the Default Archetype
|
||||
|
||||
With an `archetypes/default.md` in place, we can use the CLI to create a new post in the `posts` content section:
|
||||
|
||||
@@ -146,7 +146,7 @@ You may notice that content files created with `hugo new` do not respect the ord
|
||||
|
||||
Suppose your site's `posts` section requires more sophisticated front matter than what has been specified in `archetypes/default.md`. You can create a custom archetype for your posts at `archetypes/posts.md` that includes the full set of front matter to be added to the two default archetypes fields.
|
||||
|
||||
### Creating a Custom Archetype
|
||||
### Create a Custom Archetype
|
||||
|
||||
{{% code file="archetypes/posts.md"%}}
|
||||
```toml
|
||||
@@ -158,7 +158,7 @@ categories = ""
|
||||
```
|
||||
{{% /code %}}
|
||||
|
||||
### Using a Custom Archetype
|
||||
### Use a Custom Archetype
|
||||
|
||||
With an `archetypes/posts.md` in place, you can use the Hugo CLI to create a new post with your preconfigured front matter in the `posts` content section:
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ The `social` section contains all the links to the social network accounts of an
|
||||
|
||||
The `params` section can contain arbitrary data much like the same-named section in the config file. What it contains is up to you.
|
||||
|
||||
## Associating Content Through Identifiers
|
||||
## Associate Content Through Identifiers
|
||||
|
||||
Earlier it was mentioned that content can be associated with an author through their corresponding identifier. In our case, blogger Alice has the identifier `alice`. In the front matter of a content file, you can create a list of identifiers and assign it to the `authors` variable. Here are examples for `alice` using YAML and TOML, respectively.
|
||||
|
||||
@@ -89,7 +89,7 @@ Nothing to read here. Move along...
|
||||
|
||||
Future authors who might work on this blog post can append their identifiers to the `authors` array in the front matter as well.
|
||||
|
||||
## Working with Templates
|
||||
## Work with Templates
|
||||
|
||||
After a successful setup it's time to give some credit to the authors by showing them on the website. Within the templates Hugo provides a list of the author's profiles if they are listed in the `authors` variable within the front matter.
|
||||
|
||||
@@ -108,7 +108,7 @@ Even if there are co-authors you may only want to show the main author. For this
|
||||
You can find a list of all template variables to access the profile information in [Author Variables](/variables/authors/).
|
||||
{{% /note %}}
|
||||
|
||||
### Linking Social Network Accounts
|
||||
### Link Social Network Accounts
|
||||
|
||||
As aforementioned, Hugo is able to generate links to profiles of the most popular social networks. The following social networks with their corrersponding identifiers are supported: `github`, `facebook`, `twitter`, `googleplus`, `pinterest`, `instagram`, `youtube` and `linkedin`.
|
||||
|
||||
@@ -148,7 +148,7 @@ taxonomies:
|
||||
```
|
||||
|
||||
|
||||
### Listing All Authors
|
||||
### List All Authors
|
||||
|
||||
In the next step we can create a template to list all authors of your website. Later, the list can be accessed at `www.example.com/authors/`. Create a new template in the `layouts/taxonomy/` directory called `authors.term.html`. This template will be exclusively used for this taxonomy.
|
||||
|
||||
@@ -169,7 +169,7 @@ In the next step we can create a template to list all authors of your website. L
|
||||
|
||||
`.Data.Terms` contains the identifiers of all authors and we can range over it to create a list with all author names. The `$profile` variable gives us access to the profile of the current author. This allows you to generate a nice info box with a thumbnail, a biography and social media links, like at the [end of a blog post](#linking-social-network-accounts-automatically).
|
||||
|
||||
### Listing Each Author's Publications
|
||||
### List Each Author's Publications
|
||||
|
||||
Last but not least, we have to create the second list that contains all publications of an author. Each list will be shown in its own page and can be accessed at `www.example.com/authors/<IDENTIFIER>`. Replace `<IDENTIFIER>` with a valid author identifier like `alice`.
|
||||
|
||||
|
||||
@@ -21,11 +21,11 @@ Hugo ships with support for [Disqus](https://disqus.com/), a third-party service
|
||||
|
||||
Your theme may already support Disqus, but if not, it is easy to add to your templates via [Hugo's built-in Disqus partial][disquspartial].
|
||||
|
||||
## Adding Disqus
|
||||
## Add Disqus
|
||||
|
||||
Hugo comes with all the code you need to load Disqus into your templates. Before adding Disqus to your site, you'll need to [set up an account][disqussetup].
|
||||
|
||||
### Configuring Disqus
|
||||
### Configure Disqus
|
||||
|
||||
Disqus comments require you set a single value in your [site's configuration file][configuration]. The following show the configuration variable in a `config.toml` and `config.yml`, respectively:
|
||||
|
||||
@@ -43,11 +43,11 @@ For many websites, this is enough configuration. However, you also have the opti
|
||||
* `disqus_title`
|
||||
* `disqus_url`
|
||||
|
||||
### Rendering Hugo's Built-in Disqus Partial Template
|
||||
### Render Hugo's Built-in Disqus Partial Template
|
||||
|
||||
See [Partial Templates][partials] to learn how to add the Disqus partial to your Hugo website's templates.
|
||||
|
||||
## Commenting Alternatives
|
||||
## Comments Alternatives
|
||||
|
||||
There are a few alternatives to commenting on static sites for those who do not want to use Disqus:
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ toc: true
|
||||
|
||||
The `ref` and `relref` shortcodes link documents together, both of which are [built-in Hugo shortcodes][]. These shortcodes are also used to provide links to headings inside of your content, whether across documents or within a document. The only difference between `ref` and `relref` is whether the resulting URL is absolute (`http://1.com/about/`) or relative (`/about/`), respectively.
|
||||
|
||||
## Using `ref` and `relref`
|
||||
## Use `ref` and `relref`
|
||||
|
||||
```md
|
||||
{{</* ref "document" */>}}
|
||||
|
||||
@@ -25,13 +25,13 @@ For Emacs users, [goorgeous](https://github.com/chaseadamsio/goorgeous) provides
|
||||
Before you begin writing your content in markdown, Blackfriday has a known issue [(#329)](https://github.com/russross/blackfriday/issues/329) with handling deeply nested lists. Luckily, there is an easy workaround. Use 4-spaces (i.e., <kbd>tab</kbd>) rather than 2-space indentations.
|
||||
{{% /note %}}
|
||||
|
||||
## Configuring BlackFriday Markdown Rendering
|
||||
## Configure BlackFriday Markdown Rendering
|
||||
|
||||
You can configure multiple aspects of Blackfriday as show in the following list. See the docs on [Configuration][config] for the full list of explicit directions you can give to Hugo when rendering your site.
|
||||
|
||||
{{< readfile file="/content/readfiles/bfconfig.md" markdown="true" >}}
|
||||
|
||||
## Extending Markdown
|
||||
## Extend Markdown
|
||||
|
||||
Hugo provides some convenient methods for extending markdown.
|
||||
|
||||
@@ -92,7 +92,7 @@ Hugo supports GitHub-flavored markdown's use of triple back ticks, as well as pr
|
||||
|
||||
Mmark is a [fork of BlackFriday][mmark] and markdown superset that is well suited for writing [IETF documentation][ietf]. You can see examples of the syntax in the [Mmark GitHub repository][mmarkgh] or the full syntax on [Miek Gieben's website][].
|
||||
|
||||
### Using Mmark
|
||||
### Use Mmark
|
||||
|
||||
As Hugo ships with Mmark, using the syntax is as easy as changing the extension of your content files from `.md` to `.mmark`.
|
||||
|
||||
@@ -116,7 +116,7 @@ Thare are some features not available in Mmark; one example being that shortcode
|
||||
|
||||
This is not an introduction into actually using MathJax to render typeset mathematics on your website. Instead, this page is a collection of tips and hints for one way to get MathJax working on a website built with Hugo.
|
||||
|
||||
### Enabling MathJax
|
||||
### Enable MathJax
|
||||
|
||||
The first step is to enable MathJax on pages that you would like to have typeset math. There are multiple ways to do this (adventurous readers can consult the [Loading and Configuring](http://docs.mathjax.org/en/latest/configuration.html) section of the MathJax documentation for additional methods of including MathJax), but the easiest way is to use the secure MathJax CDN by include a `<script>` tag for the officially recommended secure CDN ([cdn.js.com](https://cdnjs.com)):
|
||||
|
||||
|
||||
@@ -162,11 +162,11 @@ show_comments: false
|
||||
These two user-defined fields can then be accessed via `.Params.include_toc` and `.Params.show_comments`, respectively. The [Variables][variables] section provides more information on using Hugo's page- and site-level variables in your templates.
|
||||
|
||||
|
||||
## Ordering Content Through Front Matter
|
||||
## Order Content Through Front Matter
|
||||
|
||||
You can assign content-specific `weight` in the front matter of your content. These values are especially useful for [ordering][ordering] in list views. You can use `weight` for ordering of content and the convention of [`<TAXONOMY>_weight`][taxweight] for ordering content within a taxonomy. See [Ordering and Grouping Hugo Lists][lists] to see how `weight` can be used to organize your content in list views.
|
||||
|
||||
## Overriding Global Markdown Configuration
|
||||
## Override Global Markdown Configuration
|
||||
|
||||
It's possible to set some options for Markdown rendering in a content's front matter as an override to the [BlackFriday rendering options set in your project configuration][config].
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@ Additionally, there are some relevant functions available to menus on a page:
|
||||
`.HasMenuCurrent`
|
||||
: (menu string, menuEntry *MenuEntry) boolean
|
||||
|
||||
## Adding content to menus
|
||||
## Add content to menus
|
||||
|
||||
Hugo allows you to add content to a menu via the content's [front matter](/content-management/front-matter/).
|
||||
|
||||
@@ -114,7 +114,7 @@ menu:
|
||||
---
|
||||
```
|
||||
|
||||
## Adding Non-content Entries to a Menu
|
||||
## Add Non-content Entries to a Menu
|
||||
|
||||
You can also add entries to menus that aren’t attached to a piece of content. This takes place in your Hugo project's [`config` file][config].
|
||||
|
||||
@@ -161,7 +161,7 @@ The URLs must be relative to the context root. If the `baseURL` is `http://examp
|
||||
{{% /note %}}
|
||||
|
||||
## Nesting
|
||||
|
||||
|
||||
All nesting of content is done via the `parent` field.
|
||||
|
||||
The parent of an entry should be the identifier of another entry. The identifier should be unique (within a menu).
|
||||
@@ -174,7 +174,7 @@ This means that `.Title` will be used unless `.LinkTitle` is present, etc. In pr
|
||||
|
||||
In this example, the top level of the menu is defined in your [site `config` file][config]). All content entries are attached to one of these entries via the `.Parent` field.
|
||||
|
||||
## Rendering Menus
|
||||
## Render Menus
|
||||
|
||||
See [Menu Templates](/templates/menu-templates/) for information on how to render your site menus within your templates.
|
||||
|
||||
|
||||
@@ -90,7 +90,7 @@ plaque = "plaques"
|
||||
```
|
||||
{{% /code %}}
|
||||
|
||||
## Translating Your Content
|
||||
## Translate Your Content
|
||||
|
||||
Translated articles are identified by the name of the content file.
|
||||
|
||||
|
||||
@@ -156,7 +156,7 @@ The `url` is the relative URL for the piece of content. The `url`
|
||||
* is based on the content's location within the directory structure OR
|
||||
* is defined in front matter and *overrides all the above*
|
||||
|
||||
## Overriding Destination Paths via Front Matter
|
||||
## Override Destination Paths via Front Matter
|
||||
|
||||
Hugo believes that you organize your content with a purpose. The same structure that works to organize your source content is used to organize the rendered site. As displayed above, the organization of the source content will be mirrored in the destination.
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ A shortcode is a simple snippet inside a content file that Hugo will render usin
|
||||
|
||||
In addition to cleaner Markdown, shortcodes can be updated any time to reflect new classes, techniques, or standards. At the point of site generation, Hugo shortcodes will easily merge in your changes. You avoid a possibly complicated search and replace operation.
|
||||
|
||||
## Using Shortcodes
|
||||
## Use Shortcodes
|
||||
|
||||
In your content files, a shortcode can be called by calling `{{%/* shortcodename parameters */%}}`. Shortcode parameters are space delimited, and parameters with internal spaces can be quoted.
|
||||
|
||||
@@ -68,7 +68,7 @@ The `<` character indicates that the shortcode's inner content does *not* need f
|
||||
|
||||
You can call shortcodes within other shortcodes by creating your own templates that leverage the `.Parent` variable. `.Parent` allows you to check the context in which the shortcode is being called. See [Shortcode templates][sctemps].
|
||||
|
||||
## Using Hugo's Built-in Shortcodes
|
||||
## Use Hugo's Built-in Shortcodes
|
||||
|
||||
Hugo ships with a set of predefined shortcodes that represent very common usage. These shortcodes are provided for author convenience and to keep your markdown content clean.
|
||||
|
||||
@@ -409,7 +409,7 @@ Using the preceding `youtube` example (without `autoplay="true"`), the following
|
||||
|
||||
{{< youtube w7Ft2ymGmfc >}}
|
||||
|
||||
## Creating Custom Shortcodes
|
||||
## Create Custom Shortcodes
|
||||
|
||||
To learn more about creating custom shortcodes, see the [shortcode template documentation][].
|
||||
|
||||
|
||||
@@ -97,7 +97,7 @@ When taxonomies are used---and [taxonomy templates][] are provided---Hugo will a
|
||||
* A single page at `yoursite.com/categories/` that lists all the [terms within the taxonomy][]
|
||||
* [Individual taxonomy list pages][taxonomy templates] (e.g., `/categories/development/`) for each of the terms that shows a listing of all pages marked as part of that taxonomy within any content file's [front matter][]
|
||||
|
||||
## Configuring Taxonomies
|
||||
## Configure Taxonomies
|
||||
|
||||
Taxonomies must be defined in your [website configuration][config] before they can be used throughout the site. You need to provide both the plural and singular labels for each taxonomy. For example, `singular key = "plural value"` for TOML and `singular key: "plural value"` for YAML.
|
||||
|
||||
@@ -119,7 +119,7 @@ taxonomies:
|
||||
series: "series"
|
||||
```
|
||||
|
||||
### Preserving Taxonomy Values
|
||||
### Preserve Taxonomy Values
|
||||
|
||||
By default, taxonomy names are normalized.
|
||||
|
||||
@@ -133,7 +133,7 @@ You can add content and front matter to your taxonomy list and taxonomy terms pa
|
||||
Note also that taxonomy [permalinks](/content-management/urls/) are *not* configurable.
|
||||
{{% /note %}}
|
||||
|
||||
## Adding Taxonomies to Content
|
||||
## Add Taxonomies to Content
|
||||
|
||||
Once a taxonomy is defined at the site level, any piece of content can be assigned to it, regardless of [content type][] or [content section][].
|
||||
|
||||
@@ -191,7 +191,7 @@ project_url: "https://github.com/gohugoio/hugo"
|
||||
}
|
||||
```
|
||||
|
||||
## Ordering Taxonomies
|
||||
## Order Taxonomies
|
||||
|
||||
A content file can assign weight for each of its associate taxonomies. Taxonomic weight can be used for sorting or ordering content in [taxonomy list templates][] and is declared in a content file's [front matter][]. The convention for declaring taxonomic weight is `taxonomyname_weight`.
|
||||
|
||||
|
||||
@@ -23,17 +23,17 @@ A **content type** can have a unique set of metadata (i.e., [front matter][]) or
|
||||
|
||||
[Tumblr][] is a good example of a website with multiple content types. A piece of "content" could be a photo, quote, or a post, each with different sets of metadata and different visual rendering.
|
||||
|
||||
## Assigning a Content Type
|
||||
## Assign a Content Type
|
||||
|
||||
Hugo assumes that your site will be organized into [sections][] and each section represents a corresponding type. This is to reduce the amount of configuration necessary for new Hugo projects.
|
||||
|
||||
If you are taking advantage of this default behavior, each new piece of content you place into a section will automatically inherit the type. Therefore a new file created at `content/posts/new-post.md` will automatically be assigned the type `posts`. Alternatively, you can set the content type in a content file's [front matter][] in the field "`type`".
|
||||
|
||||
## Creating New Content of a Specific Type
|
||||
## Create New Content of a Specific Type
|
||||
|
||||
You can manually add files to your content directories, but Hugo can create and populate a new content file with preconfigured front matter via [archetypes][].
|
||||
|
||||
## Defining a Content Type
|
||||
## Define a Content Type
|
||||
|
||||
Creating a new content type is easy. You simply define the templates and archetype unique to your new content type, or Hugo will use defaults.
|
||||
|
||||
|
||||
@@ -166,8 +166,7 @@ Assuming a `baseURL` of `yoursite.com`, the contents of the auto-generated alias
|
||||
|
||||
The `http-equiv="refresh"` line is what performs the redirect, in 0 seconds in this case. If an end user of your website goes to `https://yoursite.com/posts/my-old-url`, they will now be automatically redirected to the newer, correct URL. The addition of `<meta name=\"robots\" content=\"noindex\">` lets search engine bots know they they should not crawl and index your new alias page.
|
||||
|
||||
### Customizing
|
||||
|
||||
### Customize
|
||||
You may customize this alias page by creating an `alias.html` template in the
|
||||
layouts folder of your site (i.e., `layouts/alias.html`). In this case, the data passed to the template is
|
||||
|
||||
@@ -264,7 +263,7 @@ Or, if you are on Windows and do not have `grep` installed:
|
||||
hugo config | FINDSTR /I canon
|
||||
```
|
||||
|
||||
## Overriding URLS with Front Matter
|
||||
## Override URLS with Front Matter
|
||||
|
||||
In addition to specifying permalink values in your site configuration for different content sections, Hugo provides even more granular control for individual pieces of content.
|
||||
|
||||
|
||||
@@ -34,13 +34,13 @@ This contribution guide takes a step-by-step approach in hopes of helping newcom
|
||||
If you're struggling at any point in this contribution guide, reach out to the Hugo community in [Hugo's Discussion forum](https://discourse.gohugo.io).
|
||||
{{% /note %}}
|
||||
|
||||
## Installing Go
|
||||
## Install Go
|
||||
|
||||
The installation of Go should take only a few minutes. You have more than one option to get Go up and running on your machine.
|
||||
|
||||
If you are having trouble following the installation guides for go, check out [Go Bootcamp, which contains setups for every platform][gobootcamp] or reach out to the Hugo community in the [Hugo Discussion Forums][forums].
|
||||
|
||||
### Installing Go From Source
|
||||
### Install Go From Source
|
||||
|
||||
[Download the latest stable version of Go][godl] and follow the official [Golang installation guide][goinstall].
|
||||
|
||||
@@ -64,7 +64,7 @@ You can print the `GOPATH` with `echo $GOPATH`. You should see a non-empty strin
|
||||
/Users/<yourusername>/Code/go
|
||||
```
|
||||
|
||||
### Installing Go with Homebrew
|
||||
### Install Go with Homebrew
|
||||
|
||||
If you are a macOS user and have [Homebrew](https://brew.sh/) installed on your machine, installing Go is as simple as the following command:
|
||||
|
||||
@@ -80,11 +80,11 @@ More experienced users can use the [Go Version Manager][gvm] (GVM). GVM allows y
|
||||
|
||||
GVM comes in especially handy if you follow the development of Hugo over a longer period of time. Future versions of Hugo will usually be compiled with the latest version of Go. Sooner or later, you will have to upgrade if you want to keep up.
|
||||
|
||||
## Creating a GitHub Account
|
||||
## Create a GitHub Account
|
||||
|
||||
If you're going to contribute code, you'll need to have an account on GitHub. Go to [www.github.com/join](https://github.com/join) and set up a personal account.
|
||||
|
||||
## Installing Git on Your System
|
||||
## Install Git on Your System
|
||||
|
||||
You will need to have Git installed on your computer to contribute to Hugo development. Teaching git is outside the scope of the Hugo docs, but if you're looking for an excellent reference to learn the basics of Git, we recommend the [Git book][gitbook] if you are not sure where to begin. The used terminology will be explained with annotations.
|
||||
|
||||
@@ -217,7 +217,7 @@ git checkout -b <BRANCH-NAME>
|
||||
|
||||
You can check on which branch your are with `git branch`. You should see a list of all local branches. The current branch is indicated with a little asterisk.
|
||||
|
||||
### Contributing to Documentation
|
||||
### Contribute to Documentation
|
||||
|
||||
Perhaps you want to start contributing to the Hugo docs. If so, you can ignore most of the following steps and focus on the `/docs` directory within your newly cloned repository. You can change directories into the Hugo docs using `cd docs`.
|
||||
|
||||
@@ -225,7 +225,7 @@ You can start Hugo's built-in server via `hugo server`. Browse the documentation
|
||||
|
||||
We have developed a [separate Hugo documentation contribution guide][docscontrib] for more information on how the Hugo docs are built, organized, and improved by the generosity of people like you.
|
||||
|
||||
### Building Hugo
|
||||
### Build Hugo
|
||||
|
||||
While making changes in the codebase it's a good idea to build the binary to test them:
|
||||
|
||||
@@ -233,14 +233,12 @@ While making changes in the codebase it's a good idea to build the binary to tes
|
||||
go build -o hugo main.go
|
||||
```
|
||||
|
||||
### Testing
|
||||
|
||||
### Test
|
||||
Sometimes changes on the codebase can cause unintended side effects. Or they don't work as expected. Most functions have their own test cases. You can find them in files ending with `_test.go`.
|
||||
|
||||
Make sure the commands `go test ./...` passes, and `go build` completes.
|
||||
|
||||
### Formatting
|
||||
|
||||
### Formatting
|
||||
The Go code styleguide maybe is opiniated but it ensures that the codebase looks the same, regardless who wrote the code. Go comes with its own formatting tool. Let's apply the styleguide to our addtions:
|
||||
|
||||
```sh
|
||||
@@ -263,7 +261,7 @@ You noticed some commit messages don't fulfill the code contribution guidelines
|
||||
|
||||
If you are unsure what a command does leave the commit as it is. We can fix your commits later in the pull request.
|
||||
|
||||
#### Modifying the last commit
|
||||
#### Modify the last commit
|
||||
|
||||
Let's say you want to modify the last commit message. Run the following command and replace the current message:
|
||||
|
||||
@@ -285,7 +283,7 @@ git add --all
|
||||
git commit --amend
|
||||
```
|
||||
|
||||
#### Modifying multiple commits
|
||||
#### Modify multiple commits
|
||||
|
||||
{{% warning "Be Careful Modifying Multiple Commits"%}}
|
||||
Modifications such as those described in this section can have serious unintended consequences. Skip this section if you're not sure!
|
||||
|
||||
@@ -28,7 +28,7 @@ You can then create a separate branch for your additions. Be sure to choose a de
|
||||
git checkout -b jon-doe-showcase-addition
|
||||
```
|
||||
|
||||
## Adding New Content
|
||||
## Add New Content
|
||||
|
||||
The Hugo docs make heavy use of Hugo's [archetypes][] feature. All content sections in Hugo documentation have an assigned archetype.
|
||||
|
||||
@@ -42,7 +42,7 @@ hugo new <DOCS-SECTION>/<new-content-lowercase>.md
|
||||
`title` and `date` fields are added automatically when using archetypes via `hugo new`. Do not be worried if the order of the new file's front matter fields on your local machine is different than that of the examples provided in the Hugo docs. This is a known issue [(#452)](https://github.com/gohugoio/hugo/issues/452).
|
||||
{{% /note %}}
|
||||
|
||||
### Adding a New Function
|
||||
### Add a New Function
|
||||
|
||||
Once you have cloned the Hugo repository, you can create a new function via the following command. Keep the file name lowercase.
|
||||
|
||||
@@ -94,7 +94,7 @@ Here is a review of the front matter fields automatically generated for you usin
|
||||
|
||||
In the body of your function, expand the short description used in the front matter. Include as many examples as possible, and leverage the Hugo docs [`code` shortcode](#adding-code-blocks). If you are unable to add examples but would like to solicit help from the Hugo community, add `needsexample: true` to your front matter.
|
||||
|
||||
### Adding a New Tutorial
|
||||
### Add a New Tutorial
|
||||
|
||||
Once you have cloned the Hugo repository, you can create a new tutorial via the following command. Name the markdown file accordingly:
|
||||
|
||||
@@ -110,7 +110,7 @@ The archetype for the `tutorials` content type is as follows:
|
||||
```
|
||||
{{% /code %}}
|
||||
|
||||
## Adding Code Blocks
|
||||
## Add Code Blocks
|
||||
|
||||
Code blocks are crucial for providing examples of Hugo's new features to end users of the Hugo docs. Whenever possible, create examples that you think Hugo users will be able to implement in their own projects.
|
||||
|
||||
|
||||
@@ -109,7 +109,7 @@ Mar 3nd 2017
|
||||
|
||||
<!-- Content idea: see https://discourse.gohugo.io/t/formatting-a-date-with-suffix-2nd/5701 -->
|
||||
|
||||
### Using `.Local` and `.UTC`
|
||||
### Use `.Local` and `.UTC`
|
||||
|
||||
In conjunction with the [`dateFormat` function][dateFormat], you can also convert your dates to `UTC` or to local timezones:
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ There are 6 basic mathematical operators that can be used in Hugo templates:
|
||||
| `mul` | Multiplies two integers. | `{{mul 2 3}}` → 6 |
|
||||
| `sub` | Subtracts two integers. | `{{sub 3 2}}` → 1 |
|
||||
|
||||
## Using `add` with Strings
|
||||
## Use `add` with Strings
|
||||
|
||||
You can also use the `add` function with strings. You may like this functionality in many use cases, including creating new variables by combining page- or site-level variables with other strings.
|
||||
|
||||
|
||||
@@ -79,7 +79,7 @@ The following logical operators are vailable with `where`:
|
||||
`intersect`
|
||||
: `true` if a given field value that is a slice/array of strings or integers contains elements in common with the matching value; it follows the same rules as the [`intersect` function][intersect].
|
||||
|
||||
## Using `where` with `intersect`
|
||||
## Use `where` with `intersect`
|
||||
|
||||
```html
|
||||
{{ range where .Site.Pages ".Params.tags" "intersect" .Params.tags }}
|
||||
@@ -101,7 +101,7 @@ You can also put the returned value of the `where` clauses into a variable:
|
||||
```
|
||||
{{% /code %}}
|
||||
|
||||
## Using `where` with `first`
|
||||
## Use `where` with `first`
|
||||
|
||||
The following grabs the first five content files in `post` using the [default ordering](/templates/lists/) for lists (i.e., `weight => date`):
|
||||
|
||||
@@ -113,7 +113,7 @@ The following grabs the first five content files in `post` using the [default or
|
||||
```
|
||||
{{% /code %}}
|
||||
|
||||
## Nesting `where` Clauses
|
||||
## Nest `where` Clauses
|
||||
|
||||
You can also nest `where` clauses to drill down on lists of content by more than one parameter. The following first grabs all pages in the "blog" section and then ranges through the result of the first `where` clause and finds all pages that are *not* featured:
|
||||
|
||||
|
||||
@@ -335,7 +335,7 @@ $ env HUGO_TITLE="Some Title" hugo
|
||||
Names must be prefixed with `HUGO_` and the configuration key must be set in uppercase when setting operating system environment variables.
|
||||
{{% /note %}}
|
||||
|
||||
## Ignoring Files When Rendering
|
||||
## Ignore Files When Rendering
|
||||
|
||||
The following statement inside `./config.toml` will cause Hugo to ignore files ending with `.foo` and `.boo` when rendering:
|
||||
|
||||
@@ -345,7 +345,7 @@ ignoreFiles = [ "\\.foo$", "\\.boo$" ]
|
||||
|
||||
The above is a list of regular expressions. Note that the backslash (`\`) character is escaped in this example to keep TOML happy.
|
||||
|
||||
## Configuring Blackfriday
|
||||
## Configure Blackfriday
|
||||
|
||||
[Blackfriday](https://github.com/russross/blackfriday) is Hugo's built-in Markdown rendering engine.
|
||||
|
||||
@@ -381,7 +381,7 @@ blackfriday:
|
||||
```
|
||||
{{% /code %}}
|
||||
|
||||
## Configuring 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.
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@ choco install hugo -confirm
|
||||
|
||||
Hugo uses [govendor][] to vendor dependencies, but we don't commit the vendored packages themselves to the Hugo git repository. Therefore, a simple `go get` is *not* supported because the command is not vendor aware. *You must use `govendor` to fetch Hugo's dependencies.*
|
||||
|
||||
#### Fetching from GitHub
|
||||
#### Fetch from GitHub
|
||||
|
||||
{{% code file="from-gh.sh" %}}
|
||||
```sh
|
||||
@@ -125,7 +125,7 @@ There are pros and cons to each of the aforementioned methods:
|
||||
Since building from source is appealing to more seasoned command line users, this guide will focus more on installing Hugo via Homebrew and Tarball.
|
||||
{{% /note %}}
|
||||
|
||||
### Installing Hugo with Brew
|
||||
### Install Hugo with Brew
|
||||
|
||||
#### Step 1: Install `brew` if you haven't already
|
||||
|
||||
@@ -176,7 +176,7 @@ hugo version
|
||||
Hugo Static Site Generator v0.13 BuildDate: 2015-03-09T21:34:47-05:00
|
||||
```
|
||||
|
||||
### Installing Hugo from Tarball
|
||||
### Install Hugo from Tarball
|
||||
|
||||
#### Step 1: Decide on the location
|
||||
|
||||
@@ -261,7 +261,7 @@ Close the terminal and open a new terminal to pick up the changes to your profil
|
||||
|
||||
You've successfully installed Hugo.
|
||||
|
||||
### Building from Source on Mac
|
||||
### Build from Source on Mac
|
||||
|
||||
If you want to compile Hugo yourself, you'll need to install Go (aka Golang). You can [install Go directly from the Go website](https://golang.org/dl/) or via Homebrew using the following command:
|
||||
|
||||
@@ -414,7 +414,7 @@ C:\Hugo\Sites\example.com>dir
|
||||
7 Dir(s) 6,273,331,200 bytes free
|
||||
```
|
||||
|
||||
### Troubleshooting Windows Installation
|
||||
### Troubleshoot Windows Installation
|
||||
|
||||
[@dhersam][] has created a nice video on common issues:
|
||||
|
||||
@@ -469,11 +469,11 @@ snap install hugo
|
||||
Hugo-as-a-snap can write only inside the user’s `$HOME` directory---and gvfs-mounted directories owned by the user---because of Snaps’ confinement and security model. More information is also available [in this related GitHub issue](https://github.com/gohugoio/hugo/issues/3143).
|
||||
{{% /note %}}
|
||||
|
||||
## Upgrading Hugo
|
||||
## Upgrade Hugo
|
||||
|
||||
Upgrading Hugo is as easy as downloading and replacing the executable you’ve placed in your `PATH`.
|
||||
|
||||
## Installing Pygments (Optional)
|
||||
## Install Pygments (Optional)
|
||||
|
||||
The Hugo executable has one *optional* external dependency for source code highlighting ([Pygments][pygments]).
|
||||
|
||||
|
||||
@@ -338,7 +338,7 @@ hugo server --theme=hugo_theme_robust --buildDrafts
|
||||
```
|
||||
{{% /code %}}
|
||||
|
||||
### Updating Our `config.toml`
|
||||
### Update Our `config.toml`
|
||||
|
||||
Our website is currently using the dummy values specified in `bookshelf/config.toml`, which were auto-generated with `hugo new site bookshelf`. Let's update the configuration:
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ toc: true
|
||||
|
||||
The following is a description of the most command commands you will use while developing your Hugo project. See the [Command Line Reference][commands] for a comprehensive view of Hugo's CLI.
|
||||
|
||||
## Testing Installation
|
||||
## Test Installation
|
||||
|
||||
Once you have [installed Hugo][install], make sure it is in your `PATH`. You can test that Hugo has been installed correctly via the `help` command:
|
||||
|
||||
@@ -166,7 +166,7 @@ Most Hugo builds are so fast that you may not notice the change unless looking d
|
||||
Hugo injects the LiveReload `<script>` before the closing `</body>` in your templates and will therefore not work if this tag is not present..
|
||||
{{% /note %}}
|
||||
|
||||
### Disabling LiveReload
|
||||
### Disable LiveReload
|
||||
|
||||
LiveReload works by injecting JavaScript into the pages Hugo generates. The script creates a connection from the browser's web socket client to the Hugo web socket server.
|
||||
|
||||
@@ -192,7 +192,7 @@ disableLiveReload = true
|
||||
disableLiveReload: true
|
||||
```
|
||||
|
||||
## Deploying Your Website
|
||||
## Deploy Your Website
|
||||
|
||||
After running `hugo server` for local web development, you need to do a final `hugo` run *without the `server` part of the command* to rebuild your site. You may then deploy your site by copying the `public/` directory to your production web server.
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ hugo && rsync -avz --delete public/ www-data@ftp.topologix.fr:~/www/
|
||||
|
||||
As you will see, we put it in a shell script file, which makes building and deployment as easy as executing `./deploy`.
|
||||
|
||||
## Installing SSH Key
|
||||
## Install SSH Key
|
||||
|
||||
If it is not done yet, we will make an automated way to SSH to your server. If you have already installed an SSH key, switch to the next section.
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ By the end of this guide, you will have completed the following:
|
||||
|
||||
If you do not meet these assumptions, the [GitHub help section][githubhelp] has an explanation of how to install and use git. [Signing up for a GitHub][ghsignup] account is free as well. If you are completely unfamiliar with creating a new Hugo website, visit the [Hugo Quick Start][quickstart].
|
||||
|
||||
## Creating a Basic Hugo Site
|
||||
## Create a Basic Hugo Site
|
||||
|
||||
{{% note "This Guide Uses the Hugo CLI" %}}
|
||||
All the work for setting up a Hugo project and using this guide is done via the Hugo CLI's most basic commands. See the [command line reference page](/commands/) for a more exhaustive account of the CLI's features.
|
||||
@@ -99,7 +99,7 @@ If everything is fine, you should see something similar to the image below when
|
||||
|
||||
![][1]
|
||||
|
||||
## Setting up Version Control in Git
|
||||
## Set up Version Control in Git
|
||||
|
||||
Adding Git to your project is done by running the `git init` command from the root directory of your project.
|
||||
|
||||
@@ -129,7 +129,7 @@ Now we need to add (i.e., [stage [see Git documentation]][gitbasics]) and commit
|
||||
git commit -a -m "Initial commit"
|
||||
```
|
||||
|
||||
## Adding the Project to GitHub
|
||||
## Add the Project to GitHub
|
||||
|
||||
Now we need to create a new repository on GitHub. Once you are signed in to GitHub, you can add a new repository by clicking on the **+▼** dropdown at the top right or by going to [https://github.com/new](https://github.com)..
|
||||
|
||||
@@ -144,19 +144,19 @@ git push -u origin master
|
||||
|
||||
![][2]
|
||||
|
||||
## Setting Up Wercker
|
||||
## Set Up Wercker
|
||||
|
||||
To sign up for a free Wercker account, go to <https://wercker.com> and click the the **Sign Up** button on the top right of the home screen.
|
||||
|
||||
![][3]
|
||||
|
||||
### Registing for Wercker with Your GitHub Account
|
||||
### Registe for Wercker with Your GitHub Account
|
||||
|
||||
Sign up for Wercker using your GitHub credentials. If you don't have a GitHub account, or don't want to use it for your account, you have the option to register with a username and password as well. However, the second half of this guide---devoted to hosting your website on GitHub pages---will no longer be of interest to you.
|
||||
|
||||
![][4]
|
||||
|
||||
### Connecting GitHub or Bitbucket
|
||||
### Connecte GitHub or Bitbucket
|
||||
|
||||
After you are registered, you will need to link your GitHub or Bitbucket account to Wercker. You can link your account by navigating to your profile settings and then selecting "Git connections."
|
||||
|
||||
@@ -184,7 +184,7 @@ In the next step, Wercker asks you to select the repository owner. Select your G
|
||||
|
||||
![][8]
|
||||
|
||||
### Configuring Access
|
||||
### Configure Access
|
||||
|
||||
{{% note %}}
|
||||
This guide assumes you are using a public GitHub repository and understand that the [published GitHub Pages website will be available to everyone](https://help.github.com/articles/what-is-github-pages/#usage-limits).
|
||||
@@ -214,13 +214,13 @@ The application is now added and Wercker will offer you the chance to trigger a
|
||||
|
||||
![][12]
|
||||
|
||||
### Adding the Hugo-build Step
|
||||
### Add the Hugo-build Step
|
||||
|
||||
Now we need to add the Wercker steps to our build process. First, we go to the "Registry" action in the top menu. When in the registry, we can search for "hugo build". Select the "Hugo-Build by **arjen**" step.
|
||||
|
||||
![][13]
|
||||
|
||||
### Using the Hugo-build Step
|
||||
### Use the Hugo-build Step
|
||||
|
||||
A summary of very basic usage is available at the top of the details for the Hugo-Build step. Below the basic usage is the contents of the `README.md` file associated with the step's repository. `README.md`'s on Wercker usually contain more details about the advanced options and examples of usage.
|
||||
|
||||
@@ -255,7 +255,7 @@ If completed and successful, a green check mark should appear in the commit colu
|
||||
|
||||
![][14]
|
||||
|
||||
### Adding a GitHub Pages Deploy Step to `wercker.yml`
|
||||
### Add a GitHub Pages Deploy Step to `wercker.yml`
|
||||
|
||||
In order to deploy to GitHub Pages, we need to add a deploy step to our `wercker.yml`. We are going to add `lukevevier/gh-pages`, the most popular GitHub Pages step in the Wercker Steps repository. Additionally, we need to ensure the box Wercker uses for our deployments has git and ssh installed. We can do this using the `install-packages` command. Here is our *final* `wercker.yml` file:
|
||||
|
||||
@@ -287,13 +287,13 @@ Secondly, we've configured the `basedir` to `public`. This is the directory that
|
||||
|
||||
Lastly, you'll notice a `$GIT_TOKEN` variable. This is used for pushing our changes to GitHub. We will need to configure this token before Wercker can build our website.
|
||||
|
||||
### Setting the App's Deploy Target
|
||||
### Set the App's Deploy Target
|
||||
|
||||
We can set our deploy target by going to our app's settings and clicking on **Deploy targets**. Now select **Add deploy target** and then **Custom deploy**.
|
||||
|
||||
![][15]
|
||||
|
||||
### Configuring the Deploy Step in Wercker
|
||||
### Configure the Deploy Step in Wercker
|
||||
|
||||
The next screen requires you fill in the deploy target name.
|
||||
|
||||
|
||||
@@ -85,7 +85,7 @@ git push upstream gh-pages
|
||||
git checkout master
|
||||
```
|
||||
|
||||
### Building and Deployment
|
||||
### Build and Deployment
|
||||
|
||||
Now check out the `gh-pages` branch into your `public` folder using git's [worktree feature][]. Essentially, the worktree allows you to have multiple branches of the same local repository to be checked out in different directories:
|
||||
|
||||
@@ -109,7 +109,7 @@ If the changes in your local `gh-pages` branch look alright, push them to the re
|
||||
git push upstream gh-pages
|
||||
```
|
||||
|
||||
#### Setting `gh-pages` as Your Publish Branch
|
||||
#### Set `gh-pages` as Your Publish Branch
|
||||
|
||||
In order to use your `gh-pages` branch as your publishing branch, you'll need to configure the repository within the GitHub UI. This will likely happen automatically once GitHub realizes you've created this branch. You can also set the branch manually from within your GitHub project:
|
||||
|
||||
@@ -118,7 +118,7 @@ In order to use your `gh-pages` branch as your publishing branch, you'll need to
|
||||
|
||||
After a short while, you'll see the updated contents on your GitHub Pages site.
|
||||
|
||||
### Putting it Into a Script
|
||||
### Put it Into a Script
|
||||
|
||||
To automate these steps, you can create a script with the following contents:
|
||||
|
||||
@@ -167,7 +167,7 @@ You will also need to set `master` as your publishable branch from within the Gi
|
||||
1. Go to **Settings** → **GitHub Pages**
|
||||
2. From **Source**, select "master branch" and then **Save**.
|
||||
|
||||
## Hosting GitHub User or Organization Pages
|
||||
## Host GitHub User or Organization Pages
|
||||
|
||||
As mentioned [in this GitHub Help article](https://help.github.com/articles/user-organization-and-project-pages/), you can host a user/organization page in addition to project pages. Here are the key differences in GitHub Pages websites for Users and Organizations:
|
||||
|
||||
@@ -187,7 +187,7 @@ It becomes much simpler in this case: we'll create two separate repos, one for H
|
||||
* `rm -rf public` to completely remove the `public` directory if there
|
||||
6. `git submodule add -b master git@github.com:<USERNAME>/<USERNAME>.github.io.git public`. This creates a git [submodule][]. Now when you run the `hugo` command to build your site to `public`, the created `public` directory will have a different remote origin (i.e. hosted GitHub repository). You can automate some of these steps with the following script.
|
||||
|
||||
#### Putting it Into a Script
|
||||
#### Put it Into a Script
|
||||
|
||||
You're almost done. You can also add a `deploy.sh` script to automate the preceding steps for you. You can also make it executable with `chmod +x deploy.sh`.
|
||||
|
||||
@@ -225,7 +225,7 @@ You can then run `./deploy.sh "Your optional commit message"` to send changes to
|
||||
|
||||
That's it! Your personal page should be up and running at `https://yourusername.github.io` within a couple minutes.
|
||||
|
||||
## Using a Custom Domain
|
||||
## Use a Custom Domain
|
||||
|
||||
If you'd like to use a custom domain for your GitHub Pages site, create a file `static/CNAME`. Your custom domain name should be the only contents inside `CNAME`. Since it's inside `static`, the published site will contain the CNAME file at the root of the published site, which is a requirements of GitHub Pages.
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ Select the repo you want to use for continuous deployment. If you have a large n
|
||||
|
||||
Once selected, you'll be brought to a screen for basic setup. Here you can select the branch you wanted published, your [build command][], and your publish (i.e. deploy) directory. The publish directory should mirror that of what you've set in your [site configuration][config], the default of which is `public`. The following steps assume you are publishing from the `master` branch.
|
||||
|
||||
### Building with a Specific Hugo Version
|
||||
### Build with a Specific Hugo Version
|
||||
|
||||
Setting the build command to `hugo` will build your site according to the current default Hugo version used by Netlify. You can see the full list of [available Hugo versions in Netlify's Docker file][hugoversions].
|
||||
|
||||
@@ -87,7 +87,7 @@ Once the build is finished---this should only take a few seconds--you should now
|
||||
|
||||
Now every time you push changes to your hosted git repository, Netlify will rebuild and redeploy your site.
|
||||
|
||||
## Using Hugo Themes with Netlify
|
||||
## Use Hugo Themes with Netlify
|
||||
|
||||
The [`git clone` method for installing themes][installthemes] is not supported by Netlify. If you were to use `git clone`, it would require you to recursively remove the `.git` subdirectory from the theme folder and would therefore prevent compatibility with future versions of the theme.
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ Hugo assumes you want to append `nd` as a string to the day of the month and out
|
||||
Mar 3nd 2017
|
||||
```
|
||||
|
||||
### Using `.Local` and `.UTC`
|
||||
### Use `.Local` and `.UTC`
|
||||
|
||||
In conjunction with the [`dateFormat` function][dateFormat], you can also convert your dates to `UTC` or to local timezones:
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ Here is the lookup order for the `post` base template:
|
||||
9. `/layouts/_default/baseof.html`
|
||||
10. `/themes/mytheme/layouts/_default/baseof.html`
|
||||
|
||||
## Defining the Base Template
|
||||
## Define the Base Template
|
||||
|
||||
The following defines a simple base template at `_default/baseof.html`. As a default template, it is the shell from which all your pages will be rendered unless you specify another `*baseof.html` closer to the beginning of the lookup order.
|
||||
|
||||
@@ -83,7 +83,7 @@ The following defines a simple base template at `_default/baseof.html`. As a def
|
||||
```
|
||||
{{% /code %}}
|
||||
|
||||
## Overriding the Base Template
|
||||
## Override the Base Template
|
||||
|
||||
From the above base template, you can define a [default list template][hugolists]. The default list template will inherit all of the code defined above and can then implement its own `"main"` block from:
|
||||
|
||||
|
||||
@@ -122,7 +122,7 @@ Data-driven content currently consists of two functions, `getJSON` and `getCSV`,
|
||||
|
||||
## Implementation details
|
||||
|
||||
### Calling the Functions with a URL
|
||||
### Call the Functions with a URL
|
||||
|
||||
In your template, call the functions like this:
|
||||
|
||||
@@ -199,7 +199,7 @@ For `getCSV`, the one-character-long separator must be placed in the first posit
|
||||
|
||||
The expression `{{index $r number}}` must be used to output the nth-column from the current row.
|
||||
|
||||
### Caching of URLs
|
||||
### Cache URLs
|
||||
|
||||
Each downloaded URL will be cached in the default folder `$TMPDIR/hugo_cache/`. The variable `$TMPDIR` will be resolved to your system-dependent temporary directory.
|
||||
|
||||
@@ -213,7 +213,7 @@ If you don't like caching at all, you can fully disable caching with the command
|
||||
|
||||
Currently, you can only use those authentication methods that can be put into an URL. [OAuth][] and other authentication methods are not implemented.
|
||||
|
||||
### Loading Local files
|
||||
### Load Local files
|
||||
|
||||
To load local files with `getJSON` and `getCSV`, the source files must reside within Hugo's working directory. The file extension does not matter, but the content does.
|
||||
|
||||
|
||||
@@ -19,11 +19,11 @@ aliases: [/extras/localfiles/,/templates/local-files/]
|
||||
toc: true
|
||||
---
|
||||
|
||||
## Traversing Local Files
|
||||
## Traverse Local Files
|
||||
|
||||
With Hugo's [`readDir` and `readFile` template functions][reads], you can traverse your website's files on your server.
|
||||
|
||||
## Using `readDir`
|
||||
## Use `readDir`
|
||||
|
||||
The [`readDir` function][reads] returns an array of [`os.FileInfo`][osfileinfo]. It takes the file's `path` as a single string argument. This path can be to any directory of your website (i.e., as found on your server's file system).
|
||||
|
||||
@@ -56,7 +56,7 @@ The above shortcode [is part of the code for the Hugo docs][dirindex]. Here it l
|
||||
The initial slash `/` in `pathURL` is important in the `directoryindex` shortcode. Otherwise, `pathURL` becomes relative to the current web page.
|
||||
{{% /note %}}
|
||||
|
||||
## Using `readFile`
|
||||
## Use `readFile`
|
||||
|
||||
The [`readfile` function][reads] reads a file from disk and converts it into a string to be manipulated by other Hugo functions or added as-is. `readFile` takes the file, including path, as an argument passed to the function.
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ The [lookup order][lookup] for the homepage template is as follows:
|
||||
3. `/themes/<THEME>/layouts/index.html`
|
||||
4. `/themes/<THEME>/layouts/_default/list.html`
|
||||
|
||||
## Adding Content and Front Matter to the Homepage
|
||||
## Add Content and Front Matter to the Homepage
|
||||
|
||||
The homepage, similar to other [list pages in Hugo][lists], accepts content and front matter from an `_index.md` file. This file should live at the root of your `content` folder (i.e., `content/_index.md`). You can then add body copy and metadata to your homepage the way you would any other content file.
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ While the following internal templates are called similar to partials, they do *
|
||||
|
||||
Hugo ships with internal templates for Google Analytics tracking, including both synchronous and asynchronous tracking codes.
|
||||
|
||||
### Configuring Google Analytics
|
||||
### Configure Google Analytics
|
||||
|
||||
Provide your tracking id in your configuration file:
|
||||
|
||||
@@ -41,7 +41,7 @@ googleAnalytics = "UA-123-45"
|
||||
googleAnalytics: "UA-123-45"
|
||||
```
|
||||
|
||||
### Using the Google Analytics Template
|
||||
### Use the Google Analytics Template
|
||||
|
||||
You can then include the Google Analytics internal template:
|
||||
|
||||
@@ -58,7 +58,7 @@ You can then include the Google Analytics internal template:
|
||||
|
||||
Hugo also ships with an internal template for [Disqus comments][disqus], a popular commenting system for both static and dynamic websites. In order to effectively use Disqus, you will need to secure a Disqus "shortname" by [signing up for the free service][disqussignup].
|
||||
|
||||
### Configuring Disqus
|
||||
### Configure Disqus
|
||||
|
||||
To use Hugo's Disqus template, you first need to set a single value in your site's `config.toml` or `config.yml`:
|
||||
|
||||
@@ -76,7 +76,7 @@ You also have the option to set the following in the front matter for a given pi
|
||||
* `disqus_title`
|
||||
* `disqus_url`
|
||||
|
||||
### Using the Disqus Template
|
||||
### Use the Disqus Template
|
||||
|
||||
To add Disqus, include the following line in templates where you want your comments to appear:
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ Go templates provide an extremely simple template language that adheres to the b
|
||||
|
||||
Golang templates are HTML files with the addition of [variables][variables] and [functions][functions]. Golang template variables and functions are accessible within `{{ }}`.
|
||||
|
||||
### Accessing a Predefined Variable
|
||||
### Access a Predefined Variable
|
||||
|
||||
```golang
|
||||
{{ foo }}
|
||||
@@ -367,7 +367,7 @@ Go considers the following characters whitespace:
|
||||
|
||||
Hugo provides the option of passing values to your template layer through your [site configuration][config] (i.e. for site-wide values) or through the metadata of each specific piece of content (i.e. the [front matter][]). You can define any values of any type and use them however you want in your templates, as long as the values are supported by the front matter format specified via `metaDataFormat` in your configuration file.
|
||||
|
||||
## Using Content (`Page`) Parameters
|
||||
## Use Content (`Page`) Parameters
|
||||
|
||||
You can provide variables to be used by templates in individual content's [front matter][].
|
||||
|
||||
@@ -404,7 +404,7 @@ Here is an example of corresponding code that could be used inside a `toc.html`
|
||||
|
||||
We want the *default* behavior to be for pages to include a TOC unless otherwise specified. This template checks to make sure that the `notoc:` field in this page's front matter is not `true`.
|
||||
|
||||
## Using Site Configuration Parameters
|
||||
## Use Site Configuration Parameters
|
||||
|
||||
You can arbitrarily define as many site-level parameters as you want in your [site's configuration file][config]. These parameters are globally available in your templates.
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ Since section lists and taxonomy lists (N.B., *not* [taxonomy terms lists][taxte
|
||||
1. `layouts/_default/taxonomy.html`
|
||||
2. `themes/<THEME>/layouts/_default/taxonomy.html`
|
||||
|
||||
## Adding Content and Front Matter to List Pages
|
||||
## Add Content and Front Matter to List Pages
|
||||
|
||||
Since v0.18, [everything in Hugo is a `Page`][bepsays]. This means list pages and the homepage can have associated content files (i.e. `_index.md`) that contain page metadata (i.e., front matter) and content.
|
||||
|
||||
@@ -213,7 +213,7 @@ This list template has been modified slightly from a template originally used in
|
||||
```
|
||||
{{% /code %}}
|
||||
|
||||
## Ordering Content
|
||||
## Order Content
|
||||
|
||||
Hugo lists render the content based on metadata you provide in [front matter][]. In addition to sane defaults, Hugo also ships with multiple methods to make quick work of ordering content inside list templates:
|
||||
|
||||
@@ -398,7 +398,7 @@ Reversing order can be applied to any of the above methods. The following uses `
|
||||
```
|
||||
{{% /code %}}
|
||||
|
||||
## Grouping Content
|
||||
## Group Content
|
||||
|
||||
Hugo provides some functions for grouping pages by Section, Type, Date, etc.
|
||||
|
||||
@@ -524,7 +524,7 @@ The following template takes grouping by `date` a step further and uses Golang's
|
||||
```
|
||||
{{% /code %}}
|
||||
|
||||
### Reversing Key Order
|
||||
### Reverse Key Order
|
||||
|
||||
Ordering of groups is performed by keys in alphanumeric order (A–Z, 1–100) and in reverse chronological order (i.e., with the newest first) for dates.
|
||||
|
||||
@@ -550,7 +550,7 @@ While these are logical defaults, they are not always the desired order. There a
|
||||
{{ range .Data.Pages.GroupBy "Section" "desc" }}
|
||||
```
|
||||
|
||||
### Ordering Within Groups
|
||||
### Order Within Groups
|
||||
|
||||
Because Grouping returns a `{{.Key}}` and a slice of pages, all of the ordering methods listed above are available.
|
||||
|
||||
@@ -576,7 +576,7 @@ Here is the ordering for the example that follows:
|
||||
```
|
||||
{{% /code %}}
|
||||
|
||||
## Filtering and Limiting Lists
|
||||
## Filter and Limiting Lists
|
||||
|
||||
Sometimes you only want to list a subset of the available content. A common is to only display “Posts” on blog's homepage. You can accomplish this with the `where` function.
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ This list template is used for [spf13.com](http://spf13.com/). It makes use of [
|
||||
```
|
||||
{{% /code %}}
|
||||
|
||||
## Ordering Content
|
||||
## Order Content
|
||||
|
||||
Hugo lists render the content based on metadata provided in the [front matter](/content-management/front-matter/)..
|
||||
|
||||
@@ -230,7 +230,7 @@ Reversing order can be applied to any of the above methods. The following uses `
|
||||
```
|
||||
{{% /code %}}
|
||||
|
||||
## Grouping Content
|
||||
## Group Content
|
||||
|
||||
Hugo provides some functions for grouping pages by Section, Type, Date, etc.
|
||||
|
||||
@@ -324,7 +324,7 @@ Hugo provides some functions for grouping pages by Section, Type, Date, etc.
|
||||
```
|
||||
{{% /code %}}
|
||||
|
||||
### Reversing Key Order
|
||||
### Reverse Key Order
|
||||
|
||||
The ordering of the groups is performed by keys in alphanumeric order (A–Z, 1–100) and in reverse chronological order (newest first) for dates.
|
||||
|
||||
@@ -341,7 +341,7 @@ While these are logical defaults, they are not always the desired order. There a
|
||||
```
|
||||
|
||||
|
||||
#### Providing the Alternate Direction
|
||||
#### Provide the Alternate Direction
|
||||
|
||||
```html
|
||||
{{ range .Data.Pages.GroupByDate "2006-01" "asc" }}
|
||||
@@ -351,7 +351,7 @@ While these are logical defaults, they are not always the desired order. There a
|
||||
{{ range .Data.Pages.GroupBy "Section" "desc" }}
|
||||
```
|
||||
|
||||
### Ordering Within Groups
|
||||
### Order Within Groups
|
||||
|
||||
Because Grouping returns a `{{.Key}}` and a slice of pages, all of the ordering methods listed above are available.
|
||||
|
||||
@@ -374,7 +374,7 @@ within each group is ordered alphabetically by title.
|
||||
```
|
||||
{{% /code %}}
|
||||
|
||||
## Filtering and Limiting Lists
|
||||
## Filter and Limiting Lists
|
||||
|
||||
Sometimes you only want to list a subset of the available content. A common request is to only display “Posts” on the homepage. You can accomplish this with the `where` function.
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ protocol = "bep://"
|
||||
|
||||
The above example is fictional, but if used for the homepage on a site with `baseURL` `http://example.org`, it will produce a plain text homepage with the URL `bep://example.org/myindex.enr`.
|
||||
|
||||
### Configuring Output Formats
|
||||
### Configure Output Formats
|
||||
|
||||
The following is the full list of configuration options for output formats and their default values:
|
||||
|
||||
@@ -148,7 +148,7 @@ outputs:
|
||||
---
|
||||
```
|
||||
|
||||
## Linking to Output Formats
|
||||
## Link to Output Formats
|
||||
|
||||
Each `Page` has both an `.OutputFormats` (all formats, including the current) and an `.AlternativeOutputFormats` variable, the latter of which is useful for creating a `link rel` list in your site's `<head>`:
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ toc: true
|
||||
|
||||
The real power of Hugo pagination shines when combined with the [`where` function][where] and its SQL-like operators: [`first`][], [`last`][], and [`after`][]. You can even [order the content][lists] the way you've become used to with Hugo.
|
||||
|
||||
## Configuring Pagination
|
||||
## Configure Pagination
|
||||
|
||||
Pagination can be configured in your [site configuration][configuration]:
|
||||
|
||||
@@ -34,7 +34,7 @@ Setting `Paginate` to a positive value will split the list pages for the homepag
|
||||
|
||||
`PaginatePath` is used to adapt the `URL` to the pages in the paginator (the default setting will produce URLs on the form `/page/1/`.
|
||||
|
||||
## Listing Paginator Pages
|
||||
## List Paginator Pages
|
||||
|
||||
{{% warning %}}
|
||||
`.Paginator` is provided to help you build a pager menu. This feature is currently only supported on homepage and list pages (i.e., taxonomies and section lists).
|
||||
|
||||
@@ -27,7 +27,7 @@ Partial templates---like [single page templates][singletemps] and [list page tem
|
||||
|
||||
This allows a theme's end user to copy a partial's contents into a file of the same name for [further customization][customize].
|
||||
|
||||
## Using Partials in your Templates
|
||||
## Use Partials in your Templates
|
||||
|
||||
All partials for your Hugo project are located in a single `layouts/partials` directory. For better organization, you can create multiple subdirectories within `partials` as well:
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ Hugo provides the ability for you to define any RSS type you wish and can have d
|
||||
4. `/themes/<THEME>/layouts/_default/rss.xml`
|
||||
5. Embedded rss.xml
|
||||
|
||||
## Configuring RSS
|
||||
## 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 [`config` file][config].
|
||||
|
||||
@@ -115,7 +115,7 @@ Hugo will automatically add the following header line to this file on render. Pl
|
||||
```
|
||||
{{% /warning %}}
|
||||
|
||||
## Referencing your RSS Feed in `<head>`
|
||||
## Reference your RSS Feed in `<head>`
|
||||
|
||||
In your `header.html` template, you can specify your RSS feed in your `<head></head>` tag like this:
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ aliases: [/templates/sections/]
|
||||
toc: true
|
||||
---
|
||||
|
||||
## Adding Content and Front Matter to Section Templates
|
||||
## Add Content and Front Matter to Section Templates
|
||||
|
||||
To effectively leverage section page templates, you should first understand Hugo's [content organization](/content-management/organization/) and, specifically, the purpose of `_index.md` for adding content and front matter to section and other list pages.
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ Shortcodes are a means to consolidate templating into small, reusable snippets t
|
||||
Hugo also ships with built-in shortcodes for common use cases. (See [Content Management: Shortcodes](/content-management/shortcodes/).)
|
||||
{{% /note %}}
|
||||
|
||||
## Creating Custom Shortcodes
|
||||
## Create Custom Shortcodes
|
||||
|
||||
Hugo's built-in shortcodes cover many common, but not all, use cases. Luckily, Hugo provides the ability to easily create custom shortcodes to meet your website's needs.
|
||||
|
||||
@@ -53,7 +53,7 @@ For more complex layouts with multiple or optional parameters, named parameters
|
||||
|
||||
Allowing both types of parameters (i.e., a "flexible" shortcode) is useful for complex layouts where you want to set default values that can be easily overridden by users.
|
||||
|
||||
### Accessing Parameters
|
||||
### Access Parameters
|
||||
|
||||
All shortcode parameters can be accessed via the `.Get` method. Whether you pass a key (i.e., string) or a number to the `.Get` method depends on whether you are accessing a named or positional parameter, respectively.
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ on render. Please don't include this in the template as it's not valid HTML.
|
||||
`<?xml version="1.0" encoding="utf-8" standalone="yes" ?>`
|
||||
{{% /note %}}
|
||||
|
||||
## Configuring `sitemap.xml`
|
||||
## Configure `sitemap.xml`
|
||||
|
||||
Defaults for `<changefreq>`, `<priority>` and `filename` values can be set in the site's config file, e.g.:
|
||||
|
||||
|
||||
@@ -119,7 +119,7 @@ type WeightedPages []WeightedPage
|
||||
|
||||
<!-- Begin /taxonomies/ordering/ -->
|
||||
|
||||
## Ordering Taxonomies
|
||||
## Order Taxonomies
|
||||
|
||||
Taxonomies can be ordered by either alphabetical key or by the number of content pieces assigned to that key.
|
||||
|
||||
@@ -147,7 +147,7 @@ Taxonomies can be ordered by either alphabetical key or by the number of content
|
||||
|
||||
<!-- [See Also Taxonomy Lists](/templates/list/) -->
|
||||
|
||||
## Ordering Content within Taxonomies
|
||||
## Order Content within Taxonomies
|
||||
|
||||
Hugo uses both `date` and `weight` to order content within taxonomies.
|
||||
|
||||
@@ -155,7 +155,7 @@ Each piece of content in Hugo can optionally be assigned a date. It can also be
|
||||
|
||||
When iterating over content within taxonomies, the default sort is the same as that used for [section and list pages]() first by weight then by date. This means that if the weights for two pieces of content are the same, than the more recent content will be displayed first. The default weight for any piece of content is 0.
|
||||
|
||||
### Assigning Weight
|
||||
### Assign Weight
|
||||
|
||||
Content can be assigned weight for each taxonomy that it's assigned to.
|
||||
|
||||
@@ -203,7 +203,7 @@ using the [list templates](/templates/list/):
|
||||
3. You can list all terms for a taxonomy
|
||||
4. You can list all taxonomies (with their terms)
|
||||
|
||||
## Displaying a Single Piece of Content's Taxonomies
|
||||
## Display a Single Piece of Content's Taxonomies
|
||||
|
||||
Within your content templates, you may wish to display the taxonomies that piece of content is assigned to.
|
||||
|
||||
@@ -234,7 +234,7 @@ To list such taxonomies, use the following:
|
||||
|
||||
Alternatively, you may use the [delimit template function][delimit] as a shortcut if the taxonomies should just be listed with a separator. See {{< gh 2143 >}} on GitHub for discussion.
|
||||
|
||||
## Listing Content with the Same Taxonomy Term
|
||||
## List Content with the Same Taxonomy Term
|
||||
|
||||
If you are using a taxonomy for something like a series of posts, you can list individual pages associated with the same taxonomy. This is also a quick and dirty method for showing related content:
|
||||
|
||||
@@ -248,7 +248,7 @@ If you are using a taxonomy for something like a series of posts, you can list i
|
||||
</ul>
|
||||
```
|
||||
|
||||
## Listing All content in a Given taxonomy
|
||||
## List All content in a Given taxonomy
|
||||
|
||||
This would be very useful in a sidebar as “featured content”. You could even have different sections of “featured content” by assigning different terms to the content.
|
||||
|
||||
@@ -269,7 +269,7 @@ This would be very useful in a sidebar as “featured content”. You could even
|
||||
</section>
|
||||
```
|
||||
|
||||
## Rendering a Site's Taxonomies
|
||||
## Render a Site's Taxonomies
|
||||
|
||||
If you wish to display the list of all keys for your site's taxonomy, you can retrieve them from the [`.Site` variable][sitevars] available on every page.
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ The following are common use cases for content views:
|
||||
* You want content of every type to be shown on the homepage but only with limited [summary views][summaries].
|
||||
* You only want a bulleted list of your content on a [taxonomy list page][taxonomylists]. Views make this very straightforward by delegating the rendering of each different type of content to the content itself.
|
||||
|
||||
## Creating a Content View
|
||||
## Create a Content View
|
||||
|
||||
To create a new view, create a template in each of your different content type directories with the view name. The following example contains an "li" view and a "summary" view for the `post` and `project` content types. As you can see, these sit next to the [single content view][single] template, `single.html. You can even provide a specific view for a given type and continue to use the `_default/single.html` for the primary view.
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ The following are key concepts for Hugo site customization with themes. Hugo per
|
||||
When you use a theme cloned from its git repository, do not edit the theme's files directly. Instead, theme customization in Hugo is a matter of *overriding* the templates made available to you in a theme. This provides the added flexibility of tweaking a theme to meet your needs while staying current with a theme's upstream.
|
||||
{{% /note %}}
|
||||
|
||||
## Overriding Static Files
|
||||
## Override Static Files
|
||||
|
||||
There are times where you want to include static assets that differ from versions of the same asset that ships with a theme.
|
||||
|
||||
@@ -41,7 +41,7 @@ You want to replace the version of jQuery that ships with the theme with the new
|
||||
/static/js/jquery.min.js
|
||||
```
|
||||
|
||||
## Overriding Template Files
|
||||
## Override Template Files
|
||||
|
||||
Anytime Hugo looks for a matching template, it will first check the working directory before looking in the theme directory. If you would like to modify a template, simply create that template in your local `layouts` directory.
|
||||
|
||||
@@ -65,7 +65,7 @@ Would be overwritten by
|
||||
This only works for templates that Hugo "knows about" (i.e., that follow its convention for folder structure and naming). If a theme imports template files in a creatively named directory, Hugo won’t know to look for the local `/layouts` first.
|
||||
{{% /warning %}}
|
||||
|
||||
## Overriding Archetypes
|
||||
## Override Archetypes
|
||||
|
||||
If the archetype that ships with the theme for a given content type (or all content types) doesn’t fit with how you are using the theme, feel free to copy it to your `/archetypes` directory and make modifications as you see fit.
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ Hugo currently doesn’t ship with a “default” theme. This decision is inten
|
||||
1. You have already [installed Hugo on your development machine][install].
|
||||
2. You have git installed on your machine and you are familiar with basic git usage.
|
||||
|
||||
## Installing Themes
|
||||
## Install Themes
|
||||
|
||||
The community-contributed themes featured on [themes.gohugo.io](//themes.gohugo.io/) are hosted in a [centralized GitHub repository][themesrepo]. The Hugo Themes Repo at <https://github.com/gohugoio/hugoThemes> is really a meta repository that contains pointers to a set of contributed themes.
|
||||
|
||||
@@ -36,7 +36,7 @@ The community-contributed themes featured on [themes.gohugo.io](//themes.gohugo.
|
||||
Without [Git](https://git-scm.com/) installed on your computer, none of the following theme instructions will work. Git tutorials are beyond the scope of the Hugo docs, but [GitHub](https://try.github.io/) and [codecademy](https://www.codecademy.com/learn/learn-git) offer free, interactive courses for beginners.
|
||||
{{% /warning %}}
|
||||
|
||||
### Installing All Themes
|
||||
### Install All Themes
|
||||
|
||||
You can install *all* available Hugo themes by cloning the entire [Hugo Theme repository on GitHub][themesrepo] from within your working directory. Depending on your internet connection the download of all themes might take a while.
|
||||
|
||||
@@ -46,7 +46,7 @@ git clone --depth 1 --recursive https://github.com/gohugoio/hugoThemes.git theme
|
||||
|
||||
Before you use a theme, remove the .git folder in that theme's root folder. Otherwise, this will cause problem if you deploy using Git.
|
||||
|
||||
### Installing a Single Theme
|
||||
### Install a Single Theme
|
||||
|
||||
Change into the `themes` directory and download a theme by replacing `URL_TO_THEME` with the URL of the theme repository:
|
||||
|
||||
@@ -75,7 +75,7 @@ Always review the `README.md` file that is shipped with a theme. Often, these fi
|
||||
Please make certain you have installed the themes you want to use in the
|
||||
`/themes` directory. This is the default directory used by Hugo. Hugo comes with the ability to change the themes directory via the [`themesDir` variable in your site configuration][config], but this is not recommended.
|
||||
|
||||
## Using Themes
|
||||
## Use Themes
|
||||
|
||||
Hugo applies the decided theme first and then applies anything that is in the local directory. This allows for easier customization while retaining compatibility with the upstream version of the theme. To learn more, go to [customizing themes][customizethemes].
|
||||
|
||||
|
||||
@@ -236,7 +236,7 @@ In Hugo, you can declare params in individual pages and globally for your entire
|
||||
|
||||
The `.Param` method provides a way to resolve a single value according to it's definition in a page parameter (i.e. in the content's front matter) or a site parameter (i.e., in your `config`).
|
||||
|
||||
### Accessing Nested Fields in Front Matter
|
||||
### Access Nested Fields in Front Matter
|
||||
|
||||
When front matter contains nested fields like the following:
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ Note that `.Data.Terms.Alphabetical` and `.Data.Terms.ByCount` can also be rever
|
||||
* `.Data.Terms.Alphabetical.Reverse`
|
||||
* `.Data.Terms.ByCount.Reverse`
|
||||
|
||||
## Using `.Site.Taxonomies` Outside of Taxonomy Templates
|
||||
## Use `.Site.Taxonomies` Outside of Taxonomy Templates
|
||||
|
||||
The `.Site.Taxonomies` variable holds all the taxonomies defined site-wide. `.Site.Taxonomies` is a map of the taxonomy name to a list of its values (e.g., `"tags" -> ["tag1", "tag2", "tag3"]``). Each value, though, is not a string but rather a *Taxonomy variable*.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user