mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-21 20:46:30 -05:00
Squashed 'docs/' changes from 16753a78d..341ecabb2
341ecabb2 Update lookup-order.md bfabd8ce8 Update homepage.md 7a1e0b742 Update shortcodes.md e8bf22497 HTTPS links to Vimeo embeds a9d0e7c68 Revise the wildly inaccurate types doc af33bb724 netlify: Bump version f4251583e Merge branch 'temp641' 4dcda861d releaser: Add release notes to /docs for release of 0.64.1 92bd0b1f5 Update errorf.md git-subtree-dir: docs git-subtree-split: 341ecabb29abb9a9626d52309ce0650311607b81
This commit is contained in:
parent
3c0036805d
commit
4b670bc8cc
8 changed files with 50 additions and 94 deletions
|
@ -51,6 +51,17 @@ Here are two examples of paired shortcodes:
|
|||
|
||||
The examples above use two different delimiters, the difference being the `%` character in the first and the `<>` characters in the second.
|
||||
|
||||
### Shortcodes with raw string parameters
|
||||
|
||||
{{< new-in "0.64.1" >}}
|
||||
|
||||
You can pass multiple lines as parameters to a shortcode by using raw string literals:
|
||||
|
||||
```
|
||||
{{</* myshortcode `This is some <b>HTML</b>,
|
||||
and a new line with a "quouted string".` */>}}
|
||||
```
|
||||
|
||||
### Shortcodes with Markdown
|
||||
|
||||
In Hugo `0.55` we changed how the `%` delimiter works. Shortcodes using the `%` as the outer-most delimiter will now be fully rendered when sent to the content renderer (e.g. Blackfriday for Markdown), meaning they can be part of the generated table of contents, footnotes, etc.
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
---
|
||||
title: Content Types
|
||||
linktitle: Types
|
||||
description: Hugo supports sites with multiple content types and assumes your site will be organized into sections, where each section represents the corresponding type.
|
||||
description: Hugo is built around content organized in sections.
|
||||
date: 2017-02-01
|
||||
publishdate: 2017-02-01
|
||||
lastmod: 2017-02-01
|
||||
categories: [content management]
|
||||
keywords: [lists,sections,content types,types,organization]
|
||||
menu:
|
||||
|
@ -17,83 +14,11 @@ aliases: [/content/types]
|
|||
toc: true
|
||||
---
|
||||
|
||||
A **content type** can have a unique set of metadata (i.e., [front matter][]) or customized [template][] and can be created by the `hugo new` command via [archetypes][].
|
||||
A **content type** is a way to organize your content. Hugo resolves the content type from either the `type` in front matter or, if not set, the first directory in the file path. E.g. `content/blog/my-first-event.md` will be of type `blog` if no `type` set.
|
||||
|
||||
## What is a Content Type
|
||||
A content type is used to
|
||||
|
||||
[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.
|
||||
|
||||
## 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`".
|
||||
|
||||
## 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][].
|
||||
|
||||
## 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.
|
||||
* Determine how the content is rendered. See [Template Lookup Order](/templates/lookup-order/) and [Content Views](https://gohugo.io/templates/views) for more.
|
||||
* Determine which [archetype](/content-management/archetypes/) template to use for new content.
|
||||
|
||||
|
||||
{{% note "Declaring Content Types" %}}
|
||||
Remember, all of the following are *optional*. If you do not specifically declare content types in your front matter or develop specific layouts for content types, Hugo is smart enough to assume the content type from the file path and section. (See [Content Sections](/content-management/sections/) for more information.)
|
||||
{{% /note %}}
|
||||
|
||||
The following examples take you stepwise through creating a new type layout for a content file that contains the following front matter:
|
||||
|
||||
{{< code file="content/events/my-first-event.md" copy="false" >}}
|
||||
+++
|
||||
title = My First Event
|
||||
date = "2016-06-24T19:20:04-07:00"
|
||||
description = "Today is my 36th birthday. How time flies."
|
||||
type = "event"
|
||||
layout = "birthday"
|
||||
+++
|
||||
{{< /code >}}
|
||||
|
||||
By default, Hugo assumes `*.md` under `events` is of the `events` content type. However, we have specified that this particular file at `content/events/my-first-event.md` is of type `event` and should render using the `birthday` layout.
|
||||
|
||||
### Create a Type Layout Directory
|
||||
|
||||
Create a directory with the name of the type in `/layouts`. For creating these custom layouts, **type is always singular**; e.g., `events => event` and `posts => post`.
|
||||
|
||||
For this example, you need to create `layouts/event/birthday.html`.
|
||||
|
||||
{{% note %}}
|
||||
If you have multiple content files in your `events` directory that are of the `special` type and you don't want to define the `layout` specifically for each piece of content, you can create a layout at `layouts/special/single.html` to observe the [single page template lookup order](/templates/single-page-templates/).
|
||||
{{% /note %}}
|
||||
|
||||
{{% warning %}}
|
||||
With the "everything is a page" data model introduced in v0.18 (see [Content Organization](/content-management/organization/)), you can use `_index.md` in content directories to add both content and front matter to [list pages](/templates/lists/).
|
||||
{{% /warning %}}
|
||||
|
||||
### Create Views
|
||||
|
||||
Many sites support rendering content in a few different ways; e.g., a single page view and a summary view to be used when displaying a [list of section contents][sectiontemplates].
|
||||
|
||||
Hugo limits assumptions about how you want to display your content to an intuitive set of sane defaults and will support as many different views of a content type as your site requires. All that is required for these additional views is that a template exists in each `/layouts/<TYPE>` directory with the same name.
|
||||
|
||||
### Custom Content Type Template Lookup Order
|
||||
|
||||
The lookup order for the `content/events/my-first-event.md` templates would be as follows:
|
||||
|
||||
* `layouts/event/birthday.html`
|
||||
* `layouts/event/single.html`
|
||||
* `layouts/events/single.html`
|
||||
* `layouts/_default/single.html`
|
||||
|
||||
### Create a Corresponding Archetype
|
||||
|
||||
We can then create a custom archetype with preconfigured front matter at `event.md` in the `/archetypes` directory; i.e. `archetypes/event.md`.
|
||||
|
||||
Read [Archetypes][archetypes] for more information on archetype usage with `hugo new`.
|
||||
|
||||
[archetypes]: /content-management/archetypes/
|
||||
[front matter]: /content-management/front-matter/
|
||||
[sectiontemplates]: /templates/section-templates/
|
||||
[sections]: /content-management/sections/
|
||||
[template]: /templates/
|
||||
[Tumblr]: https://www.tumblr.com/
|
||||
|
|
|
@ -14,7 +14,6 @@ workson: []
|
|||
hugoversion:
|
||||
relatedfuncs: [printf]
|
||||
deprecated: false
|
||||
aliases: [/functions/errorf]
|
||||
---
|
||||
|
||||
`errorf` or `warnf` will evaluate a format string, then output the result to the ERROR or WARNING log (and only once per error message to avoid flooding the log).
|
||||
|
|
22
content/en/news/0.64.1-relnotes/index.md
Normal file
22
content/en/news/0.64.1-relnotes/index.md
Normal file
|
@ -0,0 +1,22 @@
|
|||
|
||||
---
|
||||
date: 2020-02-09
|
||||
title: "Hugo 0.64.1: A couple of Bug Fixes"
|
||||
description: "This version fixes a couple of bugs introduced in 0.64.0."
|
||||
categories: ["Releases"]
|
||||
images:
|
||||
- images/blog/hugo-bug-poster.png
|
||||
|
||||
---
|
||||
|
||||
|
||||
|
||||
This is a bug-fix release with a couple of important fixes.
|
||||
|
||||
* hugofs: Fix mount with hole regression [b78576fd](https://github.com/gohugoio/hugo/commit/b78576fd38a76bbdaab5ad21228c8e5a559090b1) [@bep](https://github.com/bep) [#6854](https://github.com/gohugoio/hugo/issues/6854)
|
||||
* Fix bundle resource ordering regression [18888e09](https://github.com/gohugoio/hugo/commit/18888e09bbb5325bdd63f2cd93116ff490dd37ab) [@bep](https://github.com/bep) [#6851](https://github.com/gohugoio/hugo/issues/6851)
|
||||
* CONTRIBUTING: Fix note about CGO [7f0ebd4a](https://github.com/gohugoio/hugo/commit/7f0ebd4a3c9e016afddc2cf5e7dfe6a820aa099a) [@moorereason](https://github.com/moorereason)
|
||||
* Update Go version requirement [23ea4318](https://github.com/gohugoio/hugo/commit/23ea43180b84e35d99e88083a83e7ca1916b3b36) [@bep](https://github.com/bep) [#6853](https://github.com/gohugoio/hugo/issues/6853)
|
||||
|
||||
|
||||
|
|
@ -54,8 +54,7 @@ The following is an example of a homepage template that uses [partial][partials]
|
|||
{{.Content}}
|
||||
</div>
|
||||
<div>
|
||||
<!-- Note that .Pages is the same as .Site.RegularPages on the homepage template. -->
|
||||
{{ range first 10 .Pages }}
|
||||
{{ range first 10 .Site.RegularPages }}
|
||||
{{ .Render "summary"}}
|
||||
{{ end }}
|
||||
</div>
|
||||
|
|
|
@ -28,15 +28,15 @@ Hugo takes the parameters listed below into consideration when choosing a layout
|
|||
Kind
|
||||
: The page `Kind` (the home page is one). See the example tables below per kind. This also determines if it is a **single page** (i.e. a regular content page. We then look for a template in `_default/single.html` for HTML) or a **list page** (section listings, home page, taxonomy lists, taxonomy terms. We then look for a template in `_default/list.html` for HTML).
|
||||
|
||||
Layout
|
||||
: Can be set in page front matter.
|
||||
|
||||
Output Format
|
||||
: See [Custom Output Formats](/templates/output-formats). An output format has both a `name` (e.g. `rss`, `amp`, `html`) and a `suffix` (e.g. `xml`, `html`). We prefer matches with both (e.g. `index.amp.html`, but look for less specific templates.
|
||||
|
||||
Language
|
||||
: We will consider a language code in the template name. If the site language is `fr`, `index.fr.amp.html` will win over `index.amp.html`, but `index.amp.html` will be chosen before `index.fr.html`.
|
||||
|
||||
Layout
|
||||
: Can be set in page front matter.
|
||||
|
||||
Type
|
||||
: Is value of `type` if set in front matter, else it is the name of the root section (e.g. "blog"). It will always have a value, so if not set, the value is "page".
|
||||
|
||||
|
|
|
@ -252,11 +252,11 @@ Would load the template found at `/layouts/shortcodes/vimeo.html`:
|
|||
{{< code file="/layouts/shortcodes/vimeo.html" >}}
|
||||
{{ if .IsNamedParams }}
|
||||
<div class="{{ if .Get "class" }}{{ .Get "class" }}{{ else }}vimeo-container{{ end }}">
|
||||
<iframe src="//player.vimeo.com/video/{{ .Get "id" }}" allowfullscreen></iframe>
|
||||
<iframe src="https://player.vimeo.com/video/{{ .Get "id" }}" allowfullscreen></iframe>
|
||||
</div>
|
||||
{{ else }}
|
||||
<div class="{{ if len .Params | eq 2 }}{{ .Get 1 }}{{ else }}vimeo-container{{ end }}">
|
||||
<iframe src="//player.vimeo.com/video/{{ .Get 0 }}" allowfullscreen></iframe>
|
||||
<iframe src="https://player.vimeo.com/video/{{ .Get 0 }}" allowfullscreen></iframe>
|
||||
</div>
|
||||
{{ end }}
|
||||
{{< /code >}}
|
||||
|
@ -265,10 +265,10 @@ Would be rendered as:
|
|||
|
||||
{{< code file="vimeo-iframes.html" copy="false" >}}
|
||||
<div class="vimeo-container">
|
||||
<iframe src="//player.vimeo.com/video/49718712" allowfullscreen></iframe>
|
||||
<iframe src="https://player.vimeo.com/video/49718712" allowfullscreen></iframe>
|
||||
</div>
|
||||
<div class="flex-video">
|
||||
<iframe src="//player.vimeo.com/video/49718712" allowfullscreen></iframe>
|
||||
<iframe src="https://player.vimeo.com/video/49718712" allowfullscreen></iframe>
|
||||
</div>
|
||||
{{< /code >}}
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ publish = "public"
|
|||
command = "hugo --gc --minify"
|
||||
|
||||
[context.production.environment]
|
||||
HUGO_VERSION = "0.64.0"
|
||||
HUGO_VERSION = "0.64.1"
|
||||
HUGO_ENV = "production"
|
||||
HUGO_ENABLEGITINFO = "true"
|
||||
|
||||
|
@ -11,20 +11,20 @@ HUGO_ENABLEGITINFO = "true"
|
|||
command = "hugo --gc --minify --enableGitInfo"
|
||||
|
||||
[context.split1.environment]
|
||||
HUGO_VERSION = "0.64.0"
|
||||
HUGO_VERSION = "0.64.1"
|
||||
HUGO_ENV = "production"
|
||||
|
||||
[context.deploy-preview]
|
||||
command = "hugo --gc --minify --buildFuture -b $DEPLOY_PRIME_URL"
|
||||
|
||||
[context.deploy-preview.environment]
|
||||
HUGO_VERSION = "0.64.0"
|
||||
HUGO_VERSION = "0.64.1"
|
||||
|
||||
[context.branch-deploy]
|
||||
command = "hugo --gc --minify -b $DEPLOY_PRIME_URL"
|
||||
|
||||
[context.branch-deploy.environment]
|
||||
HUGO_VERSION = "0.64.0"
|
||||
HUGO_VERSION = "0.64.1"
|
||||
|
||||
[context.next.environment]
|
||||
HUGO_ENABLEGITINFO = "true"
|
||||
|
|
Loading…
Reference in a new issue