mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-07 20:30:36 -05:00
doc: Strip trailing whitespace; other revisions
Make some random and non-comprehensive changes to the template functions documentation to make them more consistent.
This commit is contained in:
parent
b0416e9bef
commit
5505ac0d72
29 changed files with 217 additions and 206 deletions
|
@ -101,7 +101,7 @@ We welcome your contributions. To make the process as seamless as possible, we a
|
||||||
* Run `go fmt`
|
* Run `go fmt`
|
||||||
* Squash your commits into a single commit. `git rebase -i`. It’s okay to force update your pull request.
|
* Squash your commits into a single commit. `git rebase -i`. It’s okay to force update your pull request.
|
||||||
* This [blog article](http://chris.beams.io/posts/git-commit/) is a good resource for learning how to write good commit messages, the most important part being that each commit message should have a title/subject in imperative mode without trailing period: *"Return error on wrong use of the Paginator"*, **NOT** *"Returning some error."* Also, if your commit references one or more GitHub issues, always end your commit message body with *See #1234* or *Fixes #1234*. Replace *1234* with the GitHub issue ID. The last example will close the issue when the commit is merged into *master*.
|
* This [blog article](http://chris.beams.io/posts/git-commit/) is a good resource for learning how to write good commit messages, the most important part being that each commit message should have a title/subject in imperative mode without trailing period: *"Return error on wrong use of the Paginator"*, **NOT** *"Returning some error."* Also, if your commit references one or more GitHub issues, always end your commit message body with *See #1234* or *Fixes #1234*. Replace *1234* with the GitHub issue ID. The last example will close the issue when the commit is merged into *master*.
|
||||||
* Make sure `go test ./...` passes, and `go build` completes. Our [Travis CI loop](https://travis-ci.org/spf13/hugo) (Linux) and [AppVeyor](https://ci.appveyor.com/project/spf13/hugo/branch/master) (Windows) will catch most things that are missing.
|
* Make sure `go test ./...` passes, and `go build` completes. Our [Travis CI loop](https://travis-ci.org/spf13/hugo) (Linux) and [AppVeyor](https://ci.appveyor.com/project/spf13/hugo/branch/master) (Windows) will catch most things that are missing.
|
||||||
|
|
||||||
### Building Hugo with Your Changes
|
### Building Hugo with Your Changes
|
||||||
|
|
||||||
|
|
|
@ -145,12 +145,12 @@ When a `url` is provided, it will be used exactly. Using `url` will ignore the
|
||||||
|
|
||||||
**section** = which type the content is by default
|
**section** = which type the content is by default
|
||||||
|
|
||||||
* based on content location
|
* based on content location
|
||||||
* front matter overrides
|
* front matter overrides
|
||||||
|
|
||||||
**slug** = name.ext or name/
|
**slug** = name.ext or name/
|
||||||
|
|
||||||
* based on content-name.md
|
* based on content-name.md
|
||||||
* front matter overrides
|
* front matter overrides
|
||||||
|
|
||||||
**path** = section + path to file excluding slug
|
**path** = section + path to file excluding slug
|
||||||
|
|
|
@ -19,11 +19,11 @@ Luckily, redirects can be handled easily with _aliases_ in Hugo.
|
||||||
|
|
||||||
## Example
|
## Example
|
||||||
|
|
||||||
Given a post on your current Hugo site, with a path of:
|
Given a post on your current Hugo site, with a path of:
|
||||||
|
|
||||||
``content/posts/my-awesome-blog-post.md``
|
``content/posts/my-awesome-blog-post.md``
|
||||||
|
|
||||||
... you create an "aliases" section in the frontmatter of your post, and add previous paths to that.
|
... you create an "aliases" section in the frontmatter of your post, and add previous paths to that.
|
||||||
|
|
||||||
### TOML frontmatter
|
### TOML frontmatter
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ aliases:
|
||||||
---
|
---
|
||||||
~~~
|
~~~
|
||||||
|
|
||||||
Now when you visit any of the locations specified in aliases, _assuming the same site domain_, you'll be redirected to the page they are specified on.
|
Now when you visit any of the locations specified in aliases, _assuming the same site domain_, you'll be redirected to the page they are specified on.
|
||||||
|
|
||||||
## Important Behaviors
|
## Important Behaviors
|
||||||
|
|
||||||
|
@ -63,9 +63,9 @@ any content with the same location.*
|
||||||
|
|
||||||
## How Hugo Aliases Work
|
## How Hugo Aliases Work
|
||||||
|
|
||||||
When aliases are specified, Hugo creates a physical folder structure to match the alias entry, and, an html file specifying the canonical URL for the page, and a redirect target.
|
When aliases are specified, Hugo creates a physical folder structure to match the alias entry, and, an html file specifying the canonical URL for the page, and a redirect target.
|
||||||
|
|
||||||
Assuming a baseurl of `mysite.tld`, the contents of the html file will look something like:
|
Assuming a baseurl of `mysite.tld`, the contents of the html file will look something like:
|
||||||
|
|
||||||
~~~html
|
~~~html
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
|
|
|
@ -80,7 +80,7 @@ A few alternatives exist to [Disqus](https://disqus.com/):
|
||||||
* [isso](http://posativ.org/isso/) (Self-hosted, Python)
|
* [isso](http://posativ.org/isso/) (Self-hosted, Python)
|
||||||
* [Kaiju](https://github.com/spf13/kaiju)
|
* [Kaiju](https://github.com/spf13/kaiju)
|
||||||
|
|
||||||
## Kaiju
|
## Kaiju
|
||||||
|
|
||||||
[Kaiju](https://github.com/spf13/kaiju) is an open-source project started by [spf13](http://spf13.com/) (Hugo’s author) to bring easy and fast real time discussions to the web.
|
[Kaiju](https://github.com/spf13/kaiju) is an open-source project started by [spf13](http://spf13.com/) (Hugo’s author) to bring easy and fast real time discussions to the web.
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ Data Files can also be used in [themes](/themes/overview/), but note: If the sam
|
||||||
|
|
||||||
As explained in [Source Organization](/overview/source-directory/), the `data` folder is where you can store additional data for Hugo to use when generating your site. These files must be YAML, JSON or TOML files (using either the `.yml`, `.yaml`, `.json` or `toml` extension) and the data will be accessible as a `map` in `.Site.Data`.
|
As explained in [Source Organization](/overview/source-directory/), the `data` folder is where you can store additional data for Hugo to use when generating your site. These files must be YAML, JSON or TOML files (using either the `.yml`, `.yaml`, `.json` or `toml` extension) and the data will be accessible as a `map` in `.Site.Data`.
|
||||||
|
|
||||||
**The keys in this map will be a dot chained set of _path_, _filename_ and _key_ in file (if applicable).**
|
**The keys in this map will be a dot chained set of _path_, _filename_ and _key_ in file (if applicable).**
|
||||||
|
|
||||||
This is best explained with an example:
|
This is best explained with an example:
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ discography = [
|
||||||
"1991 - Live In New York City, Volumes 1-7.",
|
"1991 - Live In New York City, Volumes 1-7.",
|
||||||
"1999 - Rare Collection (compilation)",
|
"1999 - Rare Collection (compilation)",
|
||||||
"2003 - Punk Jazz: The Jaco Pastorius Anthology (compilation)",
|
"2003 - Punk Jazz: The Jaco Pastorius Anthology (compilation)",
|
||||||
"2007 - The Essential Jaco Pastorius (compilation)"
|
"2007 - The Essential Jaco Pastorius (compilation)"
|
||||||
]
|
]
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -101,4 +101,4 @@ To render the `Short Description` in your `layout` File following code is requir
|
||||||
<div>Short Description of {{.Site.Data.User0123.Name}}: <p>{{ index .Site.Data.User0123 "Short Description" | markdownify }}</p></div>
|
<div>Short Description of {{.Site.Data.User0123.Name}}: <p>{{ index .Site.Data.User0123 "Short Description" | markdownify }}</p></div>
|
||||||
```
|
```
|
||||||
|
|
||||||
Note the use of the `markdownify` template function. This will send the description through the Blackfriday Markdown rendering engine.
|
Note the use of the `markdownify` template function. This will send the description through the Blackfriday Markdown rendering engine.
|
||||||
|
|
|
@ -12,9 +12,9 @@ weight: 90
|
||||||
toc: true
|
toc: true
|
||||||
---
|
---
|
||||||
|
|
||||||
Hugo provides the ability for you to highlight source code in _two different ways_ — either pre-processed server side from your content, or to defer the processing to the client side, using a JavaScript library.
|
Hugo provides the ability for you to highlight source code in _two different ways_ — either pre-processed server side from your content, or to defer the processing to the client side, using a JavaScript library.
|
||||||
|
|
||||||
**The advantage of server side** is that it doesn’t depend on a JavaScript library and consequently works very well when read from an RSS feed.
|
**The advantage of server side** is that it doesn’t depend on a JavaScript library and consequently works very well when read from an RSS feed.
|
||||||
|
|
||||||
**The advantage of client side** is that it doesn’t cost anything when building your site and some of the highlighting scripts available cover more languages than Pygments does.
|
**The advantage of client side** is that it doesn’t cost anything when building your site and some of the highlighting scripts available cover more languages than Pygments does.
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ Hugo gives you two options that you can set with the variable `pygmentsuseclasse
|
||||||
|
|
||||||
### Usage
|
### Usage
|
||||||
|
|
||||||
Highlighting is carried out via the in-built shortcode `highlight`. `highlight` takes exactly one required parameter of language, and requires a closing shortcode. Note that `highlight` is _not_ used for client-side javascript highlighting.
|
Highlighting is carried out via the in-built shortcode `highlight`. `highlight` takes exactly one required parameter of language, and requires a closing shortcode. Note that `highlight` is _not_ used for client-side javascript highlighting.
|
||||||
|
|
||||||
### Example
|
### Example
|
||||||
|
|
||||||
|
@ -88,7 +88,7 @@ The keywords are the same you would using with Pygments from the command line, s
|
||||||
|
|
||||||
### Disclaimers
|
### Disclaimers
|
||||||
|
|
||||||
* Pygments is relatively slow and _causes a performance hit when building your site_, but Hugo has been designed to cache the results to disk.
|
* Pygments is relatively slow and _causes a performance hit when building your site_, but Hugo has been designed to cache the results to disk.
|
||||||
* Languages available depends on your Pygments installation.
|
* Languages available depends on your Pygments installation.
|
||||||
|
|
||||||
## Client-side
|
## Client-side
|
||||||
|
@ -118,7 +118,7 @@ In your `./layouts/partials/` (or `./layouts/chrome/`) folder, depending on your
|
||||||
|
|
||||||
### Prism example
|
### Prism example
|
||||||
|
|
||||||
Prism is another popular highlighter library, used on some major sites. Similar to Highlight.js, you simply load `prism.css` in your `<head>` via whatever Hugo partial template is creating that part of your pages, like so:
|
Prism is another popular highlighter library, used on some major sites. Similar to Highlight.js, you simply load `prism.css` in your `<head>` via whatever Hugo partial template is creating that part of your pages, like so:
|
||||||
|
|
||||||
```html
|
```html
|
||||||
...
|
...
|
||||||
|
@ -126,7 +126,7 @@ Prism is another popular highlighter library, used on some major sites. Similar
|
||||||
...
|
...
|
||||||
```
|
```
|
||||||
|
|
||||||
... and add `prism.js` near the bottom of your `<body>` tag, again in whatever Hugo partial template is appropriate for your site or theme.
|
... and add `prism.js` near the bottom of your `<body>` tag, again in whatever Hugo partial template is appropriate for your site or theme.
|
||||||
|
|
||||||
```html
|
```html
|
||||||
...
|
...
|
||||||
|
@ -139,9 +139,9 @@ In this example, the local paths indicate that your own copy of these files are
|
||||||
|
|
||||||
### Using Client-side highlighting
|
### Using Client-side highlighting
|
||||||
|
|
||||||
To use client-side highlighting, most of these javascript libraries expect your code to be wrapped in semantically correct `<code>` tags, with the language expressed in a class attribute on the `<code>` tag, such as `class="language-abc"`, where the `abc` is the code the highlighter script uses to represent that language.
|
To use client-side highlighting, most of these javascript libraries expect your code to be wrapped in semantically correct `<code>` tags, with the language expressed in a class attribute on the `<code>` tag, such as `class="language-abc"`, where the `abc` is the code the highlighter script uses to represent that language.
|
||||||
|
|
||||||
The script would be looking for classes like `language-go`, `language-html`, or `language-css`. If you look at the page's source, it would be marked up like so:
|
The script would be looking for classes like `language-go`, `language-html`, or `language-css`. If you look at the page's source, it would be marked up like so:
|
||||||
|
|
||||||
~~~html
|
~~~html
|
||||||
<pre>
|
<pre>
|
||||||
|
|
|
@ -14,14 +14,14 @@ weight: 110
|
||||||
|
|
||||||
## Traversing Local Files
|
## Traversing Local Files
|
||||||
|
|
||||||
Hugo includes a way to traverse local files.
|
Hugo includes a way to traverse local files.
|
||||||
This is done using the 'ReadDir' function.
|
This is done using the 'ReadDir' function.
|
||||||
|
|
||||||
## Using ReadDir
|
## Using ReadDir
|
||||||
|
|
||||||
ReadDir takes a single string input that is relative to the root directory of the site. It returns an array of [os.FileInfo](https://golang.org/pkg/os/#FileInfo)
|
ReadDir takes a single string input that is relative to the root directory of the site. It returns an array of [os.FileInfo](https://golang.org/pkg/os/#FileInfo)
|
||||||
|
|
||||||
Let's create a shortcode to build a file index with links using ReadDir.
|
Let's create a shortcode to build a file index with links using ReadDir.
|
||||||
|
|
||||||
'fileindex.html'
|
'fileindex.html'
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ Let's create a shortcode to build a file index with links using ReadDir.
|
||||||
<td>
|
<td>
|
||||||
<a href="{{$url}}{{.Name | urlize }}"> {{.Name}}</a>
|
<a href="{{$url}}{{.Name | urlize }}"> {{.Name}}</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ weight: 60
|
||||||
---
|
---
|
||||||
|
|
||||||
Hugo has a simple yet powerful menu system that permits content to be
|
Hugo has a simple yet powerful menu system that permits content to be
|
||||||
placed in menus with a good degree of control without a lot of work.
|
placed in menus with a good degree of control without a lot of work.
|
||||||
|
|
||||||
|
|
||||||
*TIP:* If all you want is a simple menu for your sections, see [Section Menu for "the Lazy Blogger"]({{< relref "#section-menu-for-the-lazy-blogger" >}}).
|
*TIP:* If all you want is a simple menu for your sections, see [Section Menu for "the Lazy Blogger"]({{< relref "#section-menu-for-the-lazy-blogger" >}}).
|
||||||
|
@ -121,11 +121,11 @@ And the equivalent example `config.yaml`:
|
||||||
Pre: "<i class='fa fa-road'></i>"
|
Pre: "<i class='fa fa-road'></i>"
|
||||||
Weight: -100
|
Weight: -100
|
||||||
URL: "/getting-started/"
|
URL: "/getting-started/"
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|
||||||
**NOTE:** The URLs must be relative to the context root. If the `BaseURL` is `http://example.com/mysite/`, then the URLs in the menu must not include the context root `mysite`.
|
**NOTE:** The URLs must be relative to the context root. If the `BaseURL` is `http://example.com/mysite/`, then the URLs in the menu must not include the context root `mysite`.
|
||||||
|
|
||||||
## Nesting
|
## Nesting
|
||||||
|
|
||||||
All nesting of content is done via the `parent` field.
|
All nesting of content is done via the `parent` field.
|
||||||
|
@ -146,7 +146,7 @@ and all content entries are attached to one of these entries via the
|
||||||
|
|
||||||
Hugo makes no assumptions about how your rendered HTML will be
|
Hugo makes no assumptions about how your rendered HTML will be
|
||||||
structured. Instead, it provides all of the functions you will need to be
|
structured. Instead, it provides all of the functions you will need to be
|
||||||
able to build your menu however you want.
|
able to build your menu however you want.
|
||||||
|
|
||||||
|
|
||||||
The following is an example:
|
The following is an example:
|
||||||
|
@ -213,7 +213,7 @@ This will create a menu with all the sections as menu items and all the sections
|
||||||
|
|
||||||
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.
|
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`:
|
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`:
|
||||||
|
|
||||||
```
|
```
|
||||||
[[menu.main]]
|
[[menu.main]]
|
||||||
|
|
|
@ -200,7 +200,7 @@ A shortcode with `.Inner` content can be used wihout the inline content, and wit
|
||||||
|
|
||||||
The variable `.Params` contains the list of parameters in case you need to do more complicated things than `.Get`.
|
The variable `.Params` contains the list of parameters in case you need to do more complicated things than `.Get`.
|
||||||
|
|
||||||
You can also use the variable `.Page` to access all the normal [Page Variables](/templates/variables/).
|
You can also use the variable `.Page` to access all the normal [Page Variables](/templates/variables/).
|
||||||
|
|
||||||
## Single Positional Example: youtube
|
## Single Positional Example: youtube
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ or use the `--uglyUrls=true` flag on the command line.
|
||||||
|
|
||||||
If you want a specific piece of content to have an exact URL, you can
|
If you want a specific piece of content to have an exact URL, you can
|
||||||
specify this in the front matter under the `url` key. See [Content
|
specify this in the front matter under the `url` key. See [Content
|
||||||
Organization](/content/organization/) for more details.
|
Organization](/content/organization/) for more details.
|
||||||
|
|
||||||
## Canonicalization
|
## Canonicalization
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@ them](https://github.com/spf13/hugoThemes/blob/master/README.md#theme-list).
|
||||||
|
|
||||||
Hugo also depends on a lot of other great projects. A big thanks to all of our dependencies inclding:
|
Hugo also depends on a lot of other great projects. A big thanks to all of our dependencies inclding:
|
||||||
[cobra](https://github.com/spf13/cobra),
|
[cobra](https://github.com/spf13/cobra),
|
||||||
[viper](https://github.com/spf13/viper),
|
[viper](https://github.com/spf13/viper),
|
||||||
[blackfriday](https://github.com/russross/blackfriday),
|
[blackfriday](https://github.com/russross/blackfriday),
|
||||||
[pflag](https://github.com/spf13/pflag),
|
[pflag](https://github.com/spf13/pflag),
|
||||||
[HugoThemes](https://github.com/spf13/hugothemes),
|
[HugoThemes](https://github.com/spf13/hugothemes),
|
||||||
|
@ -55,10 +55,10 @@ Hugo also depends on a lot of other great projects. A big thanks to all of our d
|
||||||
[goYaml](https://github.com/go-yaml/yaml/tree/v2), and the Go standard library.
|
[goYaml](https://github.com/go-yaml/yaml/tree/v2), and the Go standard library.
|
||||||
|
|
||||||
## New features
|
## New features
|
||||||
* Support for all file types in content directory.
|
* Support for all file types in content directory.
|
||||||
* If dedicated file type handler isn’t found it will be copied to the destination.
|
* If dedicated file type handler isn’t found it will be copied to the destination.
|
||||||
* Add `AsciiDoc` support using external helpers.
|
* Add `AsciiDoc` support using external helpers.
|
||||||
* Add experimental support for [`Mmark`](https://github.com/miekg/mmark) markdown processor
|
* Add experimental support for [`Mmark`](https://github.com/miekg/mmark) markdown processor
|
||||||
* Bash autocomplete support via `genautocomplete` command
|
* Bash autocomplete support via `genautocomplete` command
|
||||||
* Add section menu support for a [Section Menu for "the Lazy Blogger"]({{< relref "extras/menus.md#section-menu-for-the-lazy-blogger" >}})
|
* Add section menu support for a [Section Menu for "the Lazy Blogger"]({{< relref "extras/menus.md#section-menu-for-the-lazy-blogger" >}})
|
||||||
* Add support for `Ace` base templates
|
* Add support for `Ace` base templates
|
||||||
|
@ -70,7 +70,7 @@ Hugo also depends on a lot of other great projects. A big thanks to all of our d
|
||||||
* `absURL` and `relURL`, both of which takes the `BaseURL` setting into account
|
* `absURL` and `relURL`, both of which takes the `BaseURL` setting into account
|
||||||
|
|
||||||
## Improvements
|
## Improvements
|
||||||
* Highlighting with `Pygments` is now cached to disk -- expect a major speed boost if you use it!
|
* Highlighting with `Pygments` is now cached to disk -- expect a major speed boost if you use it!
|
||||||
* More Pygments highlighting options, including `line numbers`
|
* More Pygments highlighting options, including `line numbers`
|
||||||
* Show help information to Windows users who try to double click on `hugo.exe`.
|
* Show help information to Windows users who try to double click on `hugo.exe`.
|
||||||
* Add `bind` flag to `hugo server` to set the interface to which the server will bind
|
* Add `bind` flag to `hugo server` to set the interface to which the server will bind
|
||||||
|
@ -82,7 +82,7 @@ Hugo also depends on a lot of other great projects. A big thanks to all of our d
|
||||||
## Bugfixes
|
## Bugfixes
|
||||||
* Fix panic with paginator and zero pages in result set.
|
* Fix panic with paginator and zero pages in result set.
|
||||||
* Fix crossrefs on Windows.
|
* Fix crossrefs on Windows.
|
||||||
* Fix `eq` and `ne` template functions when used with a raw number combined with the result of `add`, `sub` etc.
|
* Fix `eq` and `ne` template functions when used with a raw number combined with the result of `add`, `sub` etc.
|
||||||
* Fix paginator with uglyurls
|
* Fix paginator with uglyurls
|
||||||
* Fix [#998](https://github.com/spf13/hugo/issues/988), supporting UTF8 characters in Permalinks.
|
* Fix [#998](https://github.com/spf13/hugo/issues/988), supporting UTF8 characters in Permalinks.
|
||||||
|
|
||||||
|
@ -125,7 +125,7 @@ maintainers and their tremendous contributions this release.
|
||||||
* `Scratch` -- [a "scratchpad"](/extras/scratch) for your node- and page-scoped
|
* `Scratch` -- [a "scratchpad"](/extras/scratch) for your node- and page-scoped
|
||||||
variables
|
variables
|
||||||
* [Cross Reference](/extras/crossreferences/) support to easily link documents
|
* [Cross Reference](/extras/crossreferences/) support to easily link documents
|
||||||
together with the ref and relref shortcodes.
|
together with the ref and relref shortcodes.
|
||||||
* [Ace](http://ace.yoss.si/) template engine support ([#541][])
|
* [Ace](http://ace.yoss.si/) template engine support ([#541][])
|
||||||
* A new [shortcode](/extras/shortcodes/) token of `{{</* */>}}` (raw HTML)
|
* A new [shortcode](/extras/shortcodes/) token of `{{</* */>}}` (raw HTML)
|
||||||
alongside the existing `{{%/* */%}}` (Markdown)
|
alongside the existing `{{%/* */%}}` (Markdown)
|
||||||
|
@ -143,7 +143,7 @@ maintainers and their tremendous contributions this release.
|
||||||
### Notable enhancements to existing features
|
### Notable enhancements to existing features
|
||||||
|
|
||||||
* The [shortcode](/extras/shortcodes/) handling is rewritten for speed and
|
* The [shortcode](/extras/shortcodes/) handling is rewritten for speed and
|
||||||
better error messages.
|
better error messages.
|
||||||
* Several improvements to the [template functions](/templates/functions/):
|
* Several improvements to the [template functions](/templates/functions/):
|
||||||
* `where` is now even more powerful and accepts SQL-like syntax with the
|
* `where` is now even more powerful and accepts SQL-like syntax with the
|
||||||
operators `==`, `eq`; `!=`, `<>`, `ne`; `>=`, `ge`; `>`, `gt`; `<=`,
|
operators `==`, `eq`; `!=`, `<>`, `ne`; `>=`, `ge`; `>`, `gt`; `<=`,
|
||||||
|
@ -156,7 +156,7 @@ maintainers and their tremendous contributions this release.
|
||||||
* `delimit`
|
* `delimit`
|
||||||
* `sort`
|
* `sort`
|
||||||
* `markdownify`
|
* `markdownify`
|
||||||
* `in` and `intersect`
|
* `in` and `intersect`
|
||||||
* `trim`
|
* `trim`
|
||||||
* `replace`
|
* `replace`
|
||||||
* `dateFormat`
|
* `dateFormat`
|
||||||
|
|
|
@ -80,7 +80,7 @@ Following is a list of Hugo-defined variables that you can configure and their c
|
||||||
# include content with publishdate in the future
|
# include content with publishdate in the future
|
||||||
buildFuture: false
|
buildFuture: false
|
||||||
# enable this to make all relative URLs relative to content root. Note that this does not affect absolute URLs.
|
# enable this to make all relative URLs relative to content root. Note that this does not affect absolute URLs.
|
||||||
relativeURLs: false
|
relativeURLs: false
|
||||||
canonifyURLs: false
|
canonifyURLs: false
|
||||||
# config file (default is path/config.yaml|json|toml)
|
# config file (default is path/config.yaml|json|toml)
|
||||||
config: "config.toml"
|
config: "config.toml"
|
||||||
|
|
|
@ -15,16 +15,16 @@ weight: 30
|
||||||
Make sure either `hugo` is in your `PATH` or provide a path to it.
|
Make sure either `hugo` is in your `PATH` or provide a path to it.
|
||||||
|
|
||||||
<pre><code class="hljs nohighlight">$ hugo help
|
<pre><code class="hljs nohighlight">$ hugo help
|
||||||
|
|
||||||
Hugo is a Fast and Flexible Static Site Generator built with love by spf13 and friends in Go.
|
Hugo is a Fast and Flexible Static Site Generator built with love by spf13 and friends in Go.
|
||||||
|
|
||||||
Complete documentation is available at http://gohugo.io
|
Complete documentation is available at http://gohugo.io
|
||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
hugo [flags]
|
hugo [flags]
|
||||||
hugo [command]
|
hugo [command]
|
||||||
|
|
||||||
Available Commands:
|
Available Commands:
|
||||||
server Hugo runs its own webserver to render the files
|
server Hugo runs its own webserver to render the files
|
||||||
version Print the version number of Hugo
|
version Print the version number of Hugo
|
||||||
config Print the site configuration
|
config Print the site configuration
|
||||||
|
|
|
@ -9,5 +9,5 @@ tags:
|
||||||
- personal
|
- personal
|
||||||
- blog
|
- blog
|
||||||
thumbnail: /img/arianv-tn.png
|
thumbnail: /img/arianv-tn.png
|
||||||
title: Arian's Portfolio
|
title: Arian's Portfolio
|
||||||
---
|
---
|
||||||
|
|
|
@ -37,7 +37,7 @@ and all of the content attached to those terms.
|
||||||
|
|
||||||
**Taxonomy:** A categorization that can be used to classify content
|
**Taxonomy:** A categorization that can be used to classify content
|
||||||
|
|
||||||
**Term:** A key within that taxonomy
|
**Term:** A key within that taxonomy
|
||||||
|
|
||||||
**Value:** A piece of content assigned to that Term
|
**Value:** A piece of content assigned to that Term
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,9 @@ weight: 100
|
||||||
---
|
---
|
||||||
|
|
||||||
When using Hugo with [GitHub Pages](http://pages.github.com/), you can provide
|
When using Hugo with [GitHub Pages](http://pages.github.com/), you can provide
|
||||||
your own template for a [custom 404 error page](https://help.github.com/articles/custom-404-pages/) by creating a 404.html template file in your `/layouts` folder. When Hugo generates your site, the `404.html` file will be placed in the root.
|
your own template for a [custom 404 error page](https://help.github.com/articles/custom-404-pages/)
|
||||||
|
by creating a 404.html template file in your `/layouts` folder.
|
||||||
|
When Hugo generates your site, the `404.html` file will be placed in the root.
|
||||||
|
|
||||||
404 pages are of the type **"node"** and have all the [node
|
404 pages are of the type **"node"** and have all the [node
|
||||||
variables](/layout/variables/) available to use in the templates.
|
variables](/layout/variables/) available to use in the templates.
|
||||||
|
@ -43,10 +45,10 @@ This is a basic example of a 404.html template:
|
||||||
|
|
||||||
### Automatic Loading
|
### Automatic Loading
|
||||||
|
|
||||||
Your 404.html file can be set to load automatically when a visitor enters a mistaken URL path, dependent upon the web serving environment you are using. For example:
|
Your 404.html file can be set to load automatically when a visitor enters a mistaken URL path, dependent upon the web serving environment you are using. For example:
|
||||||
|
|
||||||
* _Github Pages_ - it's automatic.
|
* _GitHub Pages_ - it's automatic.
|
||||||
* _Apache_ - one way is to specify `ErrorDocument 404 /404.html` in an `.htaccess` file in the root of your site.
|
* _Apache_ - one way is to specify `ErrorDocument 404 /404.html` in an `.htaccess` file in the root of your site.
|
||||||
* _Nginx_ - you might specify `error_page 404 = /404.html;` in your `nginx.conf` file.
|
* _Nginx_ - you might specify `error_page 404 = /404.html;` in your `nginx.conf` file.
|
||||||
* _Amazon AWS S3_ - when setting a bucket up for static web serving, you can specify the error file.
|
* _Amazon AWS S3_ - when setting a bucket up for static web serving, you can specify the error file.
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ weight: 17
|
||||||
|
|
||||||
In addition to [Go templates](/templates/go-templates) and [Amber](/templates/amber) templates, Hugo supports the powerful Ace templates.
|
In addition to [Go templates](/templates/go-templates) and [Amber](/templates/amber) templates, Hugo supports the powerful Ace templates.
|
||||||
|
|
||||||
For template documentation, follow the links from the [Ace project](https://github.com/yosssi/ace).
|
For template documentation, follow the links from the [Ace project](https://github.com/yosssi/ace).
|
||||||
|
|
||||||
* Ace templates must be named with the ace-suffix, e.g. `list.ace`
|
* Ace templates must be named with the ace-suffix, e.g. `list.ace`
|
||||||
* It's possible to use both Go templates and Ace templates side-by-side, and include one into the other
|
* It's possible to use both Go templates and Ace templates side-by-side, and include one into the other
|
||||||
|
@ -34,7 +34,7 @@ In Hugo the base template will be chosen in the following order:
|
||||||
1. <current-path>/<template-name>-baseof.ace, e.g. list-baseof.ace
|
1. <current-path>/<template-name>-baseof.ace, e.g. list-baseof.ace
|
||||||
2. <current-path>/baseof.ace
|
2. <current-path>/baseof.ace
|
||||||
3. _default/<template-name>-baseof.ace, e.g. list-baseof.ace.
|
3. _default/<template-name>-baseof.ace, e.g. list-baseof.ace.
|
||||||
4. _default/baseof.ace
|
4. _default/baseof.ace
|
||||||
5. <themedir>/layouts/_default/<template-name>-baseof.ace
|
5. <themedir>/layouts/_default/<template-name>-baseof.ace
|
||||||
6. <themedir>/layouts/_default/baseof.ace
|
6. <themedir>/layouts/_default/baseof.ace
|
||||||
```
|
```
|
||||||
|
@ -55,7 +55,7 @@ baseof.ace list.ace single.ace single-baseof.ace
|
||||||
|
|
||||||
Some examples for the layout files above:
|
Some examples for the layout files above:
|
||||||
|
|
||||||
* Home page: `./index.ace` + `./_default/baseof.ace`
|
* Home page: `./index.ace` + `./_default/baseof.ace`
|
||||||
* Single page in the `blog` section: `./blog/single.ace` + `./blog/baseof.ace`
|
* Single page in the `blog` section: `./blog/single.ace` + `./blog/baseof.ace`
|
||||||
* Single page in another section: `./_default/single.ace` + `./_default/single-baseof.ace`
|
* Single page in another section: `./_default/single.ace` + `./_default/single-baseof.ace`
|
||||||
* Taxonomy page in any section: `./_default/list.ace` + `./_default/baseof.ace`
|
* Taxonomy page in any section: `./_default/list.ace` + `./_default/baseof.ace`
|
||||||
|
|
|
@ -52,13 +52,13 @@ e.g.
|
||||||
|
|
||||||
|
|
||||||
### echoParam
|
### echoParam
|
||||||
If parameter is set, then echo it.
|
Prints a parameter if it is set.
|
||||||
|
|
||||||
e.g. `{{echoParam .Params "project_url" }}`
|
e.g. `{{ echoParam .Params "project_url" }}`
|
||||||
|
|
||||||
|
|
||||||
### eq
|
### eq
|
||||||
Return true if the parameters are equal.
|
Returns true if the parameters are equal.
|
||||||
|
|
||||||
e.g.
|
e.g.
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ e.g.
|
||||||
|
|
||||||
|
|
||||||
### first
|
### first
|
||||||
Slices an array to only the first X elements.
|
Slices an array to only the first _N_ elements.
|
||||||
|
|
||||||
Works on [lists](/templates/list/), [taxonomies](/taxonomies/displaying/), [terms](/templates/terms/), [groups](/templates/list/)
|
Works on [lists](/templates/list/), [taxonomies](/taxonomies/displaying/), [terms](/templates/terms/), [groups](/templates/list/)
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ e.g.
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
### last
|
### last
|
||||||
Slices an array to only the last X elements.
|
Slices an array to only the last _N_ elements.
|
||||||
|
|
||||||
Works on [lists](/templates/list/), [taxonomies](/taxonomies/displaying/), [terms](/templates/terms/), [groups](/templates/list/)
|
Works on [lists](/templates/list/), [taxonomies](/taxonomies/displaying/), [terms](/templates/terms/), [groups](/templates/list/)
|
||||||
|
|
||||||
|
@ -88,9 +88,8 @@ e.g.
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
### after
|
### after
|
||||||
Slices an array to only the items after the Xth item. Use this in
|
Slices an array to only the items after the <em>N</em>th item. Use this in combination
|
||||||
combination with `first` use both halves of an array split a item
|
with `first` to use both halves of an array split at item _N_.
|
||||||
X.
|
|
||||||
|
|
||||||
Works on [lists](/templates/list/), [taxonomies](/taxonomies/displaying/), [terms](/templates/terms/), [groups](/templates/list/)
|
Works on [lists](/templates/list/), [taxonomies](/taxonomies/displaying/), [terms](/templates/terms/), [groups](/templates/list/)
|
||||||
|
|
||||||
|
@ -114,7 +113,9 @@ e.g.
|
||||||
|
|
||||||
|
|
||||||
### in
|
### in
|
||||||
Checks if an element is in an array (or slice) and returns a boolean. The elements supported are strings, integers and floats (only float64 will match as expected). In addition, it can also check if a substring exists in a string.
|
Checks if an element is in an array (or slice) and returns a boolean.
|
||||||
|
The elements supported are strings, integers and floats (only float64 will match as expected).
|
||||||
|
In addition, it can also check if a substring exists in a string.
|
||||||
|
|
||||||
e.g.
|
e.g.
|
||||||
|
|
||||||
|
@ -126,9 +127,11 @@ or
|
||||||
|
|
||||||
|
|
||||||
### intersect
|
### intersect
|
||||||
Given two arrays (or slices), this function will return the common elements in the arrays. The elements supported are strings, integers and floats (only float64).
|
Given two arrays (or slices), this function will return the common elements in the arrays.
|
||||||
|
The elements supported are strings, integers and floats (only float64).
|
||||||
|
|
||||||
A useful example of this functionality is a 'similar posts' block. Create a list of links to posts where any of the tags in the current post match any tags in other posts.
|
A useful example of this functionality is a 'similar posts' block.
|
||||||
|
Create a list of links to posts where any of the tags in the current post match any tags in other posts.
|
||||||
|
|
||||||
e.g.
|
e.g.
|
||||||
|
|
||||||
|
@ -146,14 +149,14 @@ e.g.
|
||||||
|
|
||||||
|
|
||||||
### isset
|
### isset
|
||||||
Return true if the parameter is set.
|
Returns true if the parameter is set.
|
||||||
Takes either a slice, array or channel and an index or a map and a key as input.
|
Takes either a slice, array or channel and an index or a map and a key as input.
|
||||||
|
|
||||||
e.g. `{{ if isset .Params "project_url" }} {{ index .Params "project_url" }}{{ end }}`
|
e.g. `{{ if isset .Params "project_url" }} {{ index .Params "project_url" }}{{ end }}`
|
||||||
|
|
||||||
### seq
|
### seq
|
||||||
|
|
||||||
Seq creates a sequence of integers. It's named and used as GNU's seq.
|
Creates a sequence of integers. It's named and used as GNU's seq.
|
||||||
|
|
||||||
Some examples:
|
Some examples:
|
||||||
|
|
||||||
|
@ -164,7 +167,10 @@ Some examples:
|
||||||
* `1 -2` => `1, 0, -1, -2`
|
* `1 -2` => `1, 0, -1, -2`
|
||||||
|
|
||||||
### sort
|
### sort
|
||||||
Sorts maps, arrays and slices, returning a sorted slice. A sorted array of map values will be returned, with the keys eliminated. There are two optional arguments, which are `sortByField` and `sortAsc`. If left blank, sort will sort by keys (for maps) in ascending order.
|
Sorts maps, arrays and slices, returning a sorted slice.
|
||||||
|
A sorted array of map values will be returned, with the keys eliminated.
|
||||||
|
There are two optional arguments, which are `sortByField` and `sortAsc`.
|
||||||
|
If left blank, sort will sort by keys (for maps) in ascending order.
|
||||||
|
|
||||||
Works on [lists](/templates/list/), [taxonomies](/taxonomies/displaying/), [terms](/templates/terms/), [groups](/templates/list/)
|
Works on [lists](/templates/list/), [taxonomies](/taxonomies/displaying/), [terms](/templates/terms/), [groups](/templates/list/)
|
||||||
|
|
||||||
|
@ -321,30 +327,32 @@ e.g., `{{chomp "<p>Blockhead</p>\n"` → `"<p>Blockhead</p>"`
|
||||||
|
|
||||||
|
|
||||||
### dateFormat
|
### dateFormat
|
||||||
Converts the textual representation of the datetime into the other form or returns it of Go `time.Time` type value. These are formatted with the layout string.
|
Converts the textual representation of the datetime into the other form or returns it of Go `time.Time` type value.
|
||||||
|
These are formatted with the layout string.
|
||||||
|
|
||||||
e.g. `{{ dateFormat "Monday, Jan 2, 2006" "2015-01-21" }}` →"Wednesday, Jan 21, 2015"
|
e.g. `{{ dateFormat "Monday, Jan 2, 2006" "2015-01-21" }}` →"Wednesday, Jan 21, 2015"
|
||||||
|
|
||||||
|
|
||||||
### highlight
|
### highlight
|
||||||
Take a string of code and a language, uses Pygments to return the syntax highlighted code in HTML. Used in the [highlight shortcode](/extras/highlighting/).
|
Takes a string of code and a language, uses Pygments to return the syntax highlighted code in HTML.
|
||||||
|
Used in the [highlight shortcode](/extras/highlighting/).
|
||||||
|
|
||||||
|
|
||||||
### lower
|
### lower
|
||||||
Convert all characters in string to lowercase.
|
Converts all characters in string to lowercase.
|
||||||
|
|
||||||
e.g. `{{lower "BatMan"}}` → "batman"
|
e.g. `{{lower "BatMan"}}` → "batman"
|
||||||
|
|
||||||
|
|
||||||
### markdownify
|
### markdownify
|
||||||
|
|
||||||
This will run the string through the Markdown processesor. The result will be declared as "safe" so Go templates will not filter it.
|
Runs the string through the Markdown processesor. The result will be declared as "safe" so Go templates will not filter it.
|
||||||
|
|
||||||
e.g. `{{ .Title | markdownify }}`
|
e.g. `{{ .Title | markdownify }}`
|
||||||
|
|
||||||
|
|
||||||
### replace
|
### replace
|
||||||
Replace all occurences of the search string with the replacement string.
|
Replaces all occurrences of the search string with the replacement string.
|
||||||
|
|
||||||
e.g. `{{ replace "Batman and Robin" "Robin" "Catwoman" }}` → "Batman and Catwoman"
|
e.g. `{{ replace "Batman and Robin" "Robin" "Catwoman" }}` → "Batman and Catwoman"
|
||||||
|
|
||||||
|
@ -407,28 +415,29 @@ CSS or URL context.
|
||||||
|
|
||||||
### slicestr
|
### slicestr
|
||||||
|
|
||||||
Slicing in Slicestr is done by specifying a half-open range with two indices, start and end. 1 and 4 creates a slice including elements 1 through 3.
|
Slicing in `slicestr` is done by specifying a half-open range with two indices, `start` and `end`.
|
||||||
The end index can be omitted, it defaults to the string's length.
|
For example, 1 and 4 creates a slice including elements 1 through 3.
|
||||||
|
The `end` index can be omitted; it defaults to the string's length.
|
||||||
|
|
||||||
e.g.
|
e.g.
|
||||||
|
|
||||||
* `{{slicestr "BatMan" 3}}` → "Man"
|
* `{{slicestr "BatMan" 3}}` → "Man"
|
||||||
* `{{slicestr "BatMan" 0 3}}` → "Bat"
|
* `{{slicestr "BatMan" 0 3}}` → "Bat"
|
||||||
|
|
||||||
### substr
|
### substr
|
||||||
|
|
||||||
Substr extracts parts of a string, beginning at the character at the specified
|
Extracts parts of a string, beginning at the character at the specified
|
||||||
position, and returns the specified number of characters.
|
position, and returns the specified number of characters.
|
||||||
|
|
||||||
It normally takes two parameters: `start` and `length`.
|
It normally takes two parameters: `start` and `length`.
|
||||||
It can also take one parameter: `start`, i.e. `length` is omitted, in which case
|
It can also take one parameter: `start`, i.e. `length` is omitted, in which case
|
||||||
the substring starting from start until the end of the string will be returned.
|
the substring starting from start until the end of the string will be returned.
|
||||||
|
|
||||||
To extract characters from the end of the string, use a negative start number.
|
To extract characters from the end of the string, use a negative start number.
|
||||||
|
|
||||||
In addition, borrowing from the extended behavior described at http://php.net/substr,
|
In addition, borrowing from the extended behavior described at http://php.net/substr,
|
||||||
if `length` is given and is negative, then that many characters will be omitted from
|
if `length` is given and is negative, then that many characters will be omitted from
|
||||||
the end of string.
|
the end of string.
|
||||||
|
|
||||||
e.g.
|
e.g.
|
||||||
|
|
||||||
|
@ -436,26 +445,26 @@ e.g.
|
||||||
* `{{substr "BatMan" 3 3}}` → "Man"
|
* `{{substr "BatMan" 3 3}}` → "Man"
|
||||||
|
|
||||||
### title
|
### title
|
||||||
Convert all characters in string to titlecase.
|
Converts all characters in string to titlecase.
|
||||||
|
|
||||||
e.g. `{{title "BatMan"}}` → "Batman"
|
e.g. `{{title "BatMan"}}` → "Batman"
|
||||||
|
|
||||||
|
|
||||||
### trim
|
### trim
|
||||||
Trim returns a slice of the string with all leading and trailing characters contained in cutset removed.
|
Returns a slice of the string with all leading and trailing characters contained in cutset removed.
|
||||||
|
|
||||||
e.g. `{{ trim "++Batman--" "+-" }}` → "Batman"
|
e.g. `{{ trim "++Batman--" "+-" }}` → "Batman"
|
||||||
|
|
||||||
|
|
||||||
### upper
|
### upper
|
||||||
Convert all characters in string to uppercase.
|
Converts all characters in string to uppercase.
|
||||||
|
|
||||||
e.g. `{{upper "BatMan"}}` → "BATMAN"
|
e.g. `{{upper "BatMan"}}` → "BATMAN"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Urls
|
## URLs
|
||||||
|
|
||||||
### absURL, relURL
|
### absURL, relURL
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ weight: 50
|
||||||
---
|
---
|
||||||
|
|
||||||
The home page of a website is often formatted differently than the other
|
The home page of a website is often formatted differently than the other
|
||||||
pages. In Hugo you can define your own homepage template.
|
pages. In Hugo you can define your own homepage template.
|
||||||
|
|
||||||
Homepage is of the type "node" and have all the [node
|
Homepage is of the type "node" and have all the [node
|
||||||
variables](/templates/variables/) and [site
|
variables](/templates/variables/) and [site
|
||||||
|
|
|
@ -92,9 +92,8 @@ can have different RSS files for each section and taxonomy.
|
||||||
|
|
||||||
## Variables
|
## Variables
|
||||||
|
|
||||||
List pages are of the type "node" and have all the [node
|
List pages are of the type "node" and have all the [node variables](/templates/variables/)
|
||||||
variables](/templates/variables/) and [site
|
and [site variables](/templates/variables/) available to use in the templates.
|
||||||
variables](/templates/variables/) available to use in the templates.
|
|
||||||
|
|
||||||
Taxonomy pages will additionally have:
|
Taxonomy pages will additionally have:
|
||||||
|
|
||||||
|
@ -146,7 +145,7 @@ defined.
|
||||||
|
|
||||||
## Ordering Content
|
## Ordering Content
|
||||||
|
|
||||||
In the case of Hugo each list will render the content based on metadata provided in the [front
|
In the case of Hugo, each list will render the content based on metadata provided in the [front
|
||||||
matter](/content/front-matter/). See [ordering content](/content/ordering/) for more information.
|
matter](/content/front-matter/). See [ordering content](/content/ordering/) for more information.
|
||||||
|
|
||||||
Here are a variety of different ways you can order the content items in
|
Here are a variety of different ways you can order the content items in
|
||||||
|
@ -306,11 +305,11 @@ your list templates:
|
||||||
|
|
||||||
### Reversing Key Order
|
### Reversing Key Order
|
||||||
|
|
||||||
The ordering of the groups is performed by keys in alpha-numeric order (A–Z,
|
The ordering of the groups is performed by keys in alphanumeric order (A–Z,
|
||||||
1–100) and in reverse chronological order (newest first) for dates.
|
1–100) and in reverse chronological order (newest first) for dates.
|
||||||
|
|
||||||
While these are logical defaults, they are not always the desired order. There
|
While these are logical defaults, they are not always the desired order. There
|
||||||
are two different syntaxes to change the order, they both work the same way, so
|
are two different syntaxes to change the order; they both work the same way, so
|
||||||
it’s really just a matter of preference.
|
it’s really just a matter of preference.
|
||||||
|
|
||||||
#### Reverse method
|
#### Reverse method
|
||||||
|
@ -334,7 +333,7 @@ it’s really just a matter of preference.
|
||||||
|
|
||||||
Because Grouping returns a key and a slice of pages, all of the ordering methods listed above are available.
|
Because Grouping returns a key and a slice of pages, all of the ordering methods listed above are available.
|
||||||
|
|
||||||
In this example I’ve ordered the groups in chronological order and the content
|
In this example, I’ve ordered the groups in chronological order and the content
|
||||||
within each group in alphabetical order by title.
|
within each group in alphabetical order by title.
|
||||||
|
|
||||||
{{ range .Data.Pages.GroupByDate "2006-01" "asc" }}
|
{{ range .Data.Pages.GroupByDate "2006-01" "asc" }}
|
||||||
|
@ -352,38 +351,39 @@ within each group in alphabetical order by title.
|
||||||
## Filtering & Limiting Content
|
## Filtering & Limiting Content
|
||||||
|
|
||||||
Sometimes you only want to list a subset of the available content. A common
|
Sometimes you only want to list a subset of the available content. A common
|
||||||
request is to only display “Posts” on the homepage. Using the `where` function
|
request is to only display “Posts” on the homepage. Using the `where` function,
|
||||||
you can do just that.
|
you can do just that.
|
||||||
|
|
||||||
### First
|
### `first`
|
||||||
|
|
||||||
`first` works like the `limit` keyword in SQL. It reduces the array to only the
|
`first` works like the `limit` keyword in SQL. It reduces the array to only the
|
||||||
first X elements. It takes the array and number of elements as input.
|
first _N_ elements. It takes the array and number of elements as input.
|
||||||
|
|
||||||
{{ range first 10 .Data.Pages }}
|
{{ range first 10 .Data.Pages }}
|
||||||
{{ .Render "summary"}}
|
{{ .Render "summary" }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
### Where
|
### `where`
|
||||||
|
|
||||||
`where` works in a similar manner to the `where` keyword in SQL. It selects all
|
`where` works in a similar manner to the `where` keyword in SQL. It selects all
|
||||||
elements of the slice that match the provided field and value. It takes three
|
elements of the slice that match the provided field and value. It takes three
|
||||||
arguments 'array or slice of maps or structs', 'key or field name' and 'match
|
arguments: 'array or slice of maps or structs', 'key or field name' and 'match
|
||||||
value'
|
value'.
|
||||||
|
|
||||||
{{ range where .Data.Pages "Section" "post" }}
|
{{ range where .Data.Pages "Section" "post" }}
|
||||||
{{ .Content}}
|
{{ .Content }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
### First & Where Together
|
### `first` & `where` Together
|
||||||
|
|
||||||
Using both together can be very powerful.
|
Using both together can be very powerful.
|
||||||
|
|
||||||
{{ range first 5 (where .Data.Pages "Section" "post") }}
|
{{ range first 5 (where .Data.Pages "Section" "post") }}
|
||||||
{{ .Content}}
|
{{ .Content }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
If `where` or `first` receives invalid input or a field name that doesn’t exist they will provide an error and stop site generation.
|
If `where` or `first` receives invalid input or a field name that doesn’t exist,
|
||||||
|
it will return an error and stop site generation.
|
||||||
|
|
||||||
These are both template functions and work on not only
|
These are both template functions and work on not only
|
||||||
[lists](/templates/list/), but [taxonomies](/taxonomies/displaying/),
|
[lists](/templates/list/), but [taxonomies](/taxonomies/displaying/),
|
||||||
|
|
|
@ -36,7 +36,7 @@ like good names to use for inclusion in your other templates.
|
||||||
By ensuring that we only reference [variables](/layout/variables/)
|
By ensuring that we only reference [variables](/layout/variables/)
|
||||||
used for both nodes and pages, we can use the same partials for both.
|
used for both nodes and pages, we can use the same partials for both.
|
||||||
|
|
||||||
## Partial vs Template
|
## Partial vs Template
|
||||||
|
|
||||||
Version v0.12 of Hugo introduced the `partial` call inside the template system.
|
Version v0.12 of Hugo introduced the `partial` call inside the template system.
|
||||||
This is a change to the way partials were handled previously inside the
|
This is a change to the way partials were handled previously inside the
|
||||||
|
@ -77,7 +77,7 @@ This footer template is used for [spf13.com](http://spf13.com/):
|
||||||
<div>
|
<div>
|
||||||
<p>
|
<p>
|
||||||
© 2013-14 Steve Francia.
|
© 2013-14 Steve Francia.
|
||||||
<a href="http://creativecommons.org/licenses/by/3.0/" title="Creative Commons Attribution">Some rights reserved</a>;
|
<a href="http://creativecommons.org/licenses/by/3.0/" title="Creative Commons Attribution">Some rights reserved</a>;
|
||||||
please attribute properly and link back. Hosted by <a href="http://servergrove.com">ServerGrove</a>.
|
please attribute properly and link back. Hosted by <a href="http://servergrove.com">ServerGrove</a>.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
@ -90,7 +90,7 @@ This footer template is used for [spf13.com](http://spf13.com/):
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
var ga = document.createElement('script');
|
var ga = document.createElement('script');
|
||||||
ga.src = ('https:' == document.location.protocol ? 'https://ssl' :
|
ga.src = ('https:' == document.location.protocol ? 'https://ssl' :
|
||||||
'http://www') + '.google-analytics.com/ga.js';
|
'http://www') + '.google-analytics.com/ga.js';
|
||||||
ga.setAttribute('async', 'true');
|
ga.setAttribute('async', 'true');
|
||||||
document.documentElement.firstChild.appendChild(ga);
|
document.documentElement.firstChild.appendChild(ga);
|
||||||
|
@ -100,11 +100,11 @@ This footer template is used for [spf13.com](http://spf13.com/):
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
||||||
To reference a partial template stored in a subfolder, e.g. `/layout/partials/post/tag/list.html`, call it this way:
|
To reference a partial template stored in a subfolder, e.g. `/layout/partials/post/tag/list.html`, call it this way:
|
||||||
|
|
||||||
{{ partial "post/tag/list" . }}
|
{{ partial "post/tag/list" . }}
|
||||||
|
|
||||||
Note that the subdirectories you create under /layout/partials can be named whatever you like.
|
Note that the subdirectories you create under /layout/partials can be named whatever you like.
|
||||||
|
|
||||||
**For more examples of referencing these templates, see [single content
|
**For more examples of referencing these templates, see [single content
|
||||||
templates](/templates/content/), [list templates](/templates/list/) and [homepage templates](/templates/homepage/).**
|
templates](/templates/content/), [list templates](/templates/list/) and [homepage templates](/templates/homepage/).**
|
||||||
|
|
|
@ -14,9 +14,9 @@ weight: 90
|
||||||
toc: true
|
toc: true
|
||||||
---
|
---
|
||||||
|
|
||||||
Like all other templates, you can use a single RSS template to generate all of your RSS feeds, or you can create a specific template for each individual feed.
|
Like all other templates, you can use a single RSS template to generate all of your RSS feeds, or you can create a specific template for each individual feed.
|
||||||
|
|
||||||
*Unlike other Hugo templates*, Hugo ships with its own [RSS 2.0 template](#the-embedded-rss-xml:eceb479b7b3b2077408a2878a29e1320). In most cases this will be sufficient, and an RSS template will not need to be provided by the user. But you can provide an rss template if you like, as you can see in the next section.
|
*Unlike other Hugo templates*, Hugo ships with its own [RSS 2.0 template](#the-embedded-rss-xml:eceb479b7b3b2077408a2878a29e1320). In most cases this will be sufficient, and an RSS template will not need to be provided by the user. But you can provide an rss template if you like, as you can see in the next section.
|
||||||
|
|
||||||
RSS pages are of the **type "node"** and have all the [node variables](/layout/variables/) available to use in the templates.
|
RSS pages are of the **type "node"** and have all the [node variables](/layout/variables/) available to use in the templates.
|
||||||
|
|
||||||
|
@ -95,7 +95,7 @@ This is the default RSS template that ships with Hugo. It adheres to the [RSS 2.
|
||||||
|
|
||||||
## Referencing your RSS Feed in `<head>`
|
## Referencing your RSS Feed in `<head>`
|
||||||
|
|
||||||
In your `header.html` template, you can specify your RSS feed in your `<head></head>` tag like this:
|
In your `header.html` template, you can specify your RSS feed in your `<head></head>` tag like this:
|
||||||
|
|
||||||
~~~html
|
~~~html
|
||||||
{{ if .RSSlink }}
|
{{ if .RSSlink }}
|
||||||
|
@ -104,11 +104,11 @@ In your `header.html` template, you can specify your RSS feed in your `<head></h
|
||||||
{{ end }}
|
{{ end }}
|
||||||
~~~
|
~~~
|
||||||
|
|
||||||
... with the autodiscovery link specified by the line with `rel="alternate"`.
|
... with the autodiscovery link specified by the line with `rel="alternate"`.
|
||||||
|
|
||||||
The `.RSSlink` will render the appropriate RSS feed URL for the section, whether it's everything, posts in a section, or a taxonomy.
|
The `.RSSlink` will render the appropriate RSS feed URL for the section, whether it's everything, posts in a section, or a taxonomy.
|
||||||
|
|
||||||
**N.b.**, if you reference your RSS link, be sure to specify the mime type with `type="application/rss+xml"`.
|
**N.b.**, if you reference your RSS link, be sure to specify the mime type with `type="application/rss+xml"`.
|
||||||
|
|
||||||
~~~html
|
~~~html
|
||||||
<a href="{{ .URL }}" type="application/rss+xml" target="_blank">{{ .SomeText }}</a>
|
<a href="{{ .URL }}" type="application/rss+xml" target="_blank">{{ .SomeText }}</a>
|
||||||
|
|
|
@ -55,7 +55,7 @@ compatibility.
|
||||||
|
|
||||||
Everything in the static directory will be copied directly into the final site
|
Everything in the static directory will be copied directly into the final site
|
||||||
when rendered. No structure is provided here to enable complete freedom. It is
|
when rendered. No structure is provided here to enable complete freedom. It is
|
||||||
common to organize the static content into
|
common to organize the static content into:
|
||||||
|
|
||||||
/css
|
/css
|
||||||
/js
|
/js
|
||||||
|
|
|
@ -10,13 +10,13 @@ weight: 40
|
||||||
toc: true
|
toc: true
|
||||||
---
|
---
|
||||||
|
|
||||||
_The following are key concepts for Hugo site customization. Hugo permits you to **supplement or override** any theme template or static file, with files in your working directory._
|
_The following are key concepts for Hugo site customization. Hugo permits you to **supplement or override** any theme template or static file, with files in your working directory._
|
||||||
|
|
||||||
_When you use a theme cloned from its git repository, you do not edit the theme's files directly. Rather, you override them as per the following:_
|
_When you use a theme cloned from its git repository, you do not edit the theme's files directly. Rather, you override them as per the following:_
|
||||||
|
|
||||||
## Replace Static Files
|
## Replace Static Files
|
||||||
|
|
||||||
For including a different file than what the theme ships with. For example, if you would like to use a more recent version of jQuery than what the theme happens to include, simply place an identically-named file in the same relative location but in your working directory.
|
For including a different file than what the theme ships with. For example, if you would like to use a more recent version of jQuery than what the theme happens to include, simply place an identically-named file in the same relative location but in your working directory.
|
||||||
|
|
||||||
For example, if the theme has jQuery 1.6 in:
|
For example, if the theme has jQuery 1.6 in:
|
||||||
|
|
||||||
|
@ -28,17 +28,17 @@ For example, if the theme has jQuery 1.6 in:
|
||||||
|
|
||||||
## Replace a single template file
|
## Replace a single template file
|
||||||
|
|
||||||
Anytime Hugo looks for a matching template, it will first check the working directory before looking in the theme directory. If you would like to modify a template, simply create that template in your local `layouts` directory.
|
Anytime Hugo looks for a matching template, it will first check the working directory before looking in the theme directory. If you would like to modify a template, simply create that template in your local `layouts` directory.
|
||||||
|
|
||||||
In the [template documentation](/templates/overview/) _each different template type explains the rules it uses to determine which template to use_. Read and understand these rules carefully.
|
In the [template documentation](/templates/overview/) _each different template type explains the rules it uses to determine which template to use_. Read and understand these rules carefully.
|
||||||
|
|
||||||
This is especially helpful when the theme creator used [partial templates](/templates/partials/). These partial templates are perfect for easy injection into the theme with minimal maintenance to ensure future compatibility.
|
This is especially helpful when the theme creator used [partial templates](/templates/partials/). These partial templates are perfect for easy injection into the theme with minimal maintenance to ensure future compatibility.
|
||||||
|
|
||||||
For example:
|
For example:
|
||||||
|
|
||||||
/themes/themename/layouts/_default/single.html
|
/themes/themename/layouts/_default/single.html
|
||||||
|
|
||||||
... would be overridden by:
|
... would be overridden by:
|
||||||
|
|
||||||
/layouts/_default/single.html
|
/layouts/_default/single.html
|
||||||
|
|
||||||
|
@ -50,6 +50,6 @@ If the archetype that ships with the theme for a given content type (or all cont
|
||||||
|
|
||||||
## Beware of the default
|
## Beware of the default
|
||||||
|
|
||||||
**Default** is a very powerful force in Hugo... Especially as it pertains to overwriting theme files. If a default is located in the local archetype directory or `/layouts/_default/` directory, it will be used instead of any of the similar files in the theme.
|
**Default** is a very powerful force in Hugo, especially as it pertains to overwriting theme files. If a default is located in the local archetype directory or `/layouts/_default/` directory, it will be used instead of any of the similar files in the theme.
|
||||||
|
|
||||||
It is usually better to override specific files rather than using the default in your working directory.
|
It is usually better to override specific files rather than using the default in your working directory.
|
||||||
|
|
|
@ -192,7 +192,7 @@ The application is added now, and Wercker will be offering you the chance to tri
|
||||||
|
|
||||||
## Adding steps
|
## Adding steps
|
||||||
|
|
||||||
And now we're going to add the steps themselves. First, we go to the "Registry" action in the top menu and then search for "hugo build". The first result is the **Hugo-Build** task, which we select.
|
And now we're going to add the steps themselves. First, we go to the "Registry" action in the top menu and then search for "hugo build". The first result is the **Hugo-Build** task, which we select.
|
||||||
|
|
||||||
![][13]
|
![][13]
|
||||||
|
|
||||||
|
|
|
@ -151,9 +151,9 @@ INFO: 2014/09/29 Using config file: config.toml
|
||||||
INFO: 2014/09/29 syncing from /Users/quoha/Sites/zafta/static/ to /Users/quoha/Sites/zafta/public/
|
INFO: 2014/09/29 syncing from /Users/quoha/Sites/zafta/static/ to /Users/quoha/Sites/zafta/public/
|
||||||
WARN: 2014/09/29 Unable to locate layout: [index.html _default/list.html _default/single.html]
|
WARN: 2014/09/29 Unable to locate layout: [index.html _default/list.html _default/single.html]
|
||||||
WARN: 2014/09/29 Unable to locate layout: [404.html]
|
WARN: 2014/09/29 Unable to locate layout: [404.html]
|
||||||
0 draft content
|
0 draft content
|
||||||
0 future content
|
0 future content
|
||||||
0 pages created
|
0 pages created
|
||||||
0 tags created
|
0 tags created
|
||||||
0 categories created
|
0 categories created
|
||||||
in 2 ms
|
in 2 ms
|
||||||
|
@ -200,9 +200,9 @@ INFO: 2014/09/29 Using config file: /Users/quoha/Sites/zafta/config.toml
|
||||||
INFO: 2014/09/29 syncing from /Users/quoha/Sites/zafta/static/ to /Users/quoha/Sites/zafta/public/
|
INFO: 2014/09/29 syncing from /Users/quoha/Sites/zafta/static/ to /Users/quoha/Sites/zafta/public/
|
||||||
WARN: 2014/09/29 Unable to locate layout: [index.html _default/list.html _default/single.html]
|
WARN: 2014/09/29 Unable to locate layout: [index.html _default/list.html _default/single.html]
|
||||||
WARN: 2014/09/29 Unable to locate layout: [404.html]
|
WARN: 2014/09/29 Unable to locate layout: [404.html]
|
||||||
0 draft content
|
0 draft content
|
||||||
0 future content
|
0 future content
|
||||||
0 pages created
|
0 pages created
|
||||||
0 tags created
|
0 tags created
|
||||||
0 categories created
|
0 categories created
|
||||||
in 2 ms
|
in 2 ms
|
||||||
|
@ -333,9 +333,9 @@ INFO: 2014/09/29 Using config file: /Users/quoha/Sites/zafta/config.toml
|
||||||
INFO: 2014/09/29 syncing from /Users/quoha/Sites/zafta/themes/zafta/static/ to /Users/quoha/Sites/zafta/public/
|
INFO: 2014/09/29 syncing from /Users/quoha/Sites/zafta/themes/zafta/static/ to /Users/quoha/Sites/zafta/public/
|
||||||
INFO: 2014/09/29 syncing from /Users/quoha/Sites/zafta/static/ to /Users/quoha/Sites/zafta/public/
|
INFO: 2014/09/29 syncing from /Users/quoha/Sites/zafta/static/ to /Users/quoha/Sites/zafta/public/
|
||||||
WARN: 2014/09/29 Unable to locate layout: [404.html theme/404.html]
|
WARN: 2014/09/29 Unable to locate layout: [404.html theme/404.html]
|
||||||
0 draft content
|
0 draft content
|
||||||
0 future content
|
0 future content
|
||||||
0 pages created
|
0 pages created
|
||||||
0 tags created
|
0 tags created
|
||||||
0 categories created
|
0 categories created
|
||||||
in 2 ms
|
in 2 ms
|
||||||
|
@ -455,9 +455,9 @@ INFO: 2014/09/29 Using config file: /Users/quoha/Sites/zafta/config.toml
|
||||||
INFO: 2014/09/29 syncing from /Users/quoha/Sites/zafta/themes/zafta/static/ to /Users/quoha/Sites/zafta/public/
|
INFO: 2014/09/29 syncing from /Users/quoha/Sites/zafta/themes/zafta/static/ to /Users/quoha/Sites/zafta/public/
|
||||||
INFO: 2014/09/29 syncing from /Users/quoha/Sites/zafta/static/ to /Users/quoha/Sites/zafta/public/
|
INFO: 2014/09/29 syncing from /Users/quoha/Sites/zafta/static/ to /Users/quoha/Sites/zafta/public/
|
||||||
WARN: 2014/09/29 Unable to locate layout: [404.html theme/404.html]
|
WARN: 2014/09/29 Unable to locate layout: [404.html theme/404.html]
|
||||||
0 draft content
|
0 draft content
|
||||||
0 future content
|
0 future content
|
||||||
0 pages created
|
0 pages created
|
||||||
0 tags created
|
0 tags created
|
||||||
0 categories created
|
0 categories created
|
||||||
in 2 ms
|
in 2 ms
|
||||||
|
@ -469,9 +469,9 @@ INFO: 2014/09/29 File System Event: ["/Users/quoha/Sites/zafta/themes/zafta/layo
|
||||||
Change detected, rebuilding site
|
Change detected, rebuilding site
|
||||||
|
|
||||||
WARN: 2014/09/29 Unable to locate layout: [404.html theme/404.html]
|
WARN: 2014/09/29 Unable to locate layout: [404.html theme/404.html]
|
||||||
0 draft content
|
0 draft content
|
||||||
0 future content
|
0 future content
|
||||||
0 pages created
|
0 pages created
|
||||||
0 tags created
|
0 tags created
|
||||||
0 categories created
|
0 categories created
|
||||||
in 1 ms
|
in 1 ms
|
||||||
|
@ -493,12 +493,12 @@ Right now, that page is empty because we don't have any content and we don't hav
|
||||||
|
|
||||||
```
|
```
|
||||||
$ vi themes/zafta/layouts/index.html
|
$ vi themes/zafta/layouts/index.html
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<body>
|
<body>
|
||||||
<p>hugo says hello!</p>
|
<p>hugo says hello!</p>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
:wq
|
:wq
|
||||||
|
|
||||||
$
|
$
|
||||||
|
@ -512,9 +512,9 @@ INFO: 2014/09/29 Using config file: /Users/quoha/Sites/zafta/config.toml
|
||||||
INFO: 2014/09/29 syncing from /Users/quoha/Sites/zafta/themes/zafta/static/ to /Users/quoha/Sites/zafta/public/
|
INFO: 2014/09/29 syncing from /Users/quoha/Sites/zafta/themes/zafta/static/ to /Users/quoha/Sites/zafta/public/
|
||||||
INFO: 2014/09/29 syncing from /Users/quoha/Sites/zafta/static/ to /Users/quoha/Sites/zafta/public/
|
INFO: 2014/09/29 syncing from /Users/quoha/Sites/zafta/static/ to /Users/quoha/Sites/zafta/public/
|
||||||
WARN: 2014/09/29 Unable to locate layout: [404.html theme/404.html]
|
WARN: 2014/09/29 Unable to locate layout: [404.html theme/404.html]
|
||||||
0 draft content
|
0 draft content
|
||||||
0 future content
|
0 future content
|
||||||
0 pages created
|
0 pages created
|
||||||
0 tags created
|
0 tags created
|
||||||
0 categories created
|
0 categories created
|
||||||
in 2 ms
|
in 2 ms
|
||||||
|
@ -522,11 +522,11 @@ in 2 ms
|
||||||
$ find public -type f -name '*.html' | xargs ls -l
|
$ find public -type f -name '*.html' | xargs ls -l
|
||||||
-rw-r--r-- 1 quoha staff 78 Sep 29 21:26 public/index.html
|
-rw-r--r-- 1 quoha staff 78 Sep 29 21:26 public/index.html
|
||||||
|
|
||||||
$ cat public/index.html
|
$ cat public/index.html
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<body>
|
<body>
|
||||||
<p>hugo says hello!</p>
|
<p>hugo says hello!</p>
|
||||||
</html>
|
</html>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -535,15 +535,15 @@ $ cat public/index.html
|
||||||
Note: If you're running the server with the `--watch` option, you'll see different content in the file:
|
Note: If you're running the server with the `--watch` option, you'll see different content in the file:
|
||||||
|
|
||||||
```
|
```
|
||||||
$ cat public/index.html
|
$ cat public/index.html
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<body>
|
<body>
|
||||||
<p>hugo says hello!</p>
|
<p>hugo says hello!</p>
|
||||||
<script>document.write('<script src="http://'
|
<script>document.write('<script src="http://'
|
||||||
+ (location.host || 'localhost').split(':')[0]
|
+ (location.host || 'localhost').split(':')[0]
|
||||||
+ ':1313/livereload.js?mindelay=10"></'
|
+ ':1313/livereload.js?mindelay=10"></'
|
||||||
+ 'script>')</script></body>
|
+ 'script>')</script></body>
|
||||||
</html>
|
</html>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -605,7 +605,7 @@ total 16
|
||||||
-rw-r--r-- 1 quoha staff 104 Sep 29 21:54 first.md
|
-rw-r--r-- 1 quoha staff 104 Sep 29 21:54 first.md
|
||||||
-rw-r--r-- 1 quoha staff 105 Sep 29 21:57 second.md
|
-rw-r--r-- 1 quoha staff 105 Sep 29 21:57 second.md
|
||||||
|
|
||||||
$ cat content/post/first.md
|
$ cat content/post/first.md
|
||||||
+++
|
+++
|
||||||
Categories = []
|
Categories = []
|
||||||
Description = ""
|
Description = ""
|
||||||
|
@ -616,7 +616,7 @@ title = "first"
|
||||||
+++
|
+++
|
||||||
my first post
|
my first post
|
||||||
|
|
||||||
$ cat content/post/second.md
|
$ cat content/post/second.md
|
||||||
+++
|
+++
|
||||||
Categories = []
|
Categories = []
|
||||||
Description = ""
|
Description = ""
|
||||||
|
@ -640,9 +640,9 @@ INFO: 2014/09/29 syncing from /Users/quoha/Sites/zafta/themes/zafta/static/ to /
|
||||||
INFO: 2014/09/29 syncing from /Users/quoha/Sites/zafta/static/ to /Users/quoha/Sites/zafta/public/
|
INFO: 2014/09/29 syncing from /Users/quoha/Sites/zafta/static/ to /Users/quoha/Sites/zafta/public/
|
||||||
INFO: 2014/09/29 found taxonomies: map[string]string{"category":"categories", "tag":"tags"}
|
INFO: 2014/09/29 found taxonomies: map[string]string{"category":"categories", "tag":"tags"}
|
||||||
WARN: 2014/09/29 Unable to locate layout: [404.html theme/404.html]
|
WARN: 2014/09/29 Unable to locate layout: [404.html theme/404.html]
|
||||||
0 draft content
|
0 draft content
|
||||||
0 future content
|
0 future content
|
||||||
2 pages created
|
2 pages created
|
||||||
0 tags created
|
0 tags created
|
||||||
0 categories created
|
0 categories created
|
||||||
in 4 ms
|
in 4 ms
|
||||||
|
@ -675,7 +675,7 @@ There are three other types of templates: partials, content views, and terms. We
|
||||||
The home page will contain a list of posts. Let's update its template to add the posts that we just created. The logic in the template will run every time we build the site.
|
The home page will contain a list of posts. Let's update its template to add the posts that we just created. The logic in the template will run every time we build the site.
|
||||||
|
|
||||||
```
|
```
|
||||||
$ vi themes/zafta/layouts/index.html
|
$ vi themes/zafta/layouts/index.html
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<body>
|
<body>
|
||||||
|
@ -713,26 +713,26 @@ INFO: 2014/09/29 syncing from /Users/quoha/Sites/zafta/themes/zafta/static/ to /
|
||||||
INFO: 2014/09/29 syncing from /Users/quoha/Sites/zafta/static/ to /Users/quoha/Sites/zafta/public/
|
INFO: 2014/09/29 syncing from /Users/quoha/Sites/zafta/static/ to /Users/quoha/Sites/zafta/public/
|
||||||
INFO: 2014/09/29 found taxonomies: map[string]string{"tag":"tags", "category":"categories"}
|
INFO: 2014/09/29 found taxonomies: map[string]string{"tag":"tags", "category":"categories"}
|
||||||
WARN: 2014/09/29 Unable to locate layout: [404.html theme/404.html]
|
WARN: 2014/09/29 Unable to locate layout: [404.html theme/404.html]
|
||||||
0 draft content
|
0 draft content
|
||||||
0 future content
|
0 future content
|
||||||
2 pages created
|
2 pages created
|
||||||
0 tags created
|
0 tags created
|
||||||
0 categories created
|
0 categories created
|
||||||
in 4 ms
|
in 4 ms
|
||||||
$ find public -type f -name '*.html' | xargs ls -l
|
$ find public -type f -name '*.html' | xargs ls -l
|
||||||
-rw-r--r-- 1 quoha staff 94 Sep 29 22:23 public/index.html
|
-rw-r--r-- 1 quoha staff 94 Sep 29 22:23 public/index.html
|
||||||
-rw-r--r-- 1 quoha staff 0 Sep 29 22:23 public/post/first/index.html
|
-rw-r--r-- 1 quoha staff 0 Sep 29 22:23 public/post/first/index.html
|
||||||
-rw-r--r-- 1 quoha staff 0 Sep 29 22:23 public/post/index.html
|
-rw-r--r-- 1 quoha staff 0 Sep 29 22:23 public/post/index.html
|
||||||
-rw-r--r-- 1 quoha staff 0 Sep 29 22:23 public/post/second/index.html
|
-rw-r--r-- 1 quoha staff 0 Sep 29 22:23 public/post/second/index.html
|
||||||
$ cat public/index.html
|
$ cat public/index.html
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<h1>second</h1>
|
<h1>second</h1>
|
||||||
|
|
||||||
<h1>first</h1>
|
<h1>first</h1>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
$
|
$
|
||||||
|
@ -764,7 +764,7 @@ Please see the Hugo documentation on template rendering for all the details on d
|
||||||
#### Update the Template File
|
#### Update the Template File
|
||||||
|
|
||||||
```
|
```
|
||||||
$ vi themes/zafta/layouts/_default/single.html
|
$ vi themes/zafta/layouts/_default/single.html
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
|
@ -790,9 +790,9 @@ INFO: 2014/09/29 syncing from /Users/quoha/Sites/zafta/themes/zafta/static/ to /
|
||||||
INFO: 2014/09/29 syncing from /Users/quoha/Sites/zafta/static/ to /Users/quoha/Sites/zafta/public/
|
INFO: 2014/09/29 syncing from /Users/quoha/Sites/zafta/static/ to /Users/quoha/Sites/zafta/public/
|
||||||
INFO: 2014/09/29 found taxonomies: map[string]string{"tag":"tags", "category":"categories"}
|
INFO: 2014/09/29 found taxonomies: map[string]string{"tag":"tags", "category":"categories"}
|
||||||
WARN: 2014/09/29 Unable to locate layout: [404.html theme/404.html]
|
WARN: 2014/09/29 Unable to locate layout: [404.html theme/404.html]
|
||||||
0 draft content
|
0 draft content
|
||||||
0 future content
|
0 future content
|
||||||
2 pages created
|
2 pages created
|
||||||
0 tags created
|
0 tags created
|
||||||
0 categories created
|
0 categories created
|
||||||
in 4 ms
|
in 4 ms
|
||||||
|
@ -803,7 +803,7 @@ $ find public -type f -name '*.html' | xargs ls -l
|
||||||
-rw-r--r-- 1 quoha staff 0 Sep 29 22:40 public/post/index.html
|
-rw-r--r-- 1 quoha staff 0 Sep 29 22:40 public/post/index.html
|
||||||
-rw-r--r-- 1 quoha staff 128 Sep 29 22:40 public/post/second/index.html
|
-rw-r--r-- 1 quoha staff 128 Sep 29 22:40 public/post/second/index.html
|
||||||
|
|
||||||
$ cat public/post/first/index.html
|
$ cat public/post/first/index.html
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
|
@ -816,7 +816,7 @@ $ cat public/post/first/index.html
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
||||||
$ cat public/post/second/index.html
|
$ cat public/post/second/index.html
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
|
@ -859,9 +859,9 @@ INFO: 2014/09/29 syncing from /Users/quoha/Sites/zafta/themes/zafta/static/ to /
|
||||||
INFO: 2014/09/29 syncing from /Users/quoha/Sites/zafta/static/ to /Users/quoha/Sites/zafta/public/
|
INFO: 2014/09/29 syncing from /Users/quoha/Sites/zafta/static/ to /Users/quoha/Sites/zafta/public/
|
||||||
INFO: 2014/09/29 found taxonomies: map[string]string{"tag":"tags", "category":"categories"}
|
INFO: 2014/09/29 found taxonomies: map[string]string{"tag":"tags", "category":"categories"}
|
||||||
WARN: 2014/09/29 Unable to locate layout: [404.html theme/404.html]
|
WARN: 2014/09/29 Unable to locate layout: [404.html theme/404.html]
|
||||||
0 draft content
|
0 draft content
|
||||||
0 future content
|
0 future content
|
||||||
2 pages created
|
2 pages created
|
||||||
0 tags created
|
0 tags created
|
||||||
0 categories created
|
0 categories created
|
||||||
in 4 ms
|
in 4 ms
|
||||||
|
@ -872,15 +872,15 @@ $ find public -type f -name '*.html' | xargs ls -l
|
||||||
-rw-r--r-- 1 quoha staff 0 Sep 29 22:44 public/post/index.html
|
-rw-r--r-- 1 quoha staff 0 Sep 29 22:44 public/post/index.html
|
||||||
-rw-r--r-- 1 quoha staff 128 Sep 29 22:44 public/post/second/index.html
|
-rw-r--r-- 1 quoha staff 128 Sep 29 22:44 public/post/second/index.html
|
||||||
|
|
||||||
$ cat public/index.html
|
$ cat public/index.html
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<h1><a href="/post/second/">second</a></h1>
|
<h1><a href="/post/second/">second</a></h1>
|
||||||
|
|
||||||
<h1><a href="/post/first/">first</a></h1>
|
<h1><a href="/post/first/">first</a></h1>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
||||||
|
@ -907,7 +907,7 @@ Let's add an "about" page and display it at the top level (as opposed to a sub-l
|
||||||
The default in Hugo is to use the directory structure of the content/ directory to guide the location of the generated html in the public/ directory. Let's verify that by creating an "about" page at the top level:
|
The default in Hugo is to use the directory structure of the content/ directory to guide the location of the generated html in the public/ directory. Let's verify that by creating an "about" page at the top level:
|
||||||
|
|
||||||
```
|
```
|
||||||
$ vi content/about.md
|
$ vi content/about.md
|
||||||
+++
|
+++
|
||||||
title = "about"
|
title = "about"
|
||||||
description = "about this site"
|
description = "about this site"
|
||||||
|
|
|
@ -102,7 +102,7 @@ The final step in creating the blog is to add some actual blog posts. To do this
|
||||||
title: "Just another sample post"
|
title: "Just another sample post"
|
||||||
date: "2014-03-29"
|
date: "2014-03-29"
|
||||||
description: "This should be a more useful description"
|
description: "This should be a more useful description"
|
||||||
categories:
|
categories:
|
||||||
- "hugo"
|
- "hugo"
|
||||||
- "fun"
|
- "fun"
|
||||||
- "test"
|
- "test"
|
||||||
|
@ -131,7 +131,7 @@ To get this properly set up, we will execute a series of commands at the termina
|
||||||
git add .
|
git add .
|
||||||
git commit -m "INIT: initial commit on gh-pages branch"
|
git commit -m "INIT: initial commit on gh-pages branch"
|
||||||
|
|
||||||
# Push to remote gh-pages branch
|
# Push to remote gh-pages branch
|
||||||
git push origin gh-pages
|
git push origin gh-pages
|
||||||
|
|
||||||
# Return to master branch
|
# Return to master branch
|
||||||
|
@ -159,12 +159,12 @@ To get this properly set up, we will execute a series of commands at the termina
|
||||||
# Push the public subtree to the gh-pages branch
|
# Push the public subtree to the gh-pages branch
|
||||||
git subtree push --prefix=public git@github.com:spencerlyon2/hugo_gh_blog.git gh-pages
|
git subtree push --prefix=public git@github.com:spencerlyon2/hugo_gh_blog.git gh-pages
|
||||||
|
|
||||||
After executing these commands and waiting for the GitHub servers to update, the website we just created was live at [http://spencerlyon2.github.io/hugo_gh_blog](http://spencerlyon2.github.io/hugo_gh_blog).
|
After executing these commands and waiting for the GitHub servers to update, the website we just created was live at [http://spencerlyon2.github.io/hugo_gh_blog](http://spencerlyon2.github.io/hugo_gh_blog).
|
||||||
|
|
||||||
### `deploy.sh`
|
### `deploy.sh`
|
||||||
|
|
||||||
Now, as you add new posts to your blog, you will follow steps that look something like the following:
|
Now, as you add new posts to your blog, you will follow steps that look something like the following:
|
||||||
|
|
||||||
* Create the Markdown source for the new post within the `content/posts` directory
|
* Create the Markdown source for the new post within the `content/posts` directory
|
||||||
* Preview your work by running Hugo in server mode with `hugo server --watch`
|
* Preview your work by running Hugo in server mode with `hugo server --watch`
|
||||||
* Run Hugo not in server mode so that the generated urls will be correct for the website
|
* Run Hugo not in server mode so that the generated urls will be correct for the website
|
||||||
|
@ -176,7 +176,7 @@ The first two items in the previous list are simply a way to conveniently previe
|
||||||
|
|
||||||
**Note:**
|
**Note:**
|
||||||
|
|
||||||
The first command `hugo` assumes you are running with all the default settings.
|
The first command `hugo` assumes you are running with all the default settings.
|
||||||
|
|
||||||
To use a theme, make sure to specify it with `-t ThemeName` instead (or include the theme in the config file).
|
To use a theme, make sure to specify it with `-t ThemeName` instead (or include the theme in the config file).
|
||||||
|
|
||||||
|
@ -189,22 +189,22 @@ To build all draft posts *(If you only have drafts, no site will be generated)*
|
||||||
**Deploy.sh:**
|
**Deploy.sh:**
|
||||||
|
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
echo -e "\033[0;32mDeploying updates to GitHub...\033[0m"
|
echo -e "\033[0;32mDeploying updates to GitHub...\033[0m"
|
||||||
|
|
||||||
# Build the project.
|
# Build the project.
|
||||||
hugo
|
hugo
|
||||||
|
|
||||||
# Add changes to git.
|
# Add changes to git.
|
||||||
git add -A
|
git add -A
|
||||||
|
|
||||||
# Commit changes.
|
# Commit changes.
|
||||||
msg="rebuilding site `date`"
|
msg="rebuilding site `date`"
|
||||||
if [ $# -eq 1 ]
|
if [ $# -eq 1 ]
|
||||||
then msg="$1"
|
then msg="$1"
|
||||||
fi
|
fi
|
||||||
git commit -m "$msg"
|
git commit -m "$msg"
|
||||||
|
|
||||||
# Push source and build repos.
|
# Push source and build repos.
|
||||||
git push origin master
|
git push origin master
|
||||||
git subtree push --prefix=public git@github.com:spencerlyon2/hugo_gh_blog.git gh-pages
|
git subtree push --prefix=public git@github.com:spencerlyon2/hugo_gh_blog.git gh-pages
|
||||||
|
@ -220,7 +220,7 @@ There's another approach:
|
||||||
2. Create an orphaned `gh-pages` branch. (See [here](https://help.github.com/articles/creating-project-pages-manually/) for more information.)
|
2. Create an orphaned `gh-pages` branch. (See [here](https://help.github.com/articles/creating-project-pages-manually/) for more information.)
|
||||||
3. Follow the instructions below.
|
3. Follow the instructions below.
|
||||||
|
|
||||||
So, assuming you have your `gh-pages` set up, and `master` has a commit with some content you want to publish:
|
So, assuming you have your `gh-pages` set up, and `master` has a commit with some content you want to publish:
|
||||||
|
|
||||||
```
|
```
|
||||||
# Fetch the deployment script into the root of your source tree, make it executable.
|
# Fetch the deployment script into the root of your source tree, make it executable.
|
||||||
|
@ -262,7 +262,7 @@ Step by step:
|
||||||
|
|
||||||
echo -e "\033[0;32mDeploying updates to GitHub...\033[0m"
|
echo -e "\033[0;32mDeploying updates to GitHub...\033[0m"
|
||||||
|
|
||||||
# Build the project.
|
# Build the project.
|
||||||
hugo # if using a theme, replace by `hugo -t <yourtheme>`
|
hugo # if using a theme, replace by `hugo -t <yourtheme>`
|
||||||
|
|
||||||
# Go To Public folder
|
# Go To Public folder
|
||||||
|
|
|
@ -11,6 +11,6 @@
|
||||||
<td>
|
<td>
|
||||||
<a href="{{$url}}{{.Name | urlize }}"> {{.Name}}</a>
|
<a href="{{$url}}{{.Name | urlize }}"> {{.Name}}</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
</table>
|
</table>
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
<a href="{{ .Params.sitelink }}"><img class="img-responsive img-rounded" style="width:100%;" src="{{ .Params.thumbnail }}" alt="{{ .Description }}"></a>
|
<a href="{{ .Params.sitelink }}"><img class="img-responsive img-rounded" style="width:100%;" src="{{ .Params.thumbnail }}" alt="{{ .Description }}"></a>
|
||||||
<h4>
|
<h4>
|
||||||
<a href="{{ .Params.sitelink }}">{{ .Title }}</a>
|
<a href="{{ .Params.sitelink }}">{{ .Title }}</a>
|
||||||
{{ if (isset .Params "sourcelink") }}
|
{{ if (isset .Params "sourcelink") }}
|
||||||
<a href="{{ .Params.sourcelink }}" class="small pull-right">source</a>
|
<a href="{{ .Params.sourcelink }}" class="small pull-right">source</a>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
</h4>
|
</h4>
|
||||||
|
|
Loading…
Reference in a new issue