diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2018-03-11 20:40:26 +0100 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2018-03-11 20:40:26 +0100 |
commit | 95d62004a07d8bb6d2b94a56112fd419db7eeb65 (patch) | |
tree | b0958861ece2af8aa1b3e14b604c4c49f0728793 | |
parent | 68bf1511f2be39b6576d882d071196e477c72c9f (diff) | |
parent | c0290655825e7bb36e13fb39f89d85b392cf1adc (diff) |
Merge commit 'c0290655825e7bb36e13fb39f89d85b392cf1adc'
88 files changed, 506 insertions, 547 deletions
diff --git a/docs/README.md b/docs/README.md index d82776de3..5f47e8a1e 100644 --- a/docs/README.md +++ b/docs/README.md @@ -10,6 +10,12 @@ Note that this repository contains solely the documentation for Hugo. For contri *Pull requests shall **only** contain changes to the actual documentation. However, changes on the code base of Hugo **and** the documentation shall be a single, atomic pull request in the [hugo](https://github.com/gohugoio/hugo) repository.* +Spelling fixes are most welcomed, and if you want to contribute longer sections to the documentation, it would be great if you had these in mind when writing: + +* Short is good. People go to the library to read novels. If there is more than one way to _do a thing_ in Hugo, describe the current _best practice_ (avoid "… but you can also do …" and "… in older versions of Hugo you had to …". +* For examples, try to find short snippets that teaches people about the concept. If the example is also useful as-is (copy and paste), then great, but don't list long and similar examples just so people can use them on their sites. +* Hugo has users from all over the world, so an easy to understand and [simple English](https://simple.wikipedia.org/wiki/Basic_English) is good. + ## Branches * The `master` branch is where the site is automatically built from, and is the place to put changes relevant to the current Hugo version. diff --git a/docs/content/content-management/archetypes.md b/docs/content/content-management/archetypes.md index 269fda6db..902373d83 100644 --- a/docs/content/content-management/archetypes.md +++ b/docs/content/content-management/archetypes.md @@ -1,10 +1,9 @@ --- title: Archetypes linktitle: Archetypes -description: Archetypes allow you to create new instances of content types and set default parameters from the command line. +description: Archetypes are templates used when creating new content. date: 2017-02-01 publishdate: 2017-02-01 -lastmod: 2017-02-01 keywords: [archetypes,generators,metadata,front matter] categories: ["content management"] menu: @@ -18,175 +17,59 @@ aliases: [/content/archetypes/] toc: true --- -{{% note %}} -This section is outdated, see https://github.com/gohugoio/hugoDocs/issues/11 -{{% /note %}} -{{% todo %}} -See above -{{% /todo %}} - ## What are Archetypes? -**Archetypes** are content files in the [archetypes directory][] of your project that contain preconfigured [front matter][] for your website's [content types][]. Archetypes facilitate consistent metadata across your website content and allow content authors to quickly generate instances of a content type via the `hugo new` command. - -{{< youtube bcme8AzVh6o >}} - -The `hugo new` generator for archetypes assumes your working directory is the content folder at the root of your project. Hugo is able to infer the appropriate archetype by assuming the content type from the content section passed to the CLI command: +**Archetypes** are content template files in the [archetypes directory][] of your project that contain preconfigured [front matter][] and possibly also a content disposition for your website's [content types][]. These will be used when you run `hugo new`. -``` -hugo new <content-section>/<file-name.md> -``` -We can use this pattern to create a new `.md` file in the `posts` section: +The `hugo new` uses the `content-section` to find the most suitable archetype template in your project. If your project does not contain any archetype files, it will also look in the theme. {{< code file="archetype-example.sh" >}} hugo new posts/my-first-post.md {{< /code >}} -{{% note "Override Content Type in a New File" %}} -To override the content type Hugo infers from `[content-section]`, add the `--kind` flag to the end of the `hugo new` command. -{{% /note %}} - -Running this command in a new site that does not have default or custom archetypes will create the following file: - -{{< output file="content/posts/my-first-post.md" >}} -+++ -date = "2017-02-01T19:20:04-07:00" -title = "my first post" -draft = true -+++ -{{< /output >}} - -{{% note %}} -In this example, if you do not already have a `content/posts` directory, Hugo will create both `content/posts/` and `content/posts/my-first-post.md` for you. -{{% /note %}} - -The auto-populated fields are worth examining: - -* `title` is generated from the new content's filename (i.e. in this case, `my-first-post` becomes `"my first post"`) -* `date` and `title` are the variables that ship with Hugo and are therefore included in *all* content files created with the Hugo CLI. `date` is generated in [RFC 3339 format][] by way of Go's [`now()`][] function, which returns the current time. -* The third variable, `draft = true`, is *not* inherited by your default or custom archetypes but is included in Hugo's automatically scaffolded `default.md` archetype for convenience. - -Three variables per content file are often not enough for effective content management of larger websites. Luckily, Hugo provides a simple mechanism for extending the number of variables through custom archetypes, as well as default archetypes to keep content creation DRY. - -## Lookup Order for Archetypes - -Similar to the [lookup order for templates][lookup] in your `layouts` directory, Hugo looks for a section- or type-specific archetype, then a default archetype, and finally an internal archetype that ships with Hugo. For example, Hugo will look for an archetype for `content/posts/my-first-post.md` in the following order: +The above will create a new content file in `content/posts/my-first-post.md` using the first archetype file found of these: 1. `archetypes/posts.md` 2. `archetypes/default.md` -3. `themes/<THEME>/archetypes/posts.md` -4. `themes/<THEME>/archetypes/default.md` (Auto-generated with `hugo new site`) - -{{% note "Using a Theme Archetype" %}} -If you wish to use archetypes that ship with a theme, the `t |