Update archetypes documentation for v0.24

This commit is contained in:
Ryan Watters 2017-07-04 23:19:03 -05:00 committed by Anthony Fok
parent 469e504c7e
commit cea93ebe84

View File

@ -60,7 +60,7 @@ 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"`) * `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 Golang's [`now()`][] function, which returns the current time. * `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 Golang's [`now()`][] function, which returns the current time.
* The third variable, `draft = true`, is *not* inherited by your default or custom archetypes but is include in Hugo's internal/base archetype for convenience. * 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. 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.
@ -71,14 +71,13 @@ Similar to the [lookup order for templates][lookup] in your `layouts` directory,
1. `archetypes/posts.md` 1. `archetypes/posts.md`
2. `archetypes/default.md` 2. `archetypes/default.md`
3. `themes/<THEME>/archetypes/posts.md` 3. `themes/<THEME>/archetypes/posts.md`
4. `themes/<THEME>/archetypes/default.md` 4. `themes/<THEME>/archetypes/default.md` (Auto-generated with `hugo new site`)
5. `_internal` (i.e., `title` and `date`)
{{% note "Using a Theme Archetype" %}} {{% note "Using a Theme Archetype" %}}
If you wish to use archetypes that ship with a theme, the `theme` field must be specified in your [configuration file](/getting-started/configuration/). 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 %}} {{% /note %}}
## Choosing Your Front Matter Format ## Choosing 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`. By default, `hugo new` content files include front matter in the TOML format regardless of the format used in `archetypes/*.md`.
@ -90,6 +89,8 @@ Default archetypes are convenient if your content's front matter stays consisten
### Creating the Default Archetype ### Creating 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`.
The following examples are from a site that's using `tags` and `categories` as [taxonomies][]. If we assume that all content files will require these two key-values, we can create a `default.md` archetype that *extends* Hugo's base archetype. In this example, we are including "golang" and "hugo" as tags and "web development" as a category. The following examples are from a site that's using `tags` and `categories` as [taxonomies][]. If we assume that all content files will require these two key-values, we can create a `default.md` archetype that *extends* Hugo's base archetype. In this example, we are including "golang" and "hugo" as tags and "web development" as a category.
{{% code file="archetypes/default.md" %}} {{% code file="archetypes/default.md" %}}