diff options
author | Bjørn Erik Pedersen <[email protected]> | 2018-01-31 11:08:08 +0100 |
---|---|---|
committer | Bjørn Erik Pedersen <[email protected]> | 2018-01-31 11:08:08 +0100 |
commit | 158e1151cdfbdebd2e4a527e828d8a0b17933787 (patch) | |
tree | b73947184a82fe10366dbefe7e3f2d0e415ae801 /docs | |
parent | f0c0ece44d55b6c2997cbd106d1bc099ea1a2fa7 (diff) | |
parent | 337d0c5f516ee085205e8abefdb7f87e6d33ca05 (diff) | |
download | hugo-158e1151cdfbdebd2e4a527e828d8a0b17933787.tar.gz hugo-158e1151cdfbdebd2e4a527e828d8a0b17933787.zip |
Merge commit '337d0c5f516ee085205e8abefdb7f87e6d33ca05'
Diffstat (limited to 'docs')
58 files changed, 1333 insertions, 504 deletions
diff --git a/docs/archetypes/default.md b/docs/archetypes/default.md index 42eb9e04e..f30f01f74 100644 --- a/docs/archetypes/default.md +++ b/docs/archetypes/default.md @@ -1,11 +1,13 @@ --- -title: "{{ replace .TranslationBaseName "-" " " | title }}" -date: {{ .Date }} +linktitle: "" description: "" +godocref: "" +publishdate: "" +lastmod: "" categories: [] -keywords: [] +tags: [] +weight: 00 slug: "" aliases: [] toc: false -draft: true ---- +---
\ No newline at end of file diff --git a/docs/themes/gohugoioTheme/archetypes/functions.md b/docs/archetypes/functions.md index 0a5dd344f..0a5dd344f 100644 --- a/docs/themes/gohugoioTheme/archetypes/functions.md +++ b/docs/archetypes/functions.md diff --git a/docs/config.toml b/docs/config.toml index 346b66d03..61fd44303 100644 --- a/docs/config.toml +++ b/docs/config.toml @@ -98,7 +98,8 @@ twitter = "GoHugoIO" ## Configuration for BlackFriday markdown parser: https://github.com/russross/blackfriday [blackfriday] plainIDAnchors = true - hrefTargetBlank = true + # See https://github.com/gohugoio/hugo/issues/2424 + hrefTargetBlank = false angledQuotes = false latexDashes = true diff --git a/docs/content/about/features.md b/docs/content/about/features.md index f3f490cba..9d29c5bd3 100644 --- a/docs/content/about/features.md +++ b/docs/content/about/features.md @@ -55,7 +55,6 @@ toc: true * Support for [Go][], [Amber], and [Ace][] HTML templates * [Syntax highlighting][] powered by [Pygments][] -See what's coming next in the [Hugo roadmap][]. [Ace]: /templates/alternatives/ [aliases]: /content-management/urls/#aliases @@ -71,7 +70,6 @@ See what's coming next in the [Hugo roadmap][]. [Google Analytics]: https://google-analytics.com/ [homepage]: /templates/homepage/ [hostanywhere]: /hosting-and-deployment/ -[Hugo roadmap]: /about/roadmap [install]: /getting-started/installing/ [LiveReload]: /getting-started/usage/ [organization for your projects]: /getting-started/directory-structure/ diff --git a/docs/content/about/new-in-032/index.md b/docs/content/about/new-in-032/index.md index 0ae93b557..41bd58937 100644 --- a/docs/content/about/new-in-032/index.md +++ b/docs/content/about/new-in-032/index.md @@ -126,15 +126,15 @@ Image operations in Hugo currently **do not preserve EXIF data** as this is not _The photo of the sunset used in the examples below is Copyright [Bjørn Erik Pedersen](https://commons.wikimedia.org/wiki/User:Bep) (Creative Commons Attribution-Share Alike 4.0 International license)_ -{{< imgproc sunset Resize "300x" >}} +{{< imgproc sunset Resize "300x" />}} -{{< imgproc sunset Fill "90x120 left" >}} +{{< imgproc sunset Fill "90x120 left" />}} -{{< imgproc sunset Fill "90x120 right" >}} +{{< imgproc sunset Fill "90x120 right" />}} -{{< imgproc sunset Fit "90x90" >}} +{{< imgproc sunset Fit "90x90" />}} -{{< imgproc sunset Resize "300x q10" >}} +{{< imgproc sunset Resize "300x q10" />}} This is the shortcode used in the examples above: diff --git a/docs/content/about/what-is-hugo.md b/docs/content/about/what-is-hugo.md index c61fa2d40..db947e2f9 100644 --- a/docs/content/about/what-is-hugo.md +++ b/docs/content/about/what-is-hugo.md @@ -19,7 +19,7 @@ toc: true Hugo is a general-purpose website framework. Technically speaking, Hugo is a [static site generator][]. Unlike systems that dynamically build a page with each visitor request, Hugo builds pages when you create or update your content. Since websites are viewed far more often than they are edited, Hugo is designed to provide an optimal viewing experience for your website's end users and an ideal writing experience for website authors. -Websites built with Hugo are extremely fast and secure. Hugo sites can be hosted anywhere, including [Netlify][], [Heroku][], [GoDaddy][], [DreamHost][], [GitHub Pages][], [Surge][], [Aerobatic][], [Firebase][], [Google Cloud Storage][], [Amazon S3][], [Rackspace][], [Azure][], and [CloudFront][] and work well with CDNs. Hugo sites run without the need for a database or dependencies on expensive runtimes like Ruby, Python, or PHP. +Websites built with Hugo are extremely fast and secure. Hugo sites can be hosted anywhere, including [Netlify][], [Heroku][], [GoDaddy][], [DreamHost][], [GitHub Pages][], [GitLab Pages][], [Surge][], [Aerobatic][], [Firebase][], [Google Cloud Storage][], [Amazon S3][], [Rackspace][], [Azure][], and [CloudFront][] and work well with CDNs. Hugo sites run without the need for a database or dependencies on expensive runtimes like Ruby, Python, or PHP. We think of Hugo as the ideal website creation tool with nearly instant build times, able to rebuild whenever a change is made. @@ -50,7 +50,7 @@ Hugo is for people building a blog, a company site, a portfolio site, documentat [DreamHost]: http://www.dreamhost.com/ [Firebase]: https://firebase.google.com/docs/hosting/ "Firebase static hosting" [GitHub Pages]: https://pages.github.com/ -[GitLab]: https://about.gitlab.com +[GitLab Pages]: https://about.gitlab.com/features/pages/ [Go language]: https://golang.org/ [GoDaddy]: https://www.godaddy.com/ "Godaddy.com Hosting" [Google Cloud Storage]: http://cloud.google.com/storage/ diff --git a/docs/content/content-management/archetypes.md b/docs/content/content-management/archetypes.md index c6b8bde76..269fda6db 100644 --- a/docs/content/content-management/archetypes.md +++ b/docs/content/content-management/archetypes.md @@ -173,7 +173,7 @@ title = "post from custom archetype" As an example of archetypes in practice, the following is the `functions` archetype from the Hugo docs: {{< code file="archetypes/functions.md" >}} -{{< readfile file="/themes/gohugoioTheme/archetypes/functions.md" >}} +{{< readfile file="/archetypes/functions.md" >}} {{< /code >}} {{% note %}} diff --git a/docs/content/content-management/front-matter.md b/docs/content/content-management/front-matter.md index b9123db23..01afb2e60 100644 --- a/docs/content/content-management/front-matter.md +++ b/docs/content/content-management/front-matter.md @@ -103,6 +103,9 @@ There are a few predefined variables that Hugo is aware of. See [Page Variables] `expiryDate` : the datetime at which the content should no longer be published by Hugo; expired content will not be rendered unless the `--buildExpired` flag is passed to the `hugo` command. +`headless` +: if `true`, sets a leaf bundle to be [headless][headless-bundle]. + `isCJKLanguage` : if `true`, Hugo will explicitly treat the content as a CJK language; both `.Summary` and `.WordCount` work properly in CJK languages. @@ -127,6 +130,9 @@ There are a few predefined variables that Hugo is aware of. See [Page Variables] `publishDate` : if in the future, content will not be rendered unless the `--buildFuture` flag is passed to `hugo`. +`resources` +: used for configuring page bundle resources. See [Page Resources][page-resources]. + `slug` : appears as the tail of the output URL. A value specified in front matter will override the segment of the URL based on the filename. @@ -186,11 +192,13 @@ It's possible to set some options for Markdown rendering in a content's front ma [content type]: /content-management/types/ [contentorg]: /content-management/organization/ [definetype]: /content-management/types/#defining-a-content-type "Learn how to specify a type and a layout in a content's front matter" +[headless-bundle]: /content-management/page-bundles/#headless-bundle [json]: https://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf "Specification for JSON, JavaScript Object Notation" [lists]: /templates/lists/#ordering-content "See how to order content in list pages; for example, templates that look to specific _index.md for content and front matter." [lookup]: /templates/lookup-order/ "Hugo traverses your templates in a specific order when rendering content to allow for DRYer templating." [ordering]: /templates/lists/ "Hugo provides multiple ways to sort and order your content in list templates" [outputs]: /templates/output-formats/ "With the release of v22, you can output your content to any text format using Hugo's familiar templating" +[page-resources]: /content-management/page-resources/ [pagevars]: /variables/page/ [section]: /content-management/sections/ [taxweight]: /content-management/taxonomies/ diff --git a/docs/content/content-management/image-processing/index.md b/docs/content/content-management/image-processing/index.md new file mode 100644 index 000000000..d31f28dce --- /dev/null +++ b/docs/content/content-management/image-processing/index.md @@ -0,0 +1,141 @@ +--- +title: "Image Processing" +description: "Image Page resources can be resized and cropped." +date: 2018-01-24T13:10:00-05:00 +lastmod: 2018-01-26T15:59:07-05:00 +linktitle: "Image Processing" +categories: ["content management"] +keywords: [bundle,content,resources,images] +weight: 4004 +draft: false +toc: true +menu: + docs: + parent: "content-management" + weight: 32 +--- + +## The Image Page Resource + +The `image` is a [Page Resource]({{< relref "content-management/page-resources" >}}), and the processing methods listed below does not work on images inside your `/static` folder. + + +To get all images in a [Page Bundle]({{< relref "content-management/organization#page-bundles" >}}): + + +```html +{{ with .Resources.ByType "image" }} +{{ end }} + +``` + +## Image Processing Methods + + +The `image` resource implements the methods `Resize`, `Fit` and `Fill`, each returning the transformed image using the specified dimensions and processing options. + +Resize +: Resizes the image to the specified width and height. + +```go +// Resize to a width of 600px and preserve ratio +{{ $image := $resource.Resize "600x" }} + +// Resize to a height of 400px and preserve ratio +{{ $image := $resource.Resize "x400" }} + +// Resize to a width 600px and a height of 400px +{{ $image := $resource.Resize "600x400" }} +``` + +Fit +: Scale down the image to fit the given dimensions while maintaining aspect ratio. Both height and width are required. + +```go +{{ $image := $resource.Fit "600x400" }} +``` + +Fill +: Resize and crop the image to match the given dimensions. Both height and width are required. + +```go +{{ $image := $resource.Fill "600x400" }} +``` + + +{{% note %}} +Image operations in Hugo currently **do not preserve EXIF data** as this is not supported by Go's [image package](https://github.com/golang/go/search?q=exif&type=Issues&utf8=%E2%9C%93). This will be improved on in the future. +{{% /note %}} + + +## Image Processing Options + +In addition to the dimensions (e.g. `600x400`), Hugo supports a set of additional image options. + + +JPEG Quality +: Only relevant for JPEG images, values 1 to 100 inclusive, higher is better. Default is 75. + +```go +{{ $image.Resize "600x q50" }} +``` + +Rotate +: Rotates an image by the given angle counter-clockwise. The rotation will be performed first to get the dimensions correct. The main use of this is to be able to manually correct for [EXIF orientation](https://github.com/golang/go/issues/4341) of JPEG images. + +```go +{{ $image.Resize "600x r90" }} +``` + +Anchor +: Only relevant for the `Fill` method. This is useful for thumbnail generation where the main motive is located in, say, the left corner. +Valid are `Center`, `TopLeft`, `Top`, `TopRight`, `Left`, `Right`, `BottomLeft`, `Bottom`, `BottomRight`. + +```go +{{ $image.Fill "300x200 BottomLeft" }} +``` + +Resample Filter +: Filter used in resizing. Default is `Box`, a simple and fast resampling filter appropriate for downscaling. + +Examples are: `Box`, `NearestNeighbor`, `Linear`, `Gaussian`. + +See https://github.com/disintegration/imaging for more. If you want to trade quality for faster processing, this may be a option to test. + +```go +{{ $image.Resize "600x400 Gaussian" }} +``` + +### Image Processing Examples + +_The photo of the sunset used in the examples below is Copyright [Bjørn Erik Pedersen](https://commons.wikimedia.org/wiki/User:Bep) (Creative Commons Attribution-Share Alike 4.0 International license)_ + + +{{< imgproc sunset Resize "300x" />}} + +{{< imgproc sunset Fill "90x120 left" />}} + +{{< imgproc sunset Fill "90x120 right" />}} + +{{< imgproc sunset Fit "90x90" />}} + +{{< imgproc sunset Resize "300x q10" />}} + + +This is the shortcode used in the examples above: + + +{{< code file="layouts/shortcodes/imgproc.html" >}} +{{< readfile file="layouts/shortcodes/imgproc.html" >}} +{{< /code >}} + +And it is used like this: + +```html +{{</* imgproc sunset Resize "300x" /*/>}} +``` + + +{{% note %}} +**Tip:** Note the self-closing shortcode syntax above. The `imgproc` shortcode can be called both with and without **inner content**. +{{% /note %}}
\ No newline at end of file diff --git a/docs/content/content-management/image-processing/sunset.jpg b/docs/content/content-management/image-processing/sunset.jpg Binary files differnew file mode 100644 index 000000000..7d7307bed --- /dev/null +++ b/docs/content/content-management/image-processing/sunset.jpg diff --git a/docs/content/content-management/multilingual.md b/docs/content/content-management/multilingual.md index 31d409109..22271b4c8 100644 --- a/docs/content/content-management/multilingual.md +++ b/docs/content/content-management/multilingual.md @@ -17,7 +17,7 @@ aliases: [/content/multilingual/,/content-management/multilingual/,/tutorials/cr toc: true --- -You should define the available languages in a `Languages` section in your site configuration. +You should define the available languages in a `languages` section in your site configuration. ## Configure Languages @@ -30,22 +30,24 @@ copyright = "Everything is mine" [params.navigation] help = "Help" -[Languages] -[Languages.en] +[languages] +[languages.en] title = "My blog" weight = 1 linkedin = "english-link" -[Languages.fr] +[languages.fr] copyright = "Tout est à moi" title = "Mon blog" weight = 2 linkedin = "lien-francais" -[Languages.fr.navigation] + +# skip params key for front matter +[languages.fr.navigation] help = "Aide" {{< /code >}} -Anything not defined in a `[Languages]` block will fall back to the global +Anything not defined in a `[languages]` block will fall back to the global value for that key (e.g., `copyright` for the English [`en`] language). With the configuration above, all content, sitemap, RSS feeds, paginations, @@ -116,17 +118,17 @@ tag = "tags" angledQuotes = true hrefTargetBlank = true -[Languages] -[Languages.en] +[languages] +[languages.en] weight = 1 title = "English" -[Languages.en.blackfriday] +[languages.en.blackfriday] angledQuotes = false -[Languages.fr] +[languages.fr] weight = 2 title = "Français" -[Languages.fr.Taxonomies] +[languages.fr.Taxonomies] plaque = "plaques" {{< /code >}} @@ -186,7 +188,7 @@ To create a list of links to translated content, use a template similar to the f {{ end }} {{< /code >}} -The above can be put in a `partial` (i.e., inside `layouts/partials/`) and included in any template, be it for a [single content page][contenttemplate] or the [homepage][]. It will not print anything if there are no translations for a given page, or if there are translations---in the case of the homepage, section listing, etc.---a site with only render one language. +The above can be put in a `partial` (i.e., inside `layouts/partials/`) and included in any template, be it for a [single content page][contenttemplate] or the [homepage][]. It will not print anything if there are no translations for a given page. The above also uses the [`i18n` function][i18func] described in the next section. diff --git a/docs/content/content-management/organization/1-featured-content-bundles.png b/docs/content/content-management/organization/1-featured-content-bundles.png Binary files differnew file mode 100644 index 000000000..1706a29d6 --- /dev/null +++ b/docs/content/content-management/organization/1-featured-content-bundles.png diff --git a/docs/content/content-management/organization.md b/docs/content/content-management/organization/index.md index 6a854c250..742a9e5fe 100644 --- a/docs/content/content-management/organization.md +++ b/docs/content/content-management/organization/index.md @@ -6,7 +6,7 @@ date: 2017-02-01 publishdate: 2017-02-01 lastmod: 2017-02-01 categories: [content management,fundamentals] -keywords: [sections,content,organization] +keywords: [sections,content,organization,bundle,resources] menu: docs: parent: "content-management" @@ -17,17 +17,24 @@ aliases: [/content/sections/] toc: true --- -{{< youtube 0GZxidrlaRM >}} +## Page Bundles -## Content Bundles and Image Processing +Hugo `0.32` announced page-relative images and other resources packaged into `Page Bundles`. -See [This Page](/about/new-in-032/). We will get the relevant parts of the rest of the Hugo docs updated. Eventually. +These terms are connected, and you also need to read about [Page Resources]({{< relref "content-management/page-resources" >}}) and [Image Processing]({{< relref "content-management/image-processing" >}}) to get the full picture. -{{< todo >}} -Remove the above when done. -{{< /todo >}} +{{% imgproc 1-featured Resize "300x" %}} +The illustration shows 3 bundles. Note that the home page bundle cannot contain other content pages, but other files (images etc.) are fine. +{{% /imgproc %}} + + +{{% note %}} +The bundle docuementation is **work in progress**. We will publish more comprehensive docs about this soon. +{{% /note %}} + + +# Organization of Content Source -## Organization of Content Source In Hugo, your content should be organized in a manner that reflects the rendered website. diff --git a/docs/content/content-management/page-bundles.md b/docs/content/content-management/page-bundles.md new file mode 100644 index 000000000..7c5ca85d6 --- /dev/null +++ b/docs/content/content-management/page-bundles.md @@ -0,0 +1,182 @@ +--- +title : "Page Bundles" +description : "Content organization using Page Bundles" +date : 2018-01-24T13:09:00-05:00 +lastmod : 2018-01-28T22:26:40-05:00 +linktitle : "Page Bundles" +keywords : ["page", "bundle", "leaf", "branch"] +categories : ["content management"] +draft : true +toc : true +menu : + docs: + identifier : "page-bundles" + parent : "content-management" + weight : 11 +--- + +Page Bundles are a way to organize the content files. It's useful for +cases where a page or section's content needs to be split into +multiple content pages for convenience or has associated attachments +like documents or images. + +A Page Bundle can be one of two types: + +- Leaf Bundle +- Branch Bundle + +| | Leaf Bundle | Branch Bundle | +|-----------------|--------------------------------------------------------|---------------------------------------------------------| +| Usage | Collection of content and attachments for single pages | Collection of content and attachments for section pages | +| Index file name | `index.md` [^fn:1] | `_index.md` [^fn:1] | +| Layout type | `single` | `list` | +| Nesting | Doesn't allow nesting of more bundles under it | Allows nesting of leaf/branch bundles under it | +| Example | `content/posts/my-post/index.md` | `content/posts/_index.md` | + + +## Leaf Bundles {#leaf-bundles} + +A _Leaf Bundle_ is a directory at any hierarchy within the `content/` +directory, that contains at least an **`index.md`** file. + +{{% note %}} +Here `md` (markdown) is used just as an example. You can use any file +type as a content resource as long as it is a MIME type recognized by +Hugo (`json` files will, as one example, work fine). If you want to +get exotic, you can define your own media type. +{{% /note %}} + + +### Examples of Leaf Bundle organization {#examples-of-leaf-bundle-organization} + +```text +content/ +├── about +│ ├── index.md +├── posts +│ ├── my-post +│ │ ├── content1.md +│ │ ├── content2.md +│ │ ├── image1.jpg +│ │ ├── image2.png +│ │ └── index.md +│ └── my-another-post +│ └── index.md +│ +└── another-section + ├── .. + └── not-a-leaf-bundle + ├── .. + └── another-leaf-bundle + └── index.md +``` + +In the above example `content/` directory, there are four leaf +bundles: + +about +: This leaf bundle is at the root level (directly under + `content` directory) and has only the `index.md`. + +my-post +: This leaf bundle has the `index.md`, two other content + Markdown files and two image files. + +my-another-post +: This leaf bundle has only the `index.md`. + +another-leaf-bundle +: This leaf bundle is nested under couple of + directories. This bundle also has only the `index.md`. + +{{% note %}} +The hierarchy depth at which a leaf bundle is created does not matter, +as long as it is not inside another **leaf** bundle. +{{% /note %}} + + +### Headless Bundle {#headless-bundle} + +A headless bundle is a bundle that is configured to not get published +anywhere: + +- It will have no `Permalink` and no rendered HTML in `public/`. +- It will not be part of `.Site.RegularPages`, etc. + +But you can get it by `.Site.GetPage`. Here is an example: + +```html +{{ $headless := .Site.GetPage "page" "some-headless-bundle" }} +{{ $reusablePages := $headless.Resources.Match "author*" }} +<h2>Authors</h2> +{{ range $reusablePages }} + <h3>{{ .Title }}</h3> + {{ .Content }} +{{ end }} +``` + +A leaf bundle can be made headless by adding below in the Front Matter +(in the `index.md`): + +```toml +headless = true +``` + +{{% note %}} +Only leaf bundles can be made headless. +{{% /note %}} + +There are many use cases of such headless page bundles: + +- Shared media galleries +- Reusable page content "snippets" + + +## Branch Bundles {#branch-bundles} + +A _Branch Bundle_ is any directory at any hierarchy within the +`content/` directory, that contains at least an **`_index.md`** file. + +This `_index.md` can also be directly under the `content/` directory. + +{{% note %}} +Here `md` (markdown) is used just as an example. You can use any file +type as a content resource as long as it is a MIME type recognized by +Hugo (`json` files will, as one example, work fine). If you want to +get exotic, you can define your own media type. +{{% /note %}} + + +### Examples of Branch Bundle organization {#examples-of-branch-bundle-organization} + +```text +content/ +├── branch-bundle-1 +│ ├── branch-content1.md +│ ├── branch-content2.md +│ ├── image1.jpg +│ ├── image2.png +│ └── _index.md +└── branch-bundle-2 + ├── _index.md + └── a-leaf-bundle + └── index.md +``` + +In the above example `content/` directory, there are two branch +bundles (and a leaf bundle): + +`branch-bundle-1` +: This branch bundle has the `_index.md`, two + other content Markdown files and two image files. + +`branch-bundle-2` +: This branch bundle has the `_index.md` and a + nested leaf bundle. + +{{% note %}} +The hierarchy depth at which a branch bundle is created does not +matter. +{{% /note %}} + +[^fn:1]: The `.md` extension is just an example. The extension can be `.html`, `.json` or any of any valid MIME type. diff --git a/docs/content/content-management/page-resources.md b/docs/content/content-management/page-resources.md new file mode 100644 index 000000000..f3b12d8c4 --- /dev/null +++ b/docs/content/content-management/page-resources.md @@ -0,0 +1,184 @@ +--- +title : "Page Resources" +description : "Page Resources -- images, other pages, documents etc. -- have page-relative URLs and their own metadata." +date: 2018-01-24 +categories: ["content management"] +keywords: [bundle,content,resources] +weight: 4003 +draft: false +toc: true +linktitle: "Page Resources" +menu: + docs: + parent: "content-management" + weight: 31 +--- + +## Properties + +ResourceType +: The main type of the resource. For example, a file of MIME type `image/jpg` has for ResourceType `image`. + +Name +: Default value is the filename (relative to the owning page). Can be set in front matter. + +Title +: Default blank. Can be set in front matter. + +Permalink +: The absolute URL to the resource. Resources of type `page` will have no value. + +RelPermalink +: The relative URL to the resource. Resources of type `page` will have no value. + +## Methods +ByType +: Returns the page resources of the given type. + +```go +{{ .Resources.ByType "image" }} +``` +Match +: Returns all the page resources (as a slice) whose `Name` matches the given Glob pattern ([examples](https://github.com/gobwas/glob/blob/master/readme.md)). The matching is case-insensitive. + +```go +{{ .Resources.Match "images/*" }} +``` + +GetMatch +: Same as `Match` but will return the first match. + +### Pattern Matching +```go +// Using Match/GetMatch to find this images/sunset.jpg ? +.Resources.Match "images/sun*" ✅ +.Resources.Match "**/Sunset.jpg" ✅ +.Resources.Match "images/*.jpg" ✅ +.Resources.Match "**.jpg" ✅ +.Resources.Match "*" 🚫 +.Resources.Match "sunset.jpg" 🚫 +.Resources.Match "*sunset.jpg" 🚫 + +``` + +## Page Resources Metadata + +Page Resources' metadata is managed from their page's front matter with an array/table parameter named `resources`. You can batch assign values using a [wildcards](http://tldp.org/LDP/GNU-Linux-Tools-Summary/html/x11655.htm). + +{{% note %}} +Resources of type `page` get `Title` etc. from their own front matter. +{{% /note %}} + +name +: Sets the value returned in `Name`. + +{{% warning %}} +The methods `Match` and `GetMatch` use `Name` to match the resources. +{{%/ warning %}} + +title +: Sets the value returned in `Title` + +params +: A map of custom key/values. + + +### Resources metadata: YAML Example + +~~~yaml +title: Application +date : 2018-01-25 +resources : +- src : "images/sunset.jpg" + name : "header" +- src : "documents/photo_specs.pdf" + title : "Photo Specifications" + params: + icon : "photo" +- src : "documents/guide.pdf" + title : "Instruction Guide" +- src : "documents/checklist.pdf" + title : "Document Checklist" +- src : "documents/payment.docx" + title : "Proof of Payment" +- src : "**.pdf" + name : "pdf-file-:counter" + params : + icon : "pdf" +- src : "**.docx" + params : + icon : "word" +~~~ + +### Resources metadata: TOML Example + +~~~toml +title = Application +date : 2018-01-25 +[[resources]] + src = "images/sunset.jpg" + name = "header" +[[resources]] + src = "documents/photo_specs.pdf" + title = "Photo Specifications" + [resources.params] + icon = "photo" +[[resources]] + src = "documents/guide.pdf" + title = "Instruction Guide" +[[resources]] + src = "documents/checklist.pdf" + title = "Document Checklist" +[[resources]] + src = "documents/payment.docx" + title = "Proof of Payment" +[[resources]] + src = "**.pdf" + name = "pdf-file-:counter" + [resources.params] + icon = "pdf" +[[resources]] + src = "**.docx" + [resources.params] + icon = "word" +~~~ + + +From the example above: + +- `sunset.jpg` will receive a new `Name` and can now be found with `.GetMatch "header"`. +- `documents/photo_specs.pdf` will get the `photo` icon. +- `documents/checklist.pdf`, `documents/guide.pdf` and `documents/payment.docx` will get `Title` as set by `title`. +- Every `PDF` in the bundle except `documents/photo_specs.pdf` will get the `pdf` icon. +- All `PDF` files will get a new `Name`. The `name` parameter contains a special placeholder [`:counter`](#counter), so the `Name` will be `pdf-file-1`, `pdf-file-2`, `pdf-file-3`. +- Every docx in the bundle will receive the `word` icon. + +{{% warning %}} +The __order matters__ --- Only the **first set** values of the `title`, `name` and `params`-**keys** will be used. Consecutive parameters will be set only for the ones not already set. For example, in the above example, `.Params.icon` is already first set to `"photo"` in `src = "documents/photo_specs.pdf"`. So that would not get overridden to `"pdf"` by the later set `src = "**.pdf"` rule. +{{%/ warning %}} + +### The `:counter` placeholder in `name` and `title` + +The `:counter` is a special placeholder recognized in `name` and `title` parameters `resources`. + +The counter starts at 1 the first time they are used in either `name` or `title`. + +For example, if a bundle has the resources `photo_specs.pdf`, `other_specs.pdf`, `guide.pdf` and `checklist.pdf`, and the front matter has specified the `resources` as: + +~~~toml +[[resources]] + src = "*specs.pdf" + title = "Specification #:counter" +[[resources]] + src = "**.pdf" + name = "pdf-file-:counter" +~~~ + +the `Name` and `Title` will be assigned to the resource files as follows: + +| Resource file | `Name` | `Title` | +|-------------------|-------------------|-----------------------| +| checklist.pdf | `"pdf-file-1.pdf` | `"checklist.pdf"` | +| guide.pdf | `"pdf-file-2.pdf` | `"guide.pdf"` | +| other\_specs.pdf | `"pdf-file-3.pdf` | `"Specification #1"` | +| photo\_specs.pdf | `"pdf-file-4.pdf` | `"Specification #2"` | diff --git a/docs/content/content-management/taxonomies.md b/docs/content/content-management/taxonomies.md index 0d0a26327..1a59ebe3e 100644 --- a/docs/content/content-management/taxonomies.md +++ b/docs/content/content-management/taxonomies.md @@ -240,7 +240,7 @@ If you need to add custom metadata to your taxonomy terms, you will need to crea --- {{< /code >}} -You can later use your custom metadata as shown in the [Taxonomy Terms Templates documentation](/templates/taxonomy-templates/#displaying-custom-meta-data-in-taxonomy-terms-templates). +You can later use your custom metadata as shown in the [Taxonomy Terms Templates documentation](/templates/taxonomy-templates/#displaying-custom-metadata-in-taxonomy-terms-templates). [`urlize` template function]: /functions/urlize/ [content section]: /content-management/sections/ diff --git a/docs/content/contribute/documentation.md b/docs/content/contribute/documentation.md index 3d5956ac2..e8603d432 100644 --- a/docs/content/contribute/documentation.md +++ b/docs/content/contribute/documentation.md @@ -46,10 +46,10 @@ Once you have cloned the Hugo repository, you can create a new function via the hugo new functions/newfunction.md ``` -The archetype for `functions` according to the Hugo theme is as follows: +The archetype for `functions` according to the Hugo docs is as follows: {{< code file="archetypes/functions.md" >}} -{{< readfile file="/themes/gohugoioTheme/archetypes/functions.md">}} +{{< readfile file="/archetypes/functions.md">}} {{< /code >}} #### New Function Required Fields diff --git a/docs/content/functions/cond.md b/docs/content/functions/cond.md new file mode 100644 index 000000000..16c1f105f --- /dev/null +++ b/docs/content/functions/cond.md @@ -0,0 +1,26 @@ +--- +title: "cond" +date: 2017-09-08 +description: "Return one of two arguments, depending on the value of a third argument." +categories: [functions] +menu: + docs: + parent: "functions" +signature: ["cond CONTROL VAR1 VAR2"] +aliases: [/functions/cond/] +hugoversion: 0.27 +relatedfuncs: [default] +toc: false +draft: false +needsexamples: false +--- + +`cond` returns *VAR1* if *CONTROL* is true, or *VAR2* if it is not. + +Example: + +``` +{{ cond (eq (len $geese) 1) "goose" "geese" }} +``` + +Would emit "goose" if the `$geese` array has exactly 1 item, or "geese" otherwise. diff --git a/docs/content/functions/int.md b/docs/content/functions/int.md index 8f727b235..f5416c1dc 100644 --- a/docs/content/functions/int.md +++ b/docs/content/functions/int.md @@ -24,3 +24,28 @@ Useful for turning strings into numbers. ``` {{ int "123" }} → 123 ``` + +{{% note "Usage Note" %}} +If the input string is supposed to represent a decimal number, and if it has +leading 0's, then those 0's will have to be removed before passing the string +to the `int` function, else that string will be tried to be parsed as an octal +number representation. + +The [`strings.TrimLeft` function](/functions/strings.trimleft/) can be used for +this purpose. + +``` +{{ int ("0987" | strings.TrimLeft "0") }} +{{ int ("00987" | strings.TrimLeft "0") }} +``` + +**Explanation** + +The `int` function eventually calls the `ParseInt` function from the Go library +`strconv`. + +From its [documentation](https://golang.org/pkg/strconv/#ParseInt): + +> the base is implied by the string's prefix: base 16 for "0x", base 8 for "0", +> and base 10 otherwise. +{{% /note %}} diff --git a/docs/content/getting-started/configuration.md b/docs/content/getting-started/configuration.md index d4fb5a17e..7b31931e5 100644 --- a/docs/content/getting-started/configuration.md +++ b/docs/content/getting-started/configuration.md @@ -73,7 +73,6 @@ canonifyURLs: false config: "config.toml" contentDir: "content" dataDir: "data" -defaultExtension: "html" defaultLayout: "post" # Missing translations will default to this content language defaultContentLanguage: "en" @@ -216,7 +215,6 @@ canonifyURLs = false config = "config.toml" contentDir = "content" dataDir = "data" -defaultExtension = "html" defaultLayout = "post" # Missing translations will default to this content language defaultContentLanguage = "en" diff --git a/docs/content/getting-started/installing.md b/docs/content/getting-started/installing.md index cc3783353..d9ded804d 100644 --- a/docs/content/getting-started/installing.md +++ b/docs/content/getting-started/installing.md @@ -4,7 +4,7 @@ linktitle: Install Hugo description: Install Hugo on macOS, Windows, Linux, FreeBSD, and on any machine where the Go compiler tool chain can run. date: 2016-11-01 publishdate: 2016-11-01 -lastmod: 2017-02-20 +lastmod: 2018-01-02 categories: [getting started,fundamentals] authors: ["Michael Henderson"] keywords: [install,pc,windows,linux,macos,binary,tarball] @@ -453,7 +453,15 @@ You can also install Hugo from the Arch Linux [community](https://www.archlinux. sudo pacman -Sy hugo ``` -### Fedora, CentOS, and Red Hat +### Fedora + +Fedora provides a package for Hugo. The installation is done with the command : + +``` +sudo dnf install hugo +``` + +### CentOS, and Red Hat * <https://copr.fedorainfracloud.org/coprs/daftaupe/hugo/> diff --git a/docs/content/hosting-and-deployment/deployment-with-nanobox.md b/docs/content/hosting-and-deployment/deployment-with-nanobox.md index e43ae7f48..245e9544a 100644 --- a/docs/content/hosting-and-deployment/deployment-with-nanobox.md +++ b/docs/content/hosting-and-deployment/deployment-with-nanobox.md @@ -115,8 +115,8 @@ Do this by adding a custom install script at the root of your project that will if [[ ! -f /data/bin/hugo ]]; then cd /tmp - wget https://github.com/gohugoio/hugo/releases/download/v0.25.1/hugo_0.25.1_Linux-64bit.tar.gz - tar -xzf hugo_0.25.1_Linux-64bit.tar.gz + wget https://github.com/gohugoio/hugo/releases/download/v0.31.1/hugo_0.31.1_Linux-64bit.tar.gz + tar -xzf hugo_0.31.1_Linux-64bit.tar.gz mv hugo /data/bin/hugo cd - rm -rf /tmp/* @@ -127,6 +127,9 @@ fi {{% note %}} If the install script fails during `nanobox run` you may need to make it executable with `chmod +x install.sh` {{% /note %}} +{{% note %}} +Make sure to check the version of Hugo you have installed and update the install script to match. +{{% /note %}} ### Generating a New Hugo App diff --git a/docs/content/hosting-and-deployment/hosting-on-github.md b/docs/content/hosting-and-deployment/hosting-on-github.md index d3d0385cd..fc874f892 100644 --- a/docs/content/hosting-and-deployment/hosting-on-github.md +++ b/docs/content/hosting-and-deployment/hosting-on-github.md @@ -27,13 +27,84 @@ GitHub provides free and fast static hosting over SSL for personal, organization 2. You have a GitHub account. [Signing up][ghsignup] for GitHub is free. 3. You have a ready-to-publish Hugo website or have at least completed the [Quick Start][]. -If you are working within an Organization account or want to set up a User website on GitHub and would like more information, refer to the [GitHub Pages documentation][ghorgs]. +## Types of GitHub Pages + +There are 2 types of GitHub Pages: + +- User/Organization Pages (`https://<USERNAME|ORGANIZATION>.github.io/`) +- Project Pages (`https://<USERNAME|ORGANIZATION>.github.io/<PROJECT>/`) + +Please refer to the [GitHub Pages documentation][ghorgs] to decide which type of site you would like to create as it will determine which of the below methods to use. + +To create a User/Organization Pages site, follow the single method in the *GitHub User and Organization Pages* section below. + +To create a Project Pages site, choose a method from the *Project Pages* section below. + +## GitHub User or Organization Pages + +As mentioned [the GitHub Pages documentation][ghorgs], 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: + +1. You must use a `<USERNAME>.github.io` to host your **generated** content +2. Content from the `master` branch will be used to publish your GitHub Pages site + +This is a much simpler setup as your Hugo files and generated content are published into two different repositories. + +### Step-by-step Instructions + +1. Create a `<YOUR-PROJECT>` (e.g. `blog`) repository on GitHub. This repository will contain Hugo's content and other source files. +2. Create a `<USERNAME>.github.io` GitHub repository. This is the repository that will contain the fully rendered version of your Hugo website. +3. `git clone <YOUR-PROJECT-URL> && cd <YOUR-PROJECT>` +4. Make your website work locally (`hugo server` or `hugo server -t <YOURTHEME>`) and open your browser to <http://localhost:1313>. +5. Once you are happy with the results: + * Press <kbd>Ctrl</kbd>+<kbd>C</kbd> to kill the server + * `rm -rf public` to completely remove the `public` directory +6. `git submodule add -b master [email protected]:<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. + +### 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`. + +The following are the contents of the `deploy.sh` script: + +``` +#!/bin/bash + +echo -e "\033[0;32mDeploying updates to GitHub...\033[0m" + +# Build the project. +hugo # if using a theme, replace with `hugo -t <YOURTHEME>` + +# Go To Public folder +cd public +# Add changes to git. +git add . + +# Commit changes. +msg="rebuilding site `date`" +if [ $# -eq 1 ] + then msg="$1" +fi +git commit -m "$msg" + +# Push source and build repos. +git push origin master + +# Come Back up to the Project Root +cd .. +``` + + +You can then run `./deploy.sh "Your optional commit message"` to send changes to `<USERNAME>.github.io`. Note that you likely will want to commit changes to your `<YOUR-PROJECT>` repository as well. + +That's it! Your personal page should be up and running at `https://<USERNAME>.github.io` within a couple minutes. + +## GitHub Project Pages {{% note %}} -Make sure your `baseURL` key-value in your [site configuration](/getting-started/configuration/) reflects the full URL of your GitHub pages repository if you're using the default GH Pages URL (e.g., `username.github.io/myprojectname/`) and not a custom domain. +Make sure your `baseURL` key-value in your [site configuration](/getting-started/configuration/) reflects the full URL of your GitHub pages repository if you're using the default GH Pages URL (e.g., `<USERNAME>.github.io/<PROJECT>/`) and not a custom domain. {{% /note %}} -## Deployment via `/docs` Folder on Master Branch +### Deployment of Project Pages from `/docs` folder on `master` branch [As described in the GitHub Pages documentation][ghpfromdocs], you can deploy from a folder called `docs/` on your master branch. To effectively use this feature with Hugo, you need to change the Hugo publish directory in your [site's][config] `config.toml` and `config.yaml`, respectively: @@ -53,18 +124,18 @@ After running `hugo`, push your master branch to the remote repository and choos The `docs/` option is the simplest approach but requires you set a publish directory in your site configuration. You cannot currently configure GitHub pages to publish from another directory on master, and not everyone prefers the output site live concomitantly with source files in version control. {{% /note %}} -## Deployment From Your `gh-pages` Branch +### Deployment of Project Pages From Your `gh-pages` branch You can also tell GitHub pages to treat your `master` branch as the published site or point to a separate `gh-pages` branch. The latter approach is a bit more complex but has some advantages: * It keeps your source and generated website in different branches and therefore maintains version control history for both. * Unlike the preceding `docs/` option, it uses the default `public` folder. -### Preparations for `gh-pages` Branch +#### Preparations for `gh-pages` Branch These steps only need to be done once. Replace `upstream` with the name of your remote; e.g., `origin`: -#### Add the Public Folder +##### Add the `public` Folder First, add the `public` folder to your `.gitignore` file at the project root so that the directory is ignored on the master branch: @@ -72,7 +143,7 @@ First, add the `public` folder to your `.gitignore` file at the project root so echo "public" >> .gitignore ``` -#### Initialize Your `gh-pages` Branch +##### Initialize Your `gh-pages` Branch You can now initialize your `gh-pages` branch as an empty [orphan branch][]: @@ -84,7 +155,7 @@ git push upstream gh-pages git checkout master ``` -### Build 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: @@ -106,7 +177,7 @@ If the changes in your local `gh-pages` branch look alright, push them to the re git push upstream gh-pages ``` -#### Set `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: @@ -115,7 +186,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. -### Put it Into a Script +#### Put it Into a Script To automate these steps, you can create a script with the following contents: @@ -153,7 +224,7 @@ cd public && git add --all && git commit -m "Publishing to gh-pages (publish.sh) This will abort if there are pending changes in the working directory and also makes sure that all previously existing output files are removed. Adjust the script to taste, e.g. to include the final push to the remote repository if you don't need to take a look at the gh-pages branch before pushing. Or adding `echo yourdomainname.com >> CNAME` if you set up for your gh-pages to use customize domain. -## Deployment From Your `master` Branch +### Deployment of Project Pages from Your `master` Branch To use `master` as your publishing branch, you'll need your rendered website to live at the root of the GitHub repository. Steps should be similar to that of the `gh-pages` branch, with the exception that you will create your GitHub repository with the `public` directory as the root. Note that this does not provide the same benefits of the `gh-pages` branch in keeping your source and output in separate, but version controlled, branches within the same repo. @@ -162,64 +233,6 @@ 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**. -## 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: - -1. You must use the `<USERNAME>.github.io` naming scheme for your GitHub repo. -2. Content from the `master` branch will be used to publish your GitHub Pages site. - -It becomes much simpler in this case: we'll create two separate repos, one for Hugo's content, and a git submodule with the `public` folder's content in it. - -### Step-by-step Instructions - -1. Create a `<YOUR-PROJECT>` git repository on GitHub. This repository will contain Hugo's content and other source files. -2. Create a `<USERNAME>.github.io` GitHub repository. This is the repository that will contain the fully rendered version of your Hugo website. -3. `git clone <YOUR-PROJECT-URL> && cd <YOUR-PROJECT>` -4. Make your website work locally (`hugo server` or `hugo server -t <YOURTHEME>`) and open your browser to <http://localhost:1313>. -5. Once you are happy with the results: - * Press <kbd>Ctrl</kbd>+<kbd>C</kbd> to kill the server - * `rm -rf public` to completely remove the `public` directory if there -6. `git submodule add -b master [email protected]:<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. - -#### 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`. - -The following are the contents of the `deploy.sh` script: - -``` -#!/bin/bash - -echo -e "\033[0;32mDeploying updates to GitHub...\033[0m" - -# Build the project. -hugo # if using a theme, replace with `hugo -t <YOURTHEME>` - -# Go To Public folder -cd public -# Add changes to git. -git add . - -# Commit changes. -msg="rebuilding site `date`" -if [ $# -eq 1 ] - then msg="$1" -fi -git commit -m "$msg" - -# Push source and build repos. -git push origin master - -# Come Back up to the Project Root -cd .. -``` - - -You can then run `./deploy.sh "Your optional commit message"` to send changes to `<USERNAME>.github.io`. Note that you likely will want to commit changes to your `<YOUR-PROJECT>` repository as well. - -That's it! Your personal page should be up and running at `https://yourusername.github.io` within a couple minutes. - ## 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. diff --git a/docs/content/hosting-and-deployment/hosting-on-netlify.md b/docs/content/hosting-and-deployment/hosting-on-netlify.md index 9f34f5168..def152b36 100644 --- a/docs/content/hosting-and-deployment/hosting-on-netlify.md +++ b/docs/content/hosting-and-deployment/hosting-on-netlify.md @@ -145,7 +145,7 @@ You now have a live website served over https, distributed through CDN, and conf [ghsm]: https://github.com/blog/2104-working-with-submodules [gitsm]: https://git-scm.com/book/en/v2/Git-Tools-Submodules [httpscustom]: https://www.netlify.com/docs/ssl/ -[hugoversions]: https://github.com/netlify/build-image/blob/master/Dockerfile#L166 +[hugoversions]: https://github.com/netlify/build-image/blob/master/Dockerfile#L216 [installthemes]: /themes/installing/ [netlify]: https://www.netlify.com/ [netlifysignup]: https://app.netlify.com/signup diff --git a/docs/content/news/0.33-relnotes-ready.md b/docs/content/news/0.33-relnotes-ready.md index 318c42f8e..449da614f 100644 --- a/docs/content/news/0.33-relnotes-ready.md +++ b/docs/content/news/0.33-relnotes-ready.md @@ -1,10 +1,13 @@ --- date: 2018-01-18 -title: "0.33" -description: "0.33" -slug: "0.33" +title: "Hugo 0.33: The New Kinder Surprise!" +description: "Hugo 0.33 comes with resource (images etc.) metadata, `type` and `layout` for all page types, `url` in front matter for list pages …" +slug: "0.33-relnotes" categories: ["Releases"] +images: +- images/blog/hugo-33-poster.png + --- Hugo `0.33` is the first main Hugo release of the new year, and it is safe to say that [@bep](https://github.com/bep) has turned off his lazy Christmas mode :smiley: @@ -39,6 +42,7 @@ Hugo now has: ## Notes * We have re-implemented and unified the template layout lookup logic. This has made it more powerful and much simpler to understand. We don't expect any sites to break because of this. We have tested lots of Hugo sites, including the 200 [themes](http://themes.gohugo.io/). * The `indexes` type is removed from template lookup. It's not in the documentation, and is a legacy term inherited from very old Hugo versions. +* If you have sub-dirs in your shiny new bundles (e.g. `my-bundle/images`) and use the `*Prefix*` methods to find them, we have made an unintended change that affects you. See [this issue](https://github.com/gohugoio/hugo/issues/4295). ## Enhancements diff --git a/docs/content/news/0.34-relnotes-ready.md b/docs/content/news/0.34-relnotes-ready.md index 8a76dab29..3bd05f46e 100644 --- a/docs/content/news/0.34-relnotes-ready.md +++ b/docs/content/news/0.34-relnotes-ready.md @@ -1,14 +1,16 @@ --- date: 2018-01-22 -title: "0.34" -description: "0.34" -slug: "0.34" +title: "Hugo 0.34: Pattern matching to filter images and other resources" +description: "Hugo 0.34 adds full glob with super-asterisk support, for example `*.jpg`." +slug: "0.34-relnotes" categories: ["Releases"] +images: +- images/blog/hugo-34-poster.png --- -Hugo `0.33` is a small release. It contains a few smaller bug-fixes, but more important is an overhaul of the API used to find your images and other resources in your page bundles. +Hugo `0.34` is a small release. It contains a few smaller bug-fixes, but more important is an overhaul of the API used to find images and other resources in your page bundles. We have added two simple methods on the `Resources` object: @@ -35,7 +37,7 @@ Hugo now has: ## Notes * `Resources.GetByPrefix` and `Resources.ByPrefix` are depracated. They still work, but will eventually be removed. Use `Resources.Match` (many) and `Resources.GetMatch` (one). -* When filtering bundles pages in sub-folders, you need to include the sub-folder when matching. This was a bug introduced in `0.32` and gets it in line with images and other resources. +* When filtering bundles pages in sub-folders, you need to include the sub-folder when matching. This was a bug introduced in `0.33` and gets it in line with images and other resources. ## Enhancements diff --git a/docs/content/templates/homepage.md b/docs/content/templates/homepage.md index 6c290763a..833664866 100644 --- a/docs/content/templates/homepage.md +++ b/docs/content/templates/homepage.md @@ -28,12 +28,7 @@ The homepage template is the *only* required template for building a site and th ## Homepage Template Lookup Order -The [lookup order][lookup] for the homepage template is as follows: - -1. `/layouts/index.html` -2. `/layouts/_default/list.html` -3. `/themes/<THEME>/layouts/index.html` -4. `/themes/<THEME>/layouts/_default/list.html` +See [Template Lookup](/templates/lookup-order/). ## Add Content and Front Matter to the Homepage diff --git a/docs/content/templates/lists.md b/docs/content/templates/lists.md index dc7576ef8..7609339f0 100644 --- a/docs/content/templates/lists.md +++ b/docs/content/templates/lists.md @@ -31,6 +31,8 @@ Hugo uses the term *list* in its truest sense; i.e. a sequential arrangement of * [Section list pages][sectiontemps] * [RSS][rss] +For template lookup order, see [Template Lookup](/templates/lookup-order/). + The idea of a list page comes from the [hierarchical mental model of the web][mentalmodel] and is best demonstrated visually: ![Image demonstrating a hierarchical website sitemap.](/images/site-hierarchy.svg) diff --git a/docs/content/templates/lookup-order.md b/docs/content/templates/lookup-order.md index b3740696d..fd03d5977 100644 --- a/docs/content/templates/lookup-order.md +++ b/docs/content/templates/lookup-order.md @@ -1,13 +1,13 @@ --- title: Hugo's Lookup Order linktitle: Template Lookup Order -description: The lookup order is a prioritized list used by Hugo as it traverses your files looking for the appropriate corresponding file to render your content. +description: Hugo searches for the layout to use for a given page in a well defined order, starting from the most specific. godocref: date: 2017-02-01 publishdate: 2017-02-01 lastmod: 2017-05-25 categories: [templates,fundamentals] -keywords: [lookup] +keywords: [templates] menu: docs: parent: "templates" @@ -20,172 +20,73 @@ aliases: [/templates/lookup/] toc: true --- -Before creating your templates, it's important to know how Hugo looks for files within your project's [directory structure][]. +## Hugo Layouts Lookup Rules -Hugo uses a prioritized list called the **lookup order** as it traverses your `layouts` folder in your Hugo project *looking* for the appropriate template to render your content. +Hugo takes the parameters listed below into consideration when choosing a layout for a given page. They are listed in a priority order. This should feel natural, but look at the table below for concrete examples of the different parameter variations. -The template lookup order is an inverted cascade: if template A isn’t present or specified, Hugo will look to template B. If template B isn't present or specified, Hugo will look for template C...and so on until it reaches the `_default/` directory for your project or theme. In many ways, the lookup order is similar to the programming concept of a [switch statement without fallthrough][switch]. -The power of the lookup order is that it enables you to craft specific layouts and keep your templating [DRY][]. +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). -{{% note %}} -Most Hugo websites will only need the default template files at the end of the lookup order (i.e. `_default/*.html`). -{{% /note %}} - -## Lookup Orders +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. -The respective lookup order for each of Hugo's templates has been defined throughout the Hugo docs: +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 we will `index.amp.html` will be chosen before `index.fr.html`. -* [Homepage Template][home] -* [Base Templates][base] -* [Section Page Templates][sectionlookup] -* [Taxonomy List Templates][taxonomylookup] -* [Taxonomy Terms Templates][termslookup] -* [Single Page Templates][singlelookup] -* [RSS Templates][rsslookup] -* [Shortcode Templates][sclookup] +Layout +: Can be set in page front matter. -## Template Lookup Examples +Type +: Is value of `type` if set in front matter, else it is the name of the root section (e.g. "blog"). If will always have a value, so if not set, the value is "page". -The lookup order is best illustrated through examples. The following shows you the process Hugo uses for finding the appropriate template to render your [single page templates][], but the concept holds true for all templates in Hugo. +Section +: Is relevant for `section`, `taxonomy` and `taxonomyTerm` types. -1. The project is using the theme `mytheme` (specified in the project's [configuration][config]). -2. The layouts and content directories for the project are as follows: - -``` -. -├── content -│ ├── events -│ │ ├── _index.md -│ │ └── my-first-event.md -│ └── posts -│ ├── my-first-post.md -│ └── my-second-post.md -├── layouts -│ ├── _default -│ │ └── single.html -│ ├── posts -│ │ └── single.html -│ └── reviews -│ └── reviewarticle.html -└── themes - └── mytheme - └── layouts - ├── _default - │ ├── list.html - │ └── single.html - └── posts - ├── list.html - └── single.html +{{% note %}} +**Tip:** The examples below looks long and complex. That is the flexibility talking. Most Hugo sites contain just a handful of templates: + +```bash +├── _default +│ ├── baseof.html +│ ├── list.html +│ └── single.html +└── index.html ``` - - -Now we can look at the front matter for the three content (i.e.`.md`) files. - -{{% note %}} -Only three of the four markdown files in the above project are subject to the *single* page lookup order. `_index.md` is a specific `kind` in Hugo. Whereas `my-first-post.md`, `my-second-post.md`, and `my-first-event.md` are all of kind `page`, all `_index.md` files in a Hugo project are used to add content and front matter to [list pages](/templates/lists/). In this example, `events/_index.md` will render according to its [section template](/templates/section-templates/) and respective lookup order. {{% /note %}} -### Example: `my-first-post.md` -{{< code file="content/posts/my-first-post.md" copy="false" >}} ---- -title: My First Post -date: 2017-02-19 -description: This is my first post. ---- -{{< /code >}} +## Hugo Layouts Lookup Rules With Theme -When building your site, Hugo will go through the lookup order until it finds what it needs for `my-first-post.md`: +In Hugo, layouts can live in either the project's or theme's layout folder, and the most specific layout will be chosen. Hugo will interleave the lookups: -1. ~~`/layouts/UNSPECIFIED/UNSPECIFIED.html`~~ -2. ~~`/layouts/posts/UNSPECIFIED.html`~~ -3. ~~`/layouts/UNSPECIFIED/single.html`~~ -4. <span class="yes">`/layouts/posts/single.html`</span> - <br><span class="break">BREAK</span> -5. <span class="na">`/layouts/_default/single.html`</span> -6. <span class="na">`/themes/<THEME>/layouts/UNSPECIFIED/UNSPECIFIED.html`</span> -7. <span class="na">`/themes/<THEME>/layouts/posts/UNSPECIFIED.html`</span> -8. <span class="na">`/themes/<THEME>/layouts/UNSPECIFIED/single.html`</span> -9. <span class="na">`/themes/<THEME>/layouts/posts/single.html`</span> -10. <span class="na">`/themes/<THEME>/layouts/_default/single.html`</span> -Notice the term `UNSPECIFIED` rather than `UNDEFINED`. If you don't tell Hugo the specific type and layout, it makes assumptions based on sane defaults. `my-first-post.md` does not specify a content `type` in its front matter. Therefore, Hugo assumes the content `type` and `section` (i.e. `posts`, which is defined by file location) are one in the same. ([Read more on sections][sections].) +1. layouts/page/index.html +2. demoTheme/layouts/page/index.html +3. layouts/... -`my-first-post.md` also does not specify a `layout` in its front matter. Therefore, Hugo assumes that `my-first-post.md`, which is of type `page` and a *single* piece of content, should default to the next occurrence of a `single.html` template in the lookup (#4). +This way it is possible to override specific templates from the theme. -### Example: `my-second-post.md` +## Examples: Layout Lookup for Regular Pages -{{< code file="content/posts/my-second-post.md" copy="false" >}} ---- -title: My Second Post -date: 2017-02-21 -description: This is my second post. -type: review -layout: reviewarticle ---- -{{< /code >}} +{{< datatable-filtered "output" "layouts" "Kind == page" "Example" "OutputFormat" "Suffix" "Template Lookup Order" >}} -Here is the way Hugo traverses the single-page lookup order for `my-second-post.md`: +## Examples: Layout Lookup for Home Page -1. <span class="yes">`/layouts/review/reviewarticle.html`</span> - <br><span class="break">BREAK</span> -2. <span class="na">`/layouts/posts/reviewarticle.html`</span> -3. <span class="na">`/layouts/review/single.html`</span> -4. <span class="na">`/layouts/posts/single.html`</span> -5. <span class="na">`/layouts/_default/single.html`</span> -6. <span class="na">`/themes/<THEME>/layouts/review/reviewarticle.html`</span> -7. <span class="na">`/themes/<THEME>/layouts/posts/reviewarticle.html`</span> -8. <span class="na">`/themes/<THEME>/layouts/review/single.html`</span> -9. <span class="na">`/themes/<THEME>/layouts/posts/single.html`</span> -10. <span class="na">`/themes/<THEME>/layouts/_default/single.html`</span> +{{< datatable-filtered "output" "layouts" "Kind == home" "Example" "OutputFormat" "Suffix" "Template Lookup Order" >}} -The front matter in `my-second-post.md` specifies the content `type` (i.e. `review`) as well as the `layout` (i.e. `reviewarticle`). Hugo finds the layout it needs at the top level of the lookup (#1) and does not continue to search through the other templates. +## Examples: Layout Lookup for Section Pages -{{% note "Type and not Types" %}} -Notice that the directory for the template for `my-second-post.md` is `review` and not `reviews`. This is because *type is always singular when defined in front matter*. -{{% /note%}} +{{< datatable-filtered "output" "layouts" "Kind == section" "Example" "OutputFormat" "Suffix" "Template Lookup Order" >}} -### Example: `my-first-event.md` +## Examples: Layout Lookup for Taxonomy List Pages -{{< code file="content/events/my-first-event.md" copy="false" >}} ---- -title: My First -date: 2017-02-21 -description: This is an upcoming event.. ---- -{{< /code >}} +{{< datatable-filtered "output" "layouts" "Kind == taxonomy" "Example" "OutputFormat" "Suffix" "Template Lookup Order" >}} -Here is the way Hugo traverses the single-page lookup order for `my-first-event.md`: +## Examples: Layout Lookup for Taxonomy Terms Pages + +{{< datatable-filtered "output" "layouts" "Kind == taxonomyTerm" "Example" "OutputFormat" "Suffix" "Template Lookup Order" >}} -1. ~~`/layouts/UNSPECIFIED/UNSPECIFIED.html`~~ -2. ~~`/layouts/events/UNSPECIFIED.html`~~ -3. ~~`/layouts/UNSPECIFIED/single.html`~~ -4. ~~`/layouts/events/single.html`~~ -5. <span class="yes">`/layouts/_default/single.html`</span> -<br><span class="break">BREAK</span> -6. <span class="na">`/themes/<THEME>/layouts/UNSPECIFIED/UNSPECIFIED.html`</span> -7. <span class="na">`/themes/<THEME>/layouts/events/UNSPECIFIED.html`</span> -8. <span class="na">`/themes/<THEME>/layouts/UNSPECIFIED/single.html`</span> -9. <span class="na">`/themes/<THEME>/layouts/events/single.html`</span> -10. <span class="na">`/themes/<THEME>/layouts/_default/single.html`</span> -{{% note %}} -`my-first-event.md` is significant because it demonstrates the role of the lookup order in Hugo themes. Both the root project directory *and* the `mytheme` themes directory have a file at `_default/single.html`. Understanding this order allows you to [customize Hugo themes](/themes/customizing/) by creating template files with identical names in your project directory that step in front of theme template files in the lookup. This allows you to customize the look and feel of your website while maintaining compatibility with the theme's upstream. -{{% /note %}} -[base]: /templates/base/#base-template-lookup-order -[config]: /getting-started/configuration/ -[directory structure]: /getting-started/directory-structure/ -[DRY]: https://en.wikipedia.org/wiki/Don%27t_repeat_yourself -[home]: /templates/homepage/#homepage-template-lookup-order -[rsslookup]: /templates/rss/#rss-template-lookup-order -[sclookup]: /templates/shortcode-templates/#shortcode-template-lookup-order -[sections]: /content-management/sections/ -[sectionlookup]: /templates/section-templates/#section-template-lookup-order -[single page templates]: /templates/single-page-templates/ -[singlelookup]: /templates/single-page-templates/#single-page-template-lookup-order -[switch]: https://en.wikipedia.org/wiki/Switch_statement#Fallthrough -[taxonomylookup]: /templates/taxonomy-templates/#taxonomy-list-template-lookup-order -[termslookup]: /templates/taxonomy-templates/#taxonomy-terms-template-lookup-order diff --git a/docs/content/templates/menu-templates.md b/docs/content/templates/menu-templates.md index 446710681..9eba3dc1b 100644 --- a/docs/content/templates/menu-templates.md +++ b/docs/content/templates/menu-templates.md @@ -9,6 +9,7 @@ categories: [templates] keywords: [lists,sections,menus] menu: docs: + title: "how to use menus in templates" parent: "templates" weight: 130 weight: 130 @@ -27,40 +28,35 @@ The following is an example: {{< code file="layouts/partials/sidebar.html" download="sidebar.html" >}} <!-- sidebar start --> <aside> - <div id="sidebar" class="nav-collapse"> - <!-- sidebar menu start--> - <ul class="sidebar-menu"> - {{ $currentPage := . }} - {{ range .Site.Menus.main }} - {{ if .HasChildren }} - - <li class="sub-menu{{if $currentPage.HasMenuCurrent "main" . }} active{{end}}"> - <a href="javascript:;" class=""> - {{ .Pre }} - <span>{{ .Name }}</span> - <span class="menu-arrow arrow_carrot-right"></span> - </a> - <ul class="sub"> - {{ range .Children }} - <li{{if $currentPage.IsMenuCurrent "main" . }} class="active"{{end}}><a href="{{.URL}}"> {{ .Name }} </a> </li> - {{ end }} - </ul> - {{else}} - <li> - <a href="{{.URL}}"> - {{ .Pre }} - <span>{{ .Name }}</span> - </a> - {{end}} - </li> - {{end}} - <li> <a href="https://github.com/gohugoio/hugo/issues" target="blank">Questions and Issues</a> </li> - <li> <a href="#" target="blank">Edit this Page</a> </li> - </ul> - <!-- sidebar menu end--> - </div> + <ul> + {{ $currentPage := . }} + {{ range .Site.Menus.main }} + {{ if .HasChildren }} + <li class="{{ if $currentPage.HasMenuCurrent "main" . }}active{{ end }}"> + <a href="#"> + {{ .Pre }} + <span>{{ .Name }}</span> + </a> + <ul class="sub-menu"> + {{ range .Children }} + <li class="{{ if $currentPage.IsMenuCurrent "main" . }}active{{ end }}"> + <a href="{{ .URL }}">{{ .Name }}</a> + {{ end }} + </ul> + {{else}} + <li> + <a href="{{.URL}}"> + {{ .Pre }} + <span>{{ .Name }}</span> + </a> + {{end}} + {{end}} + <li> + <a href="#" target="blank">Hardcoded Link 1</a> + <li> + <a href="#" target="blank">Hardcoded Link 2</a> + </ul> </aside> -<!--sidebar end--> {{< /code >}} {{% note "`absLangURL` and `relLangURL`" %}} @@ -83,18 +79,22 @@ This will create a menu with all the sections as menu items and all the sections <nav class="sidebar-nav"> {{ $currentPage := . }} {{ range .Site.Menus.main }} - <a class="sidebar-nav-item{{if or ($currentPage.IsMenuCurrent "main" .) ($currentPage.HasMenuCurrent "main" .) }} active{{end}}" href="{{.URL}}">{{ .Name }}</a> + <a class="sidebar-nav-item{{if or ($currentPage.IsMenuCurrent "main" .) ($currentPage.HasMenuCurrent "main" .) }} active{{end}}" href="{{ .URL }}" title="{{ .Title }}">{{ .Name }}</a> {{ end }} </nav> ``` In the above, the menu item is marked as active if on the current section's list page or on a page in that section. -The above is all that's needed. But if you want custom menu items, e.g. changing weight or name, you can define them manually in the site config, i.e. `config.toml`: + +## Site Config menus + +The above is all that's needed. But if you want custom menu items, e.g. changing weight, name, or link title attribute, you can define them manually in the site config, i.e. `config.toml`: ``` [[menu.main]] name = "This is the blog section" + title = "blog section" weight = -110 identifier = "blog" url = "/blog/" @@ -103,3 +103,55 @@ The above is all that's needed. But if you want custom menu items, e.g. changing {{% note %}} The `identifier` *must* match the section name. {{% /note %}} + +## Menu Entries from the Page's front matter + +It's also possible to create menu entries from the page (i.e. the `.md`-file). + +Here is a `yaml` example: + +``` +--- +title: Menu Templates +linktitle: Menu Templates +menu: + docs: + title: "how to use menus in templates" + parent: "templates" + weight: 130 +--- +... +``` + +{{% note %}} +You can define more than one menu. It also doesn't have to be a complex value, +`menu` can also be a string, an array of strings, or an array of complex values +like in the example above. +{{% /note %}} + +### Using .Page in Menus + +If you use the front matter method of defining menu entries, you'll get access to the `.Page` variable. +This allows to use every variable that's reachable from the [page variable](/variables/page/). + +This variable is only set when the menu entry is defined in the page's front matter. +Menu entries from the site config don't know anything about `.Page`. + +That's why you have to use the go template's `with` keyword or something similar in your templating language. + +Here's an example: + +``` +<nav class="sidebar-nav"> + {{ range .Site.Menus.main }} + <a href="{{ .URL }}" title="{{ .Title }}"> + {{- .Name -}} + {{- with .Page -}} + <span class="date"> + {{- dateFormat " (2006-01-02)" .Date -}} + </span> + {{- end -}} + </a> + {{ end }} +</nav> +``` diff --git a/docs/content/templates/rss.md b/docs/content/templates/rss.md index e7d64f3f5..f68a2e104 100644 --- a/docs/content/templates/rss.md +++ b/docs/content/templates/rss.md @@ -5,7 +5,7 @@ description: Hugo ships with its own RSS 2.0 template that requires almost no co date: 2017-02-01 publishdate: 2017-02-01 lastmod: 2017-02-01 -keywords: [rss, xml] +keywords: [rss, xml, templates] categories: [templates] menu: docs: @@ -20,12 +20,7 @@ toc: true ## RSS Template Lookup Order -You can use a single RSS template to generate all of your RSS feeds or create a specific template for each individual feed. - -1. `/layouts/section/<section>.rss.xml` -2. `/layouts/_default/rss.xml` -3. `/themes/<theme>/layouts/section/<section>.rss.xml` -4. `/themes/<theme>/layouts/_default/rss.xml` +See [Template Lookup](/templates/lookup-order/). {{% note "Hugo Ships with an RSS Template" %}} Hugo ships with its own [RSS 2.0 template](#the-embedded-rss-xml). The embedded template will be sufficient for most use cases. diff --git a/docs/content/templates/section-templates.md b/docs/content/templates/section-templates.md index 1859d3df8..60e486ecd 100644 --- a/docs/content/templates/section-templates.md +++ b/docs/content/templates/section-templates.md @@ -6,7 +6,7 @@ date: 2017-02-01 publishdate: 2017-02-01 lastmod: 2017-02-01 categories: [templates] -keywords: [lists,sections] +keywords: [lists,sections,templates] menu: docs: parent: "templates" @@ -24,18 +24,7 @@ To effectively leverage section page templates, you should first understand Hugo ## Section Template Lookup Order -The [lookup order][lookup] for section templates is as follows: - -1. `/layouts/section/<SECTION>.html` -2. `/layouts/<SECTION>/list.html` -3. `/layouts/_default/section.html` -4. `/layouts/_default/list.html` -5. `/themes/<THEME>/layouts/section/<SECTION>.html` -6. `/themes/<THEME>/layouts/<SECTION>/list.html` -7. `/themes/<THEME>/layouts/_default/section.html` -8. `/themes/<THEME>/layouts/_default/list.html` - -{{< youtube jrMClsB3VsY >}} +See [Template Lookup](/templates/lookup-order/). ## `.Site.GetPage` with Sections diff --git a/docs/content/templates/shortcode-templates.md b/docs/content/templates/shortcode-templates.md index 9770eb392..de1594281 100644 --- a/docs/content/templates/shortcode-templates.md +++ b/docs/content/templates/shortcode-templates.md @@ -6,7 +6,7 @@ date: 2017-02-01 publishdate: 2017-02-01 lastmod: 2017-02-01 categories: [templates] -keywords: [shortcodes] +keywords: [shortcodes,templates] menu: docs: parent: "templates" @@ -137,6 +137,10 @@ You can also use the variable `.Page` to access all the normal [page variables][ A shortcodes can also be nested. In a nested shortcode, you can access the parent shortcode context with [`.Parent` variable][shortcodesvars]. This can be very useful for inheritance of common shortcode parameters from the root. +### Checking for Existence + +You can check if a specific shortcode is used on a page by calling `.HasShortcode` in that page template, providing the name of the shortcode. This is sometimes useful when you want to include specific scripts or styles in the header that are only used by that shortcode. + ## Custom Shortcode Examples The following are examples of the different types of shortcodes you can create via shortcode template files in `/layouts/shortcodes`. diff --git a/docs/content/templates/single-page-templates.md b/docs/content/templates/single-page-templates.md index 41320cf63..79e1312b2 100644 --- a/docs/content/templates/single-page-templates.md +++ b/docs/content/templates/single-page-templates.md @@ -6,7 +6,7 @@ date: 2017-02-01 publishdate: 2017-02-01 lastmod: 2017-04-06 categories: [templates] -keywords: [page] +keywords: [page,templates] menu: docs: parent: "templates" @@ -20,22 +20,7 @@ toc: true ## Single Page Template Lookup Order -You can specify a [content's `type`][content type] and `layout` in a single content file's [front matter][]. However, you cannot specify `section` because this is determined based on file location (see [content section][section]). - -Hugo assumes your content section and content type are the same unless you tell Hugo otherwise by providing a `type` directly in the front matter of a content file. This is why #1 and #3 come before #2 and #4, respectively, in the following lookup order. Values in angle brackets (`<>`) are variable. - -1. `/layouts/<TYPE>/<LAYOUT>.html` -2. `/layouts/<SECTION>/<LAYOUT>.html` -3. `/layouts/<TYPE>/single.html` -4. `/layouts/<SECTION>/single.html` -5. `/layouts/_default/single.html` -6. `/themes/<THEME>/layouts/<TYPE>/<LAYOUT>.html` -7. `/themes/<THEME>/layouts/<SECTION>/<LAYOUT>.html` -8. `/themes/<THEME>/layouts/<TYPE>/single.html` -9. `/themes/<THEME>/layouts/<SECTION>/single.html` -10. `/themes/<THEME>/layouts/_default/single.html` - -{{< youtube ZYQ5k0RQzmo >}} +See [Template Lookup](/templates/lookup-order/). ## Example Single Page Templates diff --git a/docs/content/templates/sitemap-template.md b/docs/content/templates/sitemap-template.md index 309d85e75..98a4c2b1d 100644 --- a/docs/content/templates/sitemap-template.md +++ b/docs/content/templates/sitemap-template.md @@ -6,7 +6,7 @@ date: 2017-02-01 publishdate: 2017-02-01 lastmod: 2017-02-01 categories: [templates] -keywords: [sitemap, xml] +keywords: [sitemap, xml, templates] menu: docs: parent: "templates" diff --git a/docs/content/templates/taxonomy-templates.md b/docs/content/templates/taxonomy-templates.md index 9e1f4626f..f3b349a39 100644 --- a/docs/content/templates/taxonomy-templates.md +++ b/docs/content/templates/taxonomy-templates.md @@ -6,7 +6,7 @@ date: 2017-02-01 publishdate: 2017-02-01 lastmod: 2017-02-01 categories: [templates] -keywords: [taxonomies,metadata,front matter,terms] +keywords: [taxonomies,metadata,front matter,terms,templates] menu: docs: parent: "templates" @@ -35,32 +35,13 @@ Taxonomy list page templates are lists and therefore have all the variables and ### Taxonomy List Template Lookup Order -A taxonomy will be rendered at /`PLURAL`/`TERM`/ (e.g., http://spf13.com/topics/golang/) according to the following lookup order: - -1. `/layouts/taxonomy/<SINGULAR>.html` -2. `/layouts/_default/taxonomy.html` -3. `/layouts/_default/list.html` -4. `/themes/<THEME>/layouts/taxonomy/<SINGULAR>.html` -5. `/themes/<THEME>/layouts/_default/taxonomy.html` -6. `/themes/<THEME>/layouts/_default/list.html` +See [Template Lookup](/templates/lookup-order/). ## Taxonomy Terms Template ### Taxonomy Terms Templates Lookup Order -A taxonomy terms page will be rendered at `example.com/<PLURALTAXONOMYNAME>`/ (e.g., http://spf13.com/topics/) according to the following lookup order: - -1. `/layouts/taxonomy/<SINGULAR>.terms.html` -2. `/layouts/_default/terms.html` -3. `/themes/<THEME>/layouts/taxonomy/<SINGULAR>.terms.html` -4. `/themes/<THEME>/layouts/_default/terms.html` - -{{% warning "The Taxonomy Terms Template has a Unique Lookup Order" %}} -If Hugo does not find a terms template in `layout/` or `/themes/<THEME>/layouts/`, Hugo will *not* render a taxonomy terms page. -{{% /warning %}} - -<!-- Begin /taxonomies/methods/ --> -Hugo makes a set of values and methods available on the various Taxonomy structures. +See [Template Lookup](/templates/lookup-order/). ### Taxonomy Methods diff --git a/docs/content/tools/editors.md b/docs/content/tools/editors.md index 29fbef6b3..419a2a04c 100644 --- a/docs/content/tools/editors.md +++ b/docs/content/tools/editors.md @@ -30,7 +30,7 @@ The Hugo community uses a wide range of preferred tools and has developed plug-i ## Emacs -* [hugo.el](https://github.com/yewton/hugo.el). Some helper functions for creating a Website with Hugo. Note that Hugo also supports [Org-mode][formats]. +* [emacs-easy-hugo](https://github.com/masasam/emacs-easy-hugo). Emacs major mode for managing hugo blogs. Note that Hugo also supports [Org-mode][formats]. * [ox-hugo.el](https://ox-hugo.scripter.co). Native Org-mode exporter that exports to Blackfriday Markdown with Hugo front-matter. `ox-hugo` supports two common Org blogging flows --- exporting multiple Org sub-trees in a single file to multiple Hugo posts, and exporting a single Org file to a single Hugo post. It also leverages the Org tag and property inheritance features. See [*Why ox-hugo?*](https://ox-hugo.scripter.co/doc/why-ox-hugo/) for more. ## Vim diff --git a/docs/content/tools/migrations.md b/docs/content/tools/migrations.md index 2e546ca9f..ef4f169d3 100644 --- a/docs/content/tools/migrations.md +++ b/docs/content/tools/migrations.md @@ -65,6 +65,7 @@ Alternatively, you can use the new [Jekyll import command](/commands/hugo_import ## Blogger - [blogimport](https://github.com/natefinch/blogimport) - A tool to import from Blogger posts to Hugo. +- [blogger-to-hugo](https://bitbucket.org/petraszd/blogger-to-hugo) - Another tool to import Blogger posts to Hugo. It also downloads embedded images so they will be stored locally. ## Contentful diff --git a/docs/content/tools/search.md b/docs/content/tools/search.md index a7475b7c8..d39665130 100644 --- a/docs/content/tools/search.md +++ b/docs/content/tools/search.md @@ -23,7 +23,8 @@ A static website with a dynamic search function? Yes. As alternatives to embedda * [Hugoidx](https://github.com/blevesearch/hugoidx) is an experimental application to create a search index. It's built on top of [Bleve](http://www.blevesearch.com/). * [GitHub Gist for Hugo Workflow](https://gist.github.com/sebz/efddfc8fdcb6b480f567). This gist contains a simple workflow to create a search index for your static website. It uses a simple Grunt script to index all your content files and [lunr.js](http://lunrjs.com/) to serve the search results. * [hugo-lunr](https://www.npmjs.com/package/hugo-lunr). A simple way to add site search to your static Hugo site using [lunr.js](http://lunrjs.com/). Hugo-lunr will create an index file of any html and markdown documents in your Hugo project. +* [hugo-lunr-zh](https://www.npmjs.com/package/hugo-lunr-zh). A bit like Hugo-lunr, but Hugo-lunr-zh can help you seperate the Chinese keywords. ## Commercial Search Services -* [Algolia](https://www.algolia.com/)'s Search API makes it easy to deliver a great search experience in your apps and websites. Algolia Search provides hosted full-text, numerical, faceted, and geolocalized search.
\ No newline at end of file +* [Algolia](https://www.algolia.com/)'s Search API makes it easy to deliver a great search experience in your apps and websites. Algolia Search provides hosted full-text, numerical, faceted, and geolocalized search. diff --git a/docs/content/variables/menus.md b/docs/content/variables/menus.md index 3c71079ae..4216d9763 100644 --- a/docs/content/variables/menus.md +++ b/docs/content/variables/menus.md @@ -10,6 +10,7 @@ keywords: [menus] draft: false menu: docs: + title: "variables defined by a menu entry" parent: "variables" weight: 50 weight: 50 @@ -26,6 +27,22 @@ The [menu template][] has the following properties: .Name : string +.Title +: string + +This is a link title, meant to be used in `title`-Attributes of the menu's `<a>`-tags. +By default it returns `.Page.LinkTitle`, as long as the menu entry was created +through the page's front matter and not through the site config. +Setting it explicitly in the site config or the page's front matter overrides this behaviour. + +.Page +: [Page Object](/variables/page/) + +The `.Page` variable holds a reference to the page. +It's only set when the menu entry is created from the page's front matter, +not when it's created from the site config. + + .Menu : string @@ -47,4 +64,4 @@ The [menu template][] has the following properties: .Children : Menu -[menu template]: /templates/menu-templates/
\ No newline at end of file +[menu template]: /templates/menu-templates/ diff --git a/docs/content/variables/page.md b/docs/content/variables/page.md index eb4699a4e..f3a50d21d 100644 --- a/docs/content/variables/page.md +++ b/docs/content/variables/page.md @@ -10,6 +10,7 @@ keywords: [pages] draft: false menu: docs: + title: "variables defined by a page" parent: "variables" weight: 20 weight: 20 diff --git a/docs/data/docs.json b/docs/data/docs.json index 6bd8d6d9a..7b9a85d31 100644 --- a/docs/data/docs.json +++ b/docs/data/docs.json @@ -220,131 +220,457 @@ ], "layouts": [ { - "Example": "AMP home, with theme \"demoTheme\".", + "Example": "Single page in \"posts\" section", + "Kind": "page", + "OutputFormat": "HTML", + "Suffix": "html", + "Template Lookup Order": [ + "layouts/posts/single.html.html", + "layouts/posts/single.html", + "layouts/_default/single.html.html", + "layouts/_default/single.html" + ] + }, + { + "Example": "Single page in \"posts\" section with layout set", + "Kind": "page", + "OutputFormat": "HTML", + "Suffix": "html", + "Template Lookup Order": [ + "layouts/posts/demolayout.html.html", + "layouts/posts/single.html.html", + "layouts/posts/demolayout.html", + "layouts/posts/single.html", + "layouts/_default/demolayout.html.html", + "layouts/_default/single.html.html", + "layouts/_default/demolayout.html", + "layouts/_default/single.html" + ] + }, + { + "Example": "Single page in \"posts\" section with theme", + "Kind": "page", + "OutputFormat": "HTML", + "Suffix": "html", + "Template Lookup Order": [ + "layouts/posts/single.html.html", + "demoTheme/layouts/posts/single.html.html", + "layouts/posts/single.html", + "demoTheme/layouts/posts/single.html", + "layouts/_default/single.html.html", + "demoTheme/layouts/_default/single.html.html", + "layouts/_default/single.html", + "demoTheme/layouts/_default/single.html" + ] + }, + { + "Example": "AMP single page", + "Kind": "page", "OutputFormat": "AMP", "Suffix": "html", "Template Lookup Order": [ - "layouts/index.amp.html", + "layouts/posts/single.amp.html", + "layouts/posts/single.html", + "layouts/_default/single.amp.html", + "layouts/_default/single.html" + ] + }, + { + "Example": "AMP single page, French language", + "Kind": "page", + "OutputFormat": "AMP", + "Suffix": "html", + "Template Lookup Order": [ + "layouts/posts/single.fr.amp.html", + "layouts/posts/single.amp.html", + "layouts/posts/single.fr.html", + "layouts/posts/single.html", + "layouts/_default/single.fr.amp.html", + "layouts/_default/single.amp.html", + "layouts/_default/single.fr.html", + "layouts/_default/single.html" + ] + }, + { + "Example": "Home page", + "Kind": "home", + "OutputFormat": "HTML", + "Suffix": "html", + "Template Lookup Order": [ + "layouts/page/index.html.html", + "layouts/page/home.html.html", + "layouts/page/list.html.html", + "layouts/page/index.html", + "layouts/page/home.html", + "layouts/page/list.html", + "layouts/index.html.html", + "layouts/home.html.html", + "layouts/list.html.html", + "layouts/index.html", + "layouts/home.html", + "layouts/list.html", + "layouts/_default/index.html.html", + "layouts/_default/home.html.html", + "layouts/_default/list.html.html", + "layouts/_default/index.html", + "layouts/_default/home.html", + "layouts/_default/list.html" + ] + }, + { + "Example": "Home page with type set", + "Kind": "home", + "OutputFormat": "HTML", + "Suffix": "html", + "Template Lookup Order": [ + "layouts/demotype/index.html.html", + "layouts/demotype/home.html.html", + "layouts/demotype/list.html.html", + "layouts/demotype/index.html", + "layouts/demotype/home.html", + "layouts/demotype/list.html", + "layouts/index.html.html", + "layouts/home.html.html", + "layouts/list.html.html", + "layouts/index.html", + "layouts/home.html", + "layouts/list.html", + "layouts/_default/index.html.html", + "layouts/_default/home.html.html", + "layouts/_default/list.html.html", + "layouts/_default/index.html", + "layouts/_default/home.html", + "layouts/_default/list.html" + ] + }, + { + "Example": "Home page with layout set", + "Kind": "home", + "OutputFormat": "HTML", + "Suffix": "html", + "Template Lookup Order": [ + "layouts/page/demolayout.html.html", + "layouts/page/index.html.html", + "layouts/page/home.html.html", + "layouts/page/list.html.html", + "layouts/page/demolayout.html", + "layouts/page/index.html", + "layouts/page/home.html", + "layouts/page/list.html", + "layouts/demolayout.html.html", + "layouts/index.html.html", + "layouts/home.html.html", + "layouts/list.html.html", + "layouts/demolayout.html", + "layouts/index.html", + "layouts/home.html", + "layouts/list.html", + "layouts/_default/demolayout.html.html", + "layouts/_default/index.html.html", + "layouts/_default/home.html.html", + "layouts/_default/list.html.html", + "layouts/_default/demolayout.html", + "layouts/_default/index.html", + "layouts/_default/home.html", + "layouts/_default/list.html" + ] + }, + { + "Example": "Home page with theme", + "Kind": "home", + "OutputFormat": "HTML", + "Suffix": "html", + "Template Lookup Order": [ + "layouts/page/index.html.html", + "demoTheme/layouts/page/index.html.html", + "layouts/page/home.html.html", + "demoTheme/layouts/page/home.html.html", + "layouts/page/list.html.html", + "demoTheme/layouts/page/list.html.html", + "layouts/page/index.html", + "demoTheme/layouts/page/index.html", + "layouts/page/home.html", + "demoTheme/layouts/page/home.html", + "layouts/page/list.html", + "demoTheme/layouts/page/list.html", + "layouts/index.html.html", + "demoTheme/layouts/index.html.html", + "layouts/home.html.html", + "demoTheme/layouts/home.html.html", + "layouts/list.html.html", + "demoTheme/layouts/list.html.html", "layouts/index.html", - "layouts/_default/list.amp.html", - "layouts/_default/list.html", - "demoTheme/layouts/index.amp.html", "demoTheme/layouts/index.html", - "demoTheme/layouts/_default/list.amp.html", + "layouts/home.html", + "demoTheme/layouts/home.html", + "layouts/list.html", + "demoTheme/layouts/list.html", + "layouts/_default/index.html.html", + "demoTheme/layouts/_default/index.html.html", + "layouts/_default/home.html.html", + "demoTheme/layouts/_default/home.html.html", + "layouts/_default/list.html.html", + "demoTheme/layouts/_default/list.html.html", + "layouts/_default/index.html", + "demoTheme/layouts/_default/index.html", + "layouts/_default/home.html", + "demoTheme/layouts/_default/home.html", + "layouts/_default/list.html", "demoTheme/layouts/_default/list.html" ] }, { - "Example": "AMP home, French language\".", + "Example": "AMP home, French language\"", + "Kind": "home", "OutputFormat": "AMP", "Suffix": "html", "Template Lookup Order": [ + "layouts/page/index.fr.amp.html", + "layouts/page/home.fr.amp.html", + "layouts/page/list.fr.amp.html", + "layouts/page/index.amp.html", + "layouts/page/home.amp.html", + "layouts/page/list.amp.html", + "layouts/page/index.fr.html", + "layouts/page/home.fr.html", + "layouts/page/list.fr.html", + "layouts/page/index.html", + "layouts/page/home.html", + "layouts/page/list.html", "layouts/index.fr.amp.html", + "layouts/home.fr.amp.html", + "layouts/list.fr.amp.html", "layouts/index.amp.html", + "layouts/home.amp.html", + "layouts/list.amp.html", "layouts/index.fr.html", + "layouts/home.fr.html", + "layouts/list.fr.html", "layouts/index.html", + "layouts/home.html", + "layouts/list.html", + "layouts/_default/index.fr.amp.html", + "layouts/_default/home.fr.amp.html", "layouts/_default/list.fr.amp.html", + "layouts/_default/index.amp.html", + "layouts/_default/home.amp.html", "layouts/_default/list.amp.html", + "layouts/_default/index.fr.html", + "layouts/_default/home.fr.html", "layouts/_default/list.fr.html", + "layouts/_default/index.html", + "layouts/_default/home.html", "layouts/_default/list.html" ] }, { - "Example": "RSS home, no theme.", - "OutputFormat": "RSS", - "Suffix": "xml", - "Template Lookup Order": [ - "layouts/rss.xml", - "layouts/_default/rss.xml", - "layouts/_internal/_default/rss.xml" - ] - }, - { - "Example": "JSON home, no theme.", + "Example": "JSON home", + "Kind": "home", "OutputFormat": "JSON", "Suffix": "json", "Template Lookup Order": [ + "layouts/page/index.json.json", + "layouts/page/home.json.json", + "layouts/page/list.json.json", + "layouts/page/index.json", + "layouts/page/home.json", + "layouts/page/list.json", "layouts/index.json.json", + "layouts/home.json.json", + "layouts/list.json.json", "layouts/index.json", + "layouts/home.json", + "layouts/list.json", + "layouts/_default/index.json.json", + "layouts/_default/home.json.json", "layouts/_default/list.json.json", + "layouts/_default/index.json", + "layouts/_default/home.json", "layouts/_default/list.json" ] }, { - "Example": "CSV regular, \"layout: demolayout\" in front matter.", - "OutputFormat": "CSV", - "Suffix": "csv", - "Template Lookup Order": [ - "layouts/_default/demolayout.csv.csv", - "layouts/_default/demolayout.csv" - ] - }, - { - "Example": "JSON regular, \"type: demotype\" in front matter.", - "OutputFormat": "JSON", - "Suffix": "json", + "Example": "RSS home", + "Kind": "home", + "OutputFormat": "RSS", + "Suffix": "xml", "Template Lookup Order": [ - "layouts/demotype/single.json.json", - "layouts/demotype/single.json", - "layouts/_default/single.json.json", - "layouts/_default/single.json" + "layouts/page/index.rss.xml", + "layouts/page/home.rss.xml", + "layouts/page/rss.xml", + "layouts/page/list.rss.xml", + "layouts/page/index.xml", + "layouts/page/home.xml", + "layouts/page/list.xml", + "layouts/index.rss.xml", + "layouts/home.rss.xml", + "layouts/rss.xml", + "layouts/list.rss.xml", + "layouts/index.xml", + "layouts/home.xml", + "layouts/list.xml", + "layouts/_default/index.rss.xml", + "layouts/_default/home.rss.xml", + "layouts/_default/rss.xml", + "layouts/_default/list.rss.xml", + "layouts/_default/index.xml", + "layouts/_default/home.xml", + "layouts/_default/list.xml", + "layouts/_internal/_default/rss.xml" ] }, { - "Example": "HTML regular.", + "Example": "Section list for \"posts\" section", + "Kind": "section", "OutputFormat": "HTML", "Suffix": "html", "Template Lookup Order": [ - "layouts/_default/single.html.html", - "layouts/_default/single.html" + "layouts/posts/posts.html.html", + "layouts/posts/section.html.html", + "layouts/posts/list.html.html", + "layouts/posts/posts.html", + "layouts/posts/section.html", + "layouts/posts/list.html", + "layouts/section/posts.html.html", + "layouts/section/section.html.html", + "layouts/section/list.html.html", + "layouts/section/posts.html", + "layouts/section/section.html", + "layouts/section/list.html", + "layouts/_default/posts.html.html", + "layouts/_default/section.html.html", + "layouts/_default/list.html.html", + "layouts/_default/posts.html", + "layouts/_default/section.html", + "layouts/_default/list.html" ] }, { - "Example": "AMP regular.", - "OutputFormat": "AMP", + "Example": "Section list for \"posts\" section with type set to \"blog\"", + "Kind": "section", + "OutputFormat": "HTML", "Suffix": "html", "Template Lookup Order": [ - "layouts/_default/single.amp.html", - "layouts/_default/single.html" + "layouts/blog/posts.html.html", + "layouts/blog/section.html.html", + "layouts/blog/list.html.html", + "layouts/blog/posts.html", + "layouts/blog/section.html", + "layouts/blog/list.html", + "layouts/posts/posts.html.html", + "layouts/posts/section.html.html", + "layouts/posts/list.html.html", + "layouts/posts/posts.html", + "layouts/posts/section.html", + "layouts/posts/list.html", + "layouts/section/posts.html.html", + "layouts/section/section.html.html", + "layouts/section/list.html.html", + "layouts/section/posts.html", + "layouts/section/section.html", + "layouts/section/list.html", + "layouts/_default/posts.html.html", + "layouts/_default/section.html.html", + "layouts/_default/list.html.html", + "layouts/_default/posts.html", + "layouts/_default/section.html", + "layouts/_default/list.html" ] }, { - "Example": "Calendar blog section.", - "OutputFormat": "Calendar", - "Suffix": "ics", + "Example": "Section list for \"posts\" section with layout set to \"demoLayout\"", + "Kind": "section", + "OutputFormat": "HTML", + "Suffix": "html", "Template Lookup Order": [ - "layouts/section/blog.calendar.ics", - "layouts/section/blog.ics", - "layouts/blog/list.calendar.ics", - "layouts/blog/list.ics", - "layouts/_default/section.calendar.ics", - "layouts/_default/section.ics", - "layouts/_default/list.calendar.ics", - "layouts/_default/list.ics" + "layouts/posts/demolayout.html.html", + "layouts/posts/posts.html.html", + "layouts/posts/section.html.html", + "layouts/posts/list.html.html", + "layouts/posts/demolayout.html", + "layouts/posts/posts.html", + "layouts/posts/section.html", + "layouts/posts/list.html", + "layouts/section/demolayout.html.html", + "layouts/section/posts.html.html", + "layouts/section/section.html.html", + "layouts/section/list.html.html", + "layouts/section/demolayout.html", + "layouts/section/posts.html", + "layouts/section/section.html", + "layouts/section/list.html", + "layouts/_default/demolayout.html.html", + "layouts/_default/posts.html.html", + "layouts/_default/section.html.html", + "layouts/_default/list.html.html", + "layouts/_default/demolayout.html", + "layouts/_default/posts.html", + "layouts/_default/section.html", + "layouts/_default/list.html" ] }, { - "Example": "Calendar taxonomy list.", - "OutputFormat": "Calendar", - "Suffix": "ics", + "Example": "Taxonomy list in categories", + "Kind": "taxonomy", + "OutputFormat": "HTML", + "Suffix": "html", "Template Lookup Order": [ - "layouts/taxonomy/tag.calendar.ics", - "layouts/taxonomy/tag.ics", - "layouts/_default/taxonomy.calendar.ics", - "layouts/_default/taxonomy.ics", - "layouts/_default/list.calendar.ics", - "layouts/_default/list.ics" + "layouts/categories/category.html.html", + "layouts/categories/taxonomy.html.html", + "layouts/categories/list.html.html", + "layouts/categories/category.html", + "layouts/categories/taxonomy.html", + "layouts/categories/list.html", + "layouts/taxonomy/category.html.html", + "layouts/taxonomy/taxonomy.html.html", + "layouts/taxonomy/list.html.html", + "layouts/taxonomy/category.html", + "layouts/taxonomy/taxonomy.html", + "layouts/taxonomy/list.html", + "layouts/category/category.html.html", + "layouts/category/taxonomy.html.html", + "layouts/category/list.html.html", + "layouts/category/category.html", + "layouts/category/taxonomy.html", + "layouts/category/list.html", + "layouts/_default/category.html.html", + "layouts/_default/taxonomy.html.html", + "layouts/_default/list.html.html", + "layouts/_default/category.html", + "layouts/_default/taxonomy.html", + "layouts/_default/list.html" ] }, { - "Example": "Calendar taxonomy term.", - "OutputFormat": "Calendar", - "Suffix": "ics", + "Example": "Taxonomy term in categories", + "Kind": "taxonomyTerm", + "OutputFormat": "HTML", + "Suffix": "html", "Template Lookup Order": [ - "layouts/taxonomy/tag.terms.calendar.ics", - "layouts/taxonomy/tag.terms.ics", - "layouts/_default/terms.calendar.ics", - "layouts/_default/terms.ics" + "layouts/categories/category.terms.html.html", + "layouts/categories/terms.html.html", + "layouts/categories/list.html.html", + "layouts/categories/category.terms.html", + "layouts/categories/terms.html", + "layouts/categories/list.html", + "layouts/taxonomy/category.terms.html.html", + "layouts/taxonomy/terms.html.html", + "layouts/taxonomy/list.html.html", + "layouts/taxonomy/category.terms.html", + "layouts/taxonomy/terms.html", + "layouts/taxonomy/list.html", + "layouts/category/category.terms.html.html", + "layouts/category/terms.html.html", + "layouts/category/list.html.html", + "layouts/category/category.terms.html", + "layouts/category/terms.html", + "layouts/category/list.html", + "layouts/_default/category.terms.html.html", + "layouts/_default/terms.html.html", + "layouts/_default/list.html.html", + "layouts/_default/category.terms.html", + "layouts/_default/terms.html", + "layouts/_default/list.html" ] } ] @@ -1427,7 +1753,7 @@ ], "Examples": [ [ - "{{chomp \"\u003cp\u003eBlockhead\u003c/p\u003e\\n\" }}", + "{{chomp \"\u003cp\u003eBlockhead\u003c/p\u003e\\n\" | safeHTML }}", "\u003cp\u003eBlockhead\u003c/p\u003e" ] ] diff --git a/docs/layouts/shortcodes/datatable-filtered.html b/docs/layouts/shortcodes/datatable-filtered.html new file mode 100644 index 000000000..576ddab6f --- /dev/null +++ b/docs/layouts/shortcodes/datatable-filtered.html @@ -0,0 +1,28 @@ +{{ $package := (index .Params 0) }} +{{ $listname := (index .Params 1) }} +{{ $filter := split (index .Params 2) " " }} +{{ $filter1 := index $filter 0 }} +{{ $filter2 := index $filter 1 }} +{{ $filter3 := index $filter 2 }} + +{{ $list := (index (index .Site.Data.docs $package) $listname) }} +{{ $fields := after 3 .Params }} +{{ $list := where $list $filter1 $filter2 $filter3 }} + +<table class="table table-bordered"> + <tr> + {{ range $fields }} + <th>{{ . }}</th> + {{ end }} + </tr> + {{ range $list }} + <tr> + {{ range $k, $v := . }} + {{ $.Scratch.Set $k $v }} + {{ end }} + {{ range $fields }} + <td>{{ $.Scratch.Get . }}</td> + {{ end }} + </tr> + {{ end }} +</table> diff --git a/docs/layouts/shortcodes/imgproc.html b/docs/layouts/shortcodes/imgproc.html index f0ab4c8ea..6ff73e1f9 100644 --- a/docs/layouts/shortcodes/imgproc.html +++ b/docs/layouts/shortcodes/imgproc.html @@ -1,4 +1,4 @@ -{{ $original := .Page.Resources.GetByPrefix (.Get 0) }} +{{ $original := .Page.Resources.GetMatch (printf "%s*" (.Get 0)) }} {{ $command := .Get 1 }} {{ $options := .Get 2 }} {{ if eq $command "Fit"}} @@ -14,6 +14,12 @@ <figure style="width: {{ add $image.Width 3 }}px; padding: 3px; background-color: #cccc"> <img src="{{ $image.RelPermalink }}" width="{{ $image.Width }}" height="{{ $image.Height }}"> <figcaption> - <small>.{{ $command }} "{{ $options }}"</small> + <small> + {{ with .Inner }} + {{ . }} + {{ else }} + .{{ $command }} "{{ $options }}" + {{ end }} + </small> </figcaption> </figure>
\ No newline at end of file diff --git a/docs/netlify.toml b/docs/netlify.toml index 563f1e0a7..3188d0262 100644 --- a/docs/netlify.toml +++ b/docs/netlify.toml @@ -3,15 +3,15 @@ command = "hugo" [context.production.environment] - HUGO_VERSION = "0.32.4" + HUGO_VERSION = "0.34" HUGO_ENV = "production" HUGO_ENABLEGITINFO = "true" [context.deploy-preview.environment] - HUGO_VERSION = "0.32.4" + HUGO_VERSION = "0.34" [context.branch-deploy.environment] - HUGO_VERSION = "0.32.4" + HUGO_VERSION = "0.34" [context.next.environment] HUGO_BASEURL = "https://next--gohugoio.netlify.com/" diff --git a/docs/resources/_gen/images/content-management/image-processing/sunset_hu59e56ffff1bc1d8d122b1403d34e039f_90587_300x0_resize_q10_box_center.jpg b/docs/resources/_gen/images/content-management/image-processing/sunset_hu59e56ffff1bc1d8d122b1403d34e039f_90587_300x0_resize_q10_box_center.jpg Binary files differnew file mode 100644 index 000000000..8736f0376 --- /dev/null +++ b/docs/resources/_gen/images/content-management/image-processing/sunset_hu59e56ffff1bc1d8d122b1403d34e039f_90587_300x0_resize_q10_box_center.jpg diff --git a/docs/resources/_gen/images/content-management/image-processing/sunset_hu59e56ffff1bc1d8d122b1403d34e039f_90587_300x0_resize_q75_box_center.jpg b/docs/resources/_gen/images/content-management/image-processing/sunset_hu59e56ffff1bc1d8d122b1403d34e039f_90587_300x0_resize_q75_box_center.jpg Binary files differnew file mode 100644 index 000000000..47d62fce7 --- /dev/null +++ b/docs/resources/_gen/images/content-management/image-processing/sunset_hu59e56ffff1bc1d8d122b1403d34e039f_90587_300x0_resize_q75_box_center.jpg diff --git a/docs/resources/_gen/images/content-management/image-processing/sunset_hu59e56ffff1bc1d8d122b1403d34e039f_90587_90x120_fill_q75_box_left.jpg b/docs/resources/_gen/images/content-management/image-processing/sunset_hu59e56ffff1bc1d8d122b1403d34e039f_90587_90x120_fill_q75_box_left.jpg Binary files differnew file mode 100644 index 000000000..f9e218242 --- /dev/null +++ b/docs/resources/_gen/images/content-management/image-processing/sunset_hu59e56ffff1bc1d8d122b1403d34e039f_90587_90x120_fill_q75_box_left.jpg diff --git a/docs/resources/_gen/images/content-management/image-processing/sunset_hu59e56ffff1bc1d8d122b1403d34e039f_90587_90x120_fill_q75_box_right.jpg b/docs/resources/_gen/images/content-management/image-processing/sunset_hu59e56ffff1bc1d8d122b1403d34e039f_90587_90x120_fill_q75_box_right.jpg Binary files differnew file mode 100644 index 000000000..fb96b61b6 --- /dev/null +++ b/docs/resources/_gen/images/content-management/image-processing/sunset_hu59e56ffff1bc1d8d122b1403d34e039f_90587_90x120_fill_q75_box_right.jpg diff --git a/docs/resources/_gen/images/content-management/image-processing/sunset_hu59e56ffff1bc1d8d122b1403d34e039f_90587_90x90_fit_q75_box_center.jpg b/docs/resources/_gen/images/content-management/image-processing/sunset_hu59e56ffff1bc1d8d122b1403d34e039f_90587_90x90_fit_q75_box_center.jpg Binary files differnew file mode 100644 index 000000000..b8ad2659f --- /dev/null +++ b/docs/resources/_gen/images/content-management/image-processing/sunset_hu59e56ffff1bc1d8d122b1403d34e039f_90587_90x90_fit_q75_box_center.jpg diff --git a/docs/resources/_gen/images/content-management/organization/1-featured-content-bundles_hu3e3ae7839b071119f32acaa20f204198_63640_300x0_resize_box_center.png b/docs/resources/_gen/images/content-management/organization/1-featured-content-bundles_hu3e3ae7839b071119f32acaa20f204198_63640_300x0_resize_box_center.png Binary files differnew file mode 100644 index 000000000..7d29ca620 --- /dev/null +++ b/docs/resources/_gen/images/content-management/organization/1-featured-content-bundles_hu3e3ae7839b071119f32acaa20f204198_63640_300x0_resize_box_center.png diff --git a/docs/static/images/blog/hugo-33-poster.png b/docs/static/images/blog/hugo-33-poster.png Binary files differnew file mode 100644 index 000000000..c30caafcc --- /dev/null +++ b/docs/static/images/blog/hugo-33-poster.png diff --git a/docs/static/images/blog/hugo-34-poster.png b/docs/static/images/blog/hugo-34-poster.png Binary files differnew file mode 100644 index 000000000..a5c81b8c8 --- /dev/null +++ b/docs/static/images/blog/hugo-34-poster.png diff --git a/docs/themes/gohugoioTheme/archetypes/default.md b/docs/themes/gohugoioTheme/archetypes/default.md deleted file mode 100644 index f30f01f74..000000000 --- a/docs/themes/gohugoioTheme/archetypes/default.md +++ /dev/null @@ -1,13 +0,0 @@ ---- -linktitle: "" -description: "" -godocref: "" -publishdate: "" -lastmod: "" -categories: [] -tags: [] -weight: 00 -slug: "" -aliases: [] -toc: false ----
\ No newline at end of file diff --git a/docs/themes/gohugoioTheme/archetypes/showcase.md b/docs/themes/gohugoioTheme/archetypes/showcase.md deleted file mode 100644 index 562fb9e8e..000000000 --- a/docs/themes/gohugoioTheme/archetypes/showcase.md +++ /dev/null @@ -1,13 +0,0 @@ ---- -description: "" -lastmod: "" -license: "" -licenseLink: "" -sitelink: "" -sourcelink: "" -categories: [showcase] -tags: [] -image: "" -toc: false -notesforauthors: "Go to gohugo.io/contribute/documentation for more info" ----
\ No newline at end of file diff --git a/docs/themes/gohugoioTheme/archetypes/tutorials.md b/docs/themes/gohugoioTheme/archetypes/tutorials.md deleted file mode 100644 index 0a3540c0f..000000000 --- a/docs/themes/gohugoioTheme/archetypes/tutorials.md +++ /dev/null @@ -1,16 +0,0 @@ ---- -linktitle: "" -description: "" -godocref: "" -publishdate: "" -lastmod: "" -categories: [tutorials] -tags: [] -author: "" -authorurl: "" -originalurl: "" -draft: false -aliases: [] -notesforauthors: "Go to gohugo.io/contribute/documentation for more info." ---- - diff --git a/docs/themes/gohugoioTheme/layouts/_default/baseof.html b/docs/themes/gohugoioTheme/layouts/_default/baseof.html index fb09c0db4..d6c854db0 100755 --- a/docs/themes/gohugoioTheme/layouts/_default/baseof.html +++ b/docs/themes/gohugoioTheme/layouts/_default/baseof.html @@ -9,7 +9,7 @@ <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> {{/* NOTE: the Site's title, and if there is a page title, that is set too */}} - <title>{{ block "title" . }}{{ .Site.Title }} {{ with .Title }} | {{ . }}{{ end }}{{ end }}</title> + <title>{{ block "title" . }}{{ with .Title }}{{ . }} | {{ end }}{{ .Site.Title }}{{ end }}</title> <meta name="HandheldFriendly" content="True"> <meta name="MobileOptimized" content="320"> @@ -27,7 +27,7 @@ {{- template "_internal/opengraph.html" . -}} {{- template "_internal/google_news.html" . -}} {{- template "_internal/schema.html" . -}} - {{- partial "twitter_cards.html" . -}} + {{- template "_internal/twitter_cards.html" . -}} {{ if eq (getenv "HUGO_ENV") "production" | or (eq .Site.Params.env "production") }} {{ template "_internal/google_analytics_async.html" . }} diff --git a/docs/themes/gohugoioTheme/layouts/partials/twitter_cards.html b/docs/themes/gohugoioTheme/layouts/partials/twitter_cards.html deleted file mode 100644 index d719937df..000000000 --- a/docs/themes/gohugoioTheme/layouts/partials/twitter_cards.html +++ /dev/null @@ -1,17 +0,0 @@ -{{- with $.Param "images" -}} -<meta name="twitter:card" content="summary_large_image"/> -<meta name="twitter:image:src" content="{{ index . 0 | absURL }}"/> -{{ else -}} -<meta name="twitter:card" content="summary"/> -{{- end -}} -<meta name="twitter:title" content="{{ .Title }}"/> -<meta name="twitter:description" content="{{ with .Description }}{{ . }}{{ else }}{{if .IsPage}}{{ .Summary }}{{ else }}{{ with .Site.Params.description }}{{ . }}{{ end }}{{ end }}{{ end -}}"/> -{{ with .Site.Social.twitter -}} -<meta name="twitter:site" content="@{{ . }}"/> -{{ end -}} -{{ range .Site.Authors }} -{{ with .twitter -}} -<meta name="twitter:creator" content="@{{ . }}"/> -{{ end -}} -{{ end -}} - |