Add highlighting of code in documentation and clean up a bunch of the docs.

This commit is contained in:
spf13 2014-01-10 21:19:19 -05:00
parent 13b5c10dd7
commit 2ff108fcb7
25 changed files with 670 additions and 558 deletions

View file

@ -11,8 +11,8 @@ If you want to be added to this page please send a [pull request](https://github
| **Site** | **Source** | **License** | | **Site** | **Source** | **License** |
| -------------------------------------------- | ----------------------------------------------------- | -----------: | | ------------------------------------------------ | ----------------------------------------------------- | -----------: |
| [hugo](http://hugo.spf13.com) | [source](http://github.com/spf13/hugo/docs) | SIMPL | | [hugo](http://hugo.spf13.com) | [source](http://github.com/spf13/hugo/docs) | SIMPL |
| [spf13](http://spf13.com) | [source](http://github.com/spf13/spf13.com) | MIT | | [spf13](http://spf13.com) | [source](http://github.com/spf13/spf13.com) | MIT |
| [Chimera Art Space](http://chimeraarts.org) | [source](https://github.com/chimera/chimeraarts.org) | CC-SA | | [Chimera Art Space](http://chimeraarts.org) | [source](https://github.com/chimera/chimeraarts.org) | CC-SA |

View file

@ -7,28 +7,28 @@ groups_weight: 10
Hugo has two mailing lists: Hugo has two mailing lists:
### Announcements ## Announcements
Very low traffic. Only releases will be emailed here. Very low traffic. Only releases will be emailed here.
https://groups.google.com/forum/#!forum/hugo-announce https://groups.google.com/forum/#!forum/hugo-announce
### Discussion ## Discussion
For all questions and discussions: For all questions and discussions:
https://groups.google.com/forum/#!forum/hugo-discuss https://groups.google.com/forum/#!forum/hugo-discuss
# Other Resources # Other Resources
### GoNuts ## GoNuts
For general go questions or discussion please refer to the go mailing list. For general go questions or discussion please refer to the go mailing list.
https://groups.google.com/forum/#!forum/golang-nuts https://groups.google.com/forum/#!forum/golang-nuts
### Github Issues ## Github Issues
https://github.com/spf13/hugo/issues https://github.com/spf13/hugo/issues
### Twitter ## Twitter
Hugo doesn't have it's own twitter handle, but feel free to tweet [@spf13](http://twitter.com/spf13). Hugo doesn't have it's own twitter handle, but feel free to tweet [@spf13](http://twitter.com/spf13).

View file

@ -11,34 +11,36 @@ Somethings are better shown than explained. The following is a very basic exampl
**mysite/project/nitro.md <- http://mysite.com/project/nitro.html** **mysite/project/nitro.md <- http://mysite.com/project/nitro.html**
--- {{% highlight yaml %}}
Title: "Nitro : A quick and simple profiler for golang" ---
Description: "" Title: "Nitro : A quick and simple profiler for golang"
Keywords: [ "Development", "golang", "profiling" ] Description: ""
Tags: [ "Development", "golang", "profiling" ] Keywords: [ "Development", "golang", "profiling" ]
date: "2013-06-19" Tags: [ "Development", "golang", "profiling" ]
Topics: [ "Development", "GoLang" ] date: "2013-06-19"
Slug: "nitro" Topics: [ "Development", "GoLang" ]
project_url: "http://github.com/spf13/nitro" Slug: "nitro"
--- project_url: "http://github.com/spf13/nitro"
---
# Nitro # Nitro
Quick and easy performance analyzer library for golang. Quick and easy performance analyzer library for golang.
## Overview ## Overview
Nitro is a quick and easy performance analyzer library for golang. Nitro is a quick and easy performance analyzer library for golang.
It is useful for comparing A/B against different drafts of functions It is useful for comparing A/B against different drafts of functions
or different functions. or different functions.
## Implementing Nitro ## Implementing Nitro
Using Nitro is simple. First use go get to install the latest version Using Nitro is simple. First use go get to install the latest version
of the library. of the library.
$ go get github.com/spf13/nitro $ go get github.com/spf13/nitro
Next include nitro in your application. Next include nitro in your application.
{{% /highlight %}}

View file

@ -17,36 +17,41 @@ Supported formats: <br>
### YAML Example ### YAML Example
--- {{% highlight yaml %}}
title: "spf13-vim 3.0 release and new website" ---
description: "spf13-vim is a cross platform distribution of vim plugins and resources for Vim." title: "spf13-vim 3.0 release and new website"
tags: [ ".vimrc", "plugins", "spf13-vim", "vim" ] description: "spf13-vim is a cross platform distribution of vim plugins and resources for Vim."
date: "2012-04-06" tags: [ ".vimrc", "plugins", "spf13-vim", "vim" ]
categories: date: "2012-04-06"
- "Development" categories:
- "VIM" - "Development"
slug: "spf13-vim-3-0-release-and-new-website" - "VIM"
--- slug: "spf13-vim-3-0-release-and-new-website"
Content of the file goes Here ---
Content of the file goes Here
{{% /highlight %}}
### TOML Example ### TOML Example
+++ {{% highlight yaml %}}
title = "spf13-vim 3.0 release and new website" +++
description = "spf13-vim is a cross platform distribution of vim plugins and resources for Vim." title = "spf13-vim 3.0 release and new website"
tags = [ ".vimrc", "plugins", "spf13-vim", "vim" ] description = "spf13-vim is a cross platform distribution of vim plugins and resources for Vim."
date = "2012-04-06" tags = [ ".vimrc", "plugins", "spf13-vim", "vim" ]
categories = [ date = "2012-04-06"
"Development", categories = [
"VIM" "Development",
] "VIM"
slug = "spf13-vim-3-0-release-and-new-website" ]
+++ slug = "spf13-vim-3-0-release-and-new-website"
Content of the file goes Here +++
Content of the file goes Here
{{% /highlight %}}
### JSON Example ### JSON Example
{ {{% highlight json %}}
{
"title": "spf13-vim 3.0 release and new website", "title": "spf13-vim 3.0 release and new website",
"description": "spf13-vim is a cross platform distribution of vim plugins and resources for Vim.", "description": "spf13-vim is a cross platform distribution of vim plugins and resources for Vim.",
"tags": [ ".vimrc", "plugins", "spf13-vim", "vim" ], "tags": [ ".vimrc", "plugins", "spf13-vim", "vim" ],
@ -56,31 +61,33 @@ Supported formats: <br>
"VIM" "VIM"
], ],
"slug": "spf13-vim-3-0-release-and-new-website", "slug": "spf13-vim-3-0-release-and-new-website",
} }
Content of the file goes Here Content of the file goes Here
{{% /highlight %}}
### Variables ## Variables
There are a few predefined variables that Hugo is aware of and utilizes. The user can also create There are a few predefined variables that Hugo is aware of and utilizes. The user can also create
any variable they want to. These will be placed into the `.Params` variable available to the templates. any variable they want to. These will be placed into the `.Params` variable available to the templates.
**Field names are case insensitive.** **Field names are case insensitive.**
#### Required ### Required
**title** The title for the content. <br> * **title** The title for the content
**description** The description for the content.<br> * **description** The description for the content
**date** The date the content will be sorted by.<br> * **date** The date the content will be sorted by
**indexes** These will use the field name of the plural form of the index (see tags and categories above) * **indexes** These will use the field name of the plural form of the index (see tags and categories above)
#### Optional ### Optional
**redirect** Mark the post as a redirect post<br> * **redirect** Mark the post as a redirect post
**draft** If true the content will not be rendered unless `hugo` is called with -d<br> * **draft** If true the content will not be rendered unless hugo is called with --build-drafts
**type** The type of the content (will be derived from the directory automatically if unset).<br> * **type** The type of the content (will be derived from the directory automatically if unset)
**markup** (Experimental) Specify "rst" for reStructuredText (requires * **markup** (Experimental) Specify "rst" for reStructuredText (requires
`rst2html`,) or "md" (default) for the Markdown.<br> `rst2html`,) or "md" (default) for the Markdown
**slug** The token to appear in the tail of the url.<br> * **slug** The token to appear in the tail of the url
*or*<br> *or*<br>
**url** The full path to the content from the web root.<br> * **url** The full path to the content from the web root.<br>
*If neither is present the filename will be used.*
*If neither slug or url is present the filename will be used.*

View file

@ -10,7 +10,7 @@ In Hugo you have a good degree of control of how your content can be ordered.
By default, content is ordered by weight, then by date with the most recent date first. By default, content is ordered by weight, then by date with the most recent date first.
_Both the date and weight fields are optional._ _Both the date and weight fields are optional._
Unweighted pages appear at the end of the list. Unweighted pages appear at the end of the list.
If no weights are provided (or if weights are the same) date will be used to sort. If neither are provided If no weights are provided (or if weights are the same) date will be used to sort. If neither are provided
@ -29,50 +29,60 @@ Alternative sorting is also available to order content by date (ignoring weight)
## Order by Weight -> Date (default) ## Order by Weight -> Date (default)
{{ range .Data.Pages }} {{% highlight html %}}
<li> {{ range .Data.Pages }}
<a href="{{ .Permalink }}">{{ .Title }}</a> <li>
<div class="meta">{{ .Date.Format "Mon, Jan 2, 2006" }}</div> <a href="{{ .Permalink }}">{{ .Title }}</a>
</li> <div class="meta">{{ .Date.Format "Mon, Jan 2, 2006" }}</div>
{{ end }} </li>
{{ end }}
{{% /highlight %}}
## Order by Weight -> Date ## Order by Weight -> Date
{{ range .Data.Pages.ByWeight }} {{% highlight html %}}
<li> {{ range .Data.Pages.ByWeight }}
<a href="{{ .Permalink }}">{{ .Title }}</a> <li>
<div class="meta">{{ .Date.Format "Mon, Jan 2, 2006" }}</div> <a href="{{ .Permalink }}">{{ .Title }}</a>
</li> <div class="meta">{{ .Date.Format "Mon, Jan 2, 2006" }}</div>
{{ end }} </li>
{{ end }}
{{% /highlight %}}
## Order by Date ## Order by Date
{{ range .Data.Pages.ByDate }} {{% highlight html %}}
<li> {{ range .Data.Pages.ByDate }}
<a href="{{ .Permalink }}">{{ .Title }}</a> <li>
<div class="meta">{{ .Date.Format "Mon, Jan 2, 2006" }}</div> <a href="{{ .Permalink }}">{{ .Title }}</a>
</li> <div class="meta">{{ .Date.Format "Mon, Jan 2, 2006" }}</div>
{{ end }} </li>
{{ end }}
{{% /highlight %}}
## Order by Length ## Order by Length
{{ range .Data.Pages.ByLength }} {{% highlight html %}}
<li> {{ range .Data.Pages.ByLength }}
<a href="{{ .Permalink }}">{{ .Title }}</a> <li>
<div class="meta">{{ .Date.Format "Mon, Jan 2, 2006" }}</div> <a href="{{ .Permalink }}">{{ .Title }}</a>
</li> <div class="meta">{{ .Date.Format "Mon, Jan 2, 2006" }}</div>
{{ end }} </li>
{{ end }}
{{% /highlight %}}
## Reverse Order ## Reverse Order
Can be applied to any of the above. Using Date for an example. Can be applied to any of the above. Using Date for an example.
{{ range .Data.Pages.ByDate.Reverse }} {{% highlight html %}}
<li> {{ range .Data.Pages.ByDate.Reverse }}
<a href="{{ .Permalink }}">{{ .Title }}</a> <li>
<div class="meta">{{ .Date.Format "Mon, Jan 2, 2006" }}</div> <a href="{{ .Permalink }}">{{ .Title }}</a>
</li> <div class="meta">{{ .Date.Format "Mon, Jan 2, 2006" }}</div>
{{ end }} </li>
{{ end }}
{{% /highlight %}}
## Ordering Content Within Indexes ## Ordering Content Within Indexes

View file

@ -20,26 +20,26 @@ content nested at any level. The top level is special in Hugo and is used as the
. .
└── content └── content
├── post ├── post
| ├── firstpost.md // <- http://site.com/post/firstpost/ | ├── firstpost.md // <- http://1.com/post/firstpost/
| ├── happy | ├── happy
| | └── happiness.md // <- http://site.com/post/happy/happiness/ | | └── ness.md // <- http://1.com/post/happy/ness/
| └── secondpost.md // <- http://site.com/post/secondpost/ | └── secondpost.md // <- http://1.com/post/secondpost/
└── quote └── quote
├── first.md // <- http://site.com/quote/first/ ├── first.md // <- http://1.com/quote/first/
└── second.md // <- http://site.com/quote/second/ └── second.md // <- http://1.com/quote/second/
**Here's the same organization run with hugo -\-uglyurls** **Here's the same organization run with hugo -\-uglyurls**
. .
└── content └── content
├── post ├── post
| ├── firstpost.md // <- http://site.com/post/firstpost.html | ├── firstpost.md // <- http://1.com/post/firstpost.html
| ├── happy | ├── happy
| | └── happiness.md // <- http://site.com/post/happy/happiness.html | | └── ness.md // <- http://1.com/post/happy/ness.html
| └── secondpost.md // <- http://site.com/post/secondpost.html | └── secondpost.md // <- http://1.com/post/secondpost.html
└── quote └── quote
├── first.md // <- http://site.com/quote/first.html ├── first.md // <- http://1.com/quote/first.html
└── second.md // <- http://site.com/quote/second.html └── second.md // <- http://1.com/quote/second.html
## Destinations ## Destinations
@ -55,28 +55,28 @@ determine the destination of a specific piece of content.
The following items are defined in order, latter items in the list will override The following items are defined in order, latter items in the list will override
earlier settings. earlier settings.
#### filename ### filename
This isn't in the front matter, but is the actual name of the file minus the This isn't in the front matter, but is the actual name of the file minus the
extension. This will be the name of the file in the destination. extension. This will be the name of the file in the destination.
#### slug ### slug
Defined in the front matter, the slug can take the place of the filename for the Defined in the front matter, the slug can take the place of the filename for the
destination. destination.
#### filepath ### filepath
The actual path to the file on disk. Destination will create the destination The actual path to the file on disk. Destination will create the destination
with the same path. Includes [section](/content/sections). with the same path. Includes [section](/content/sections).
#### section ### section
section can be provided in the front matter overriding the section derived from section can be provided in the front matter overriding the section derived from
the source content location on disk. See [section](/content/sections). the source content location on disk. See [section](/content/sections).
#### path ### path
path can be provided in the front matter. This will replace the actual path can be provided in the front matter. This will replace the actual
path to the file on disk. Destination will create the destination with the same path to the file on disk. Destination will create the destination with the same
path. Includes [section](/content/sections). path. Includes [section](/content/sections).
#### url ### url
A complete url can be provided. This will override all the above as it pertains A complete url can be provided. This will override all the above as it pertains
to the end destination. This must be the path from the baseurl (starting with a "/"). to the end destination. This must be the path from the baseurl (starting with a "/").
When a url is provided it will be used exactly. Using url will ignore the When a url is provided it will be used exactly. Using url will ignore the
@ -135,23 +135,23 @@ 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
front matter overrides * based on content location
* front matter overrides
**slug** = name.ext or name/
* based on content-name.md
* front matter overrides
**path** = section + path to file exluding slug
* based on path to content location
slug = name.ext or name/ **url** = relative url
based on content-name.md
front matter overrides
path = section + path to file exluding slug
based on path to content location
url = relative url
defined in front matter
overrides all the above
* defined in front matter
* overrides all the above

View file

@ -15,13 +15,13 @@ The following example site uses two sections, "post" and "quote".
. .
└── content └── content
├── post ├── post
| ├── firstpost.md // <- http://site.com/post/firstpost/ | ├── firstpost.md // <- http://1.com/post/firstpost/
| ├── happy | ├── happy
| | └── happiness.md // <- http://site.com/post/happy/happiness/ | | └── ness.md // <- http://1.com/post/happy/ness/
| └── secondpost.md // <- http://site.com/post/secondpost/ | └── secondpost.md // <- http://1.com/post/secondpost/
└── quote └── quote
├── first.md // <- http://site.com/quote/first/ ├── first.md // <- http://1.com/quote/first/
└── second.md // <- http://site.com/quote/second/ └── second.md // <- http://1.com/quote/second/
## Sections and Types ## Sections and Types

View file

@ -20,16 +20,16 @@ templates that the new type will use.
It is essential to provide the single render view template as well as a It is essential to provide the single render view template as well as a
list view template. list view template.
**Step 1:** ### Step 1:
Create a directory with the name of the type in layouts.Type is always singular. *Eg /layouts/post*. Create a directory with the name of the type in layouts.Type is always singular. *Eg /layouts/post*.
**Step 2:** ### Step 2:
Create a file called single.html inside your directory. *Eg /layouts/post/single.html*. Create a file called single.html inside your directory. *Eg /layouts/post/single.html*.
**Step 3:** ### Step 3:
Create a file with the same name as your directory in /layouts/indexes/. *Eg /layouts/indexes/post.html*. Create a file with the same name as your directory in /layouts/indexes/. *Eg /layouts/indexes/post.html*.
**Step 4:** ### Step 4:
Many sites support rendering content in a few different ways, for Many sites support rendering content in a few different ways, for
instance a single page view and a summary view to be used when displaying a list instance a single page view and a summary view to be used when displaying a list
of contents on a single page. Hugo makes no assumptions here about how you want of contents on a single page. Hugo makes no assumptions here about how you want

View file

@ -16,12 +16,13 @@ Luckily, this can be handled easily with aliases in Hugo.
## Example ## Example
**content/posts/my-awesome-blog-post.md** **content/posts/my-awesome-blog-post.md**
{{% highlight yaml %}}
--- ---
aliases: aliases:
- /posts/my-original-url/ - /posts/my-original-url/
- /2010/even-earlier-url.html - /2010/even-earlier-url.html
--- ---
{{% /highlight %}}
Now when you go to any of the aliases locations they Now when you go to any of the aliases locations they
will redirect to the page. will redirect to the page.

View file

@ -6,32 +6,72 @@ groups: ["extras"]
groups_weight: 10 groups_weight: 10
--- ---
Because Hugo uses markdown for its content format, it was clear that there's a lot of things that Because Hugo uses markdown for its simple content format, however there's a lot of things that
markdown doesn't support well. This is good, the simple nature of markdown is exactly why we chose it. markdown doesn't support well.
However we cannot accept being constrained by our simple format. Also unacceptable is writing raw We are unwilling to accept being constrained by our simple format. Also unacceptable is writing raw
html in our markdown every time we want to include unsupported content such as a video. To do html in our markdown every time we want to include unsupported content such as a video. To do
so is in complete opposition to the intent of using a bare bones format for our content and so is in complete opposition to the intent of using a bare bones format for our content and
utilizing templates to apply styling for display. utilizing templates to apply styling for display.
To avoid both of these limitations Hugo has full support for shortcodes. To avoid both of these limitations Hugo created shortcodes.
### What is a shortcode? ## What is a shortcode?
A shortcode is a simple snippet inside a markdown file that Hugo will render using a template. A shortcode is a simple snippet inside a markdown file that Hugo will render using a predefined template.
Short codes are designated by the opening and closing characters of '{{&#37;' and '%}}' respectively. An example of a shortcode would be `{{% video http://urlToVideo %}}`
Short codes are space delimited. The first word is always the name of the shortcode. Following the
name are the parameters. The author of the shortcode can choose if the short code Shortcodes are created by placing a template file in `layouts/shortcodes/`. The
will use positional parameters or named parameters (but not both). A good rule of thumb is that if a name of the file becomes the name of the shortcode (without the extension).
short code has a single required value in the case of the youtube example below then positional
works very well. For more complex layouts with optional parameters named parameters work best. In your content files a shortcode can be called by using '{{&#37; name parameters
%}}' respectively. Shortcodes are space delimited (parameters with spaces
can be quoted).
The first word is always the name of the shortcode. Following
the name are the parameters.
The author of the shortcode can choose if the short code will use positional
parameters or named parameters (but not both). A good rule of thumb is that if
a short code has a single required value in the case of the youtube example
below then positional works very well. For more complex layouts with optional
parameters named parameters work best.
The format for named parameters models that of html with the format name="value" The format for named parameters models that of html with the format name="value"
### Example: youtube Lastly like HTML, shortcodes can be singular or paired. An example of a paired
*Example has an extra space so Hugo doesn't actually render it* shortcode would be:
{{ % youtube 09jf3ow9jfw %}} {{% code_highlight %}} A bunch of code here {{% /code_highlight %}}
Shortcodes are paired with an opening shortcode identical to a single shortcode
and a closing shortcode.
## Creating a shortcode
All that you need to do to create a shortcode is place a template in the layouts/shortcodes directory.
The template name will be the name of the shortcode.
**Inside the template**
To access a parameter by either position or name the index method can be used.
{{ index .Params 0 }}
or
{{ index .Params "class" }}
To check if a parameter has been provided use the isset method provided by Hugo.
{{ if isset .Params "class"}} class="{{ index .Params "class"}}" {{ end }}
For paired shortcodes the variable .Inner is available which contains all of
the content between the opening and closing shortcodes. **Simply using this
variable is the only difference between single and paired shortcodes.**
## Single Positional Example: youtube
{{% youtube 09jf3ow9jfw %}}
Would load the template /layouts/shortcodes/youtube.html Would load the template /layouts/shortcodes/youtube.html
@ -50,7 +90,7 @@ This would be rendered as
</iframe> </iframe>
</div> </div>
### Example: image with caption ## Single Named Example: image with caption
*Example has an extra space so Hugo doesn't actually render it* *Example has an extra space so Hugo doesn't actually render it*
{{ % img src="/media/spf13.jpg" title="Steve Francia" %}} {{ % img src="/media/spf13.jpg" title="Steve Francia" %}}
@ -85,23 +125,29 @@ Would be rendered as:
</figcaption> </figcaption>
</figure> </figure>
## Paired Example: Highlight
*Hugo already ships with the highlight shortcode*
### Creating a shortcode *Example has an extra space so Hugo doesn't actually render it*.
All that you need to do to create a shortcode is place a template in the layouts/shortcodes directory. {{% highlight html %}}
<html>
<body> This HTML </body>
</html>
{{% /highlight %}}
The template name will be the name of the shortcode. The template for this utilizes the following code (already include in hugo)
**Inside the template** {{ $lang := index .Params 0 }}{{ highlight .Inner $lang }}
To access a parameter by either position or name the index method can be used. And will be rendered as:
{{ index .Params 0 }} <div class="highlight" style="background: #272822"><pre style="line-height: 125%"><span style="color: #f92672">&lt;html&gt;</span>
or <span style="color: #f92672">&lt;body&gt;</span> This HTML <span style="color: #f92672">&lt;/body&gt;</span>
{{ index .Params "class" }} <span style="color: #f92672">&lt;/html&gt;</span>
</pre></div>
To check if a parameter has been provided use the isset method provided by Hugo.
{{ if isset .Params "class"}} class="{{ index .Params "class"}}" {{ end }}
Please notice that this template makes use of a hugo specific template function
called highlight which uses pygments to add the highlighting code.
More shortcode examples can be found at [spf13.com](https://github.com/spf13/spf13.com/tree/master/layouts/shortcodes)

View file

@ -15,44 +15,50 @@ First step is to define the index in your config file.
important to provide both here. We require this, rather than using inflection in important to provide both here. We require this, rather than using inflection in
effort to support as many languages as possible.* effort to support as many languages as possible.*
--- {{% highlight yaml %}}
indexes: ---
category: "categories" indexes:
baseurl: "http://spf13.com/" category: "categories"
title: "Steve Francia is spf13.com" baseurl: "http://spf13.com/"
--- title: "Steve Francia is spf13.com"
---
{{% /highlight %}}
### /layouts/indexes/category.html ### /layouts/indexes/category.html
For each index type a template needs to be provided to render the index page. For each index type a template needs to be provided to render the index page.
In the case of categories, this will render the content for /categories/CATEGORYNAME/. In the case of categories, this will render the content for /categories/`CATEGORYNAME`/.
{{ template "chrome/header.html" . }} {{% highlight html %}}
{{ template "chrome/subheader.html" . }} {{ template "chrome/header.html" . }}
{{ template "chrome/subheader.html" . }}
<section id="main"> <section id="main">
<div> <div>
<h1 id="title">{{ .Title }}</h1> <h1 id="title">{{ .Title }}</h1>
{{ range .Data.Pages }} {{ range .Data.Pages }}
{{ .Render "summary"}} {{ .Render "summary"}}
{{ end }} {{ end }}
</div> </div>
</section> </section>
{{ template "chrome/footer.html" }} {{ template "chrome/footer.html" }}
{{% /highlight %}}
### Assigning indexes to content ### Assigning indexes to content
Make sure that the index is set in the front matter: Make sure that the index is set in the front matter:
{ {{% highlight json %}}
"title": "Hugo: A fast and flexible static site generator", {
"categories": [ "title": "Hugo: A fast and flexible static site generator",
"Development", "categories": [
"golang", "Development",
"Blogging" "golang",
], "Blogging"
"slug": "hugo" ],
} "slug": "hugo"
}
{{% /highlight %}}

View file

@ -5,8 +5,8 @@ linktitle: "Displaying"
groups: ["indexes"] groups: ["indexes"]
groups_weight: 20 groups_weight: 20
--- ---
# For Content
### Index values assigned to this content ## Rendering index values assigned to this content
Within your content templates you may wish to display Within your content templates you may wish to display
the indexes that that piece of content is assigned to. the indexes that that piece of content is assigned to.
@ -16,31 +16,34 @@ define indexes for content, the indexes assigned to
each content piece are located in the usual place each content piece are located in the usual place
(.Params.`plural`) (.Params.`plural`)
#### Example ### Example
<ul id="tags"> {{% highlight html %}}
{{ range .Params.tags }} <ul id="tags">
<li><a href="tags/{{ . | urlize }}">{{ . }}</a> </li> {{ range .Params.tags }}
{{ end }} <li><a href="tags/{{ . | urlize }}">{{ . }}</a> </li>
</ul> {{ end }}
</ul>
{{% /highlight %}}
# Anywhere ## Rendering a Site's Indexes
### Displaying all keys for an index
If you wish to display the list of all keys for an index you can If you wish to display the list of all keys for an index you can find retrieve
find retrieve them from the `.Site` variable. them from the `.Site` variable which is available on every page.
This may take the form of a tag cloud, a menu or simply a list. This may take the form of a tag cloud, a menu or simply a list.
The following example displays all tag keys: The following example displays all tag keys:
#### Example ### Example
<ul id="all-tags"> {{% highlight html %}}
{{ range .Site.Indexes.tags }} <ul id="all-tags">
<li><a href="/tags/{{ .Name | urlize }}">{{ .Name }}</a></li> {{ range .Site.Indexes.tags }}
{{ end }} <li><a href="/tags/{{ .Name | urlize }}">{{ .Name }}</a></li>
</ul> {{ end }}
</ul>
{{% /highlight %}}
## Creating a menu based on indexes ## Creating a menu based on indexes
@ -53,57 +56,64 @@ called menu.html, then include it using the
`{{ template "chrome/menu.html" . }}` syntax. `{{ template "chrome/menu.html" . }}` syntax.
### Example complete menu.html file
This example will list all indexes, each of their keys and all the content assigned to each key. This example will list all indexes, each of their keys and all the content assigned to each key.
#### Example complete menu.html file
<section id="menu">
<ul>
{{ range $indexname, $index := .Site.Indexes }}
<li><a href="/{{ $indexname | urlize }}">{{ $indexname }}</a>
<ul>
{{ range $key, $value := $index }}
<li> {{ $key }} </li>
<ul>
{{ range $value.Pages }}
<li hugo-nav="{{ .RelPermalink}}"><a href="{{ .Permalink}}"> {{ .LinkTitle }} </a> </li>
{{ end }}
</ul>
{{ end }}
</ul>
</li>
{{ end }}
</ul>
</section>
{{% highlight html %}}
<section id="menu">
<ul>
{{ range $indexname, $index := .Site.Indexes }}
<li><a href="/{{ $indexname | urlize }}">{{ $indexname }}</a>
<ul>
{{ range $key, $value := $index }}
<li> {{ $key }} </li>
<ul>
{{ range $value.Pages }}
<li hugo-nav="{{ .RelPermalink}}"><a href="{{ .Permalink}}"> {{ .LinkTitle }} </a> </li>
{{ end }}
</ul>
{{ end }}
</ul>
</li>
{{ end }}
</ul>
</section>
{{% /highlight %}}
### menu.html using a single index
It is more likely that you would want to use a single index for navigation. It is more likely that you would want to use a single index for navigation.
In this example we are using the `groups` index for our menu. In this example we are using the `groups` index for our menu.
#### Example menu.html file using a single index
<section id="menu"> {{% highlight html %}}
<section id="menu">
<ul>
{{ range $key, $index := .Site.Indexes.groups }}
<li> {{ $key }} </li>
<ul> <ul>
{{ range $key, $index := .Site.Indexes.groups }} {{ range $index.Pages }}
<li> {{ $key }} </li> <li hugo-nav="{{ .RelPermalink}}"><a href="{{ .Permalink}}"> {{ .LinkTitle }} </a> </li>
<ul>
{{ range $index.Pages }}
<li hugo-nav="{{ .RelPermalink}}"><a href="{{ .Permalink}}"> {{ .LinkTitle }} </a> </li>
{{ end }}
</ul>
{{ end }} {{ end }}
</ul> </ul>
</section> {{ end }}
</ul>
</section>
{{% /highlight %}}
Or order the keys by Popularity
#### Example menu.html file using a single index ### menu.html using a single index ordered by Popularity
<section id="menu">
{{% highlight html %}}
<section id="menu">
<ul>
{{ range .Site.Indexes.groups.ByCount }}
<li> {{ .Name }} </li>
<ul> <ul>
{{ range .Site.Indexes.groups.ByCount }} {{ range .Pages }}
<li> {{ .Name }} </li> <li hugo-nav="{{ .RelPermalink}}"><a href="{{ .Permalink}}"> {{ .LinkTitle }} </a> </li>
<ul>
{{ range .Pages }}
<li hugo-nav="{{ .RelPermalink}}"><a href="{{ .Permalink}}"> {{ .LinkTitle }} </a> </li>
{{ end }}
</ul>
{{ end }} {{ end }}
</ul> </ul>
</section> {{ end }}
</ul>
</section>
{{% /highlight %}}

View file

@ -8,7 +8,7 @@ groups_weight: 40
--- ---
An index list is a list of all the keys that are contained in the index. When a An index list is a list of all the keys that are contained in the index. When a
template is present, this will be rendered at /IndexPlural/ template is present, this will be rendered at `/IndexPlural/`
Hugo also supports creating pages that list your values for each index along Hugo also supports creating pages that list your values for each index along
with the number of content items associated with the index key. These are with the number of content items associated with the index key. These are
@ -22,44 +22,46 @@ Hugo can order the meta data in two different ways. It can be ordered by the
number of content assigned to that key or alphabetically. number of content assigned to that key or alphabetically.
#### Example indexes.html file (alphabetical) ### Example indexes.html file (alphabetical)
{{ template "chrome/header.html" . }} {{% highlight html %}}
{{ template "chrome/subheader.html" . }} {{ template "chrome/header.html" . }}
{{ template "chrome/subheader.html" . }}
<section id="main"> <section id="main">
<div> <div>
<h1 id="title">{{ .Title }}</h1> <h1 id="title">{{ .Title }}</h1>
<ul> <ul>
{{ $data := .Data }} {{ $data := .Data }}
{{ range $key, $value := .Data.Index.Alphabetical }} {{ range $key, $value := .Data.Index.Alphabetical }}
<li><a href="{{ $data.Plural }}/{{ $value.Name | urlize }}"> {{ $value.Name }} </a> {{ $value.Count }} </li> <li><a href="{{ $data.Plural }}/{{ $value.Name | urlize }}"> {{ $value.Name }} </a> {{ $value.Count }} </li>
{{ end }} {{ end }}
</ul> </ul>
</div> </div>
</section> </section>
{{ template "chrome/footer.html" }}
{{% /highlight %}}
{{ template "chrome/footer.html" }} ### Example indexes.html file (ordered)
{{% highlight html %}}
{{ template "chrome/header.html" . }}
{{ template "chrome/subheader.html" . }}
#### Example indexes.html file (ordered) <section id="main">
<div>
<h1 id="title">{{ .Title }}</h1>
<ul>
{{ $data := .Data }}
{{ range $key, $value := .Data.Index.ByCount }}
<li><a href="{{ $data.Plural }}/{{ $value.Name | urlize }}"> {{ $value.Name }} </a> {{ $value.Count }} </li>
{{ end }}
</ul>
</div>
</section>
{{ template "chrome/header.html" . }} {{ template "chrome/footer.html" }}
{{ template "chrome/subheader.html" . }} {{% /highlight %}}
<section id="main">
<div>
<h1 id="title">{{ .Title }}</h1>
<ul>
{{ $data := .Data }}
{{ range $key, $value := .Data.Index.ByCount }}
<li><a href="{{ $data.Plural }}/{{ $value.Name | urlize }}"> {{ $value.Name }} </a> {{ $value.Count }} </li>
{{ end }}
</ul>
</div>
</section>
{{ template "chrome/footer.html" }}
### Variables available to list of indexes pages. ### Variables available to list of indexes pages.

View file

@ -17,21 +17,25 @@ Indexes can be ordered by either alphabetical key or by the number of content pi
### Order Alphabetically Example: ### Order Alphabetically Example:
<ul> {{% highlight html %}}
{{ $data := .Data }} <ul>
{{ range $key, $value := .Data.Index.Alphabetical }} {{ $data := .Data }}
<li><a href="{{ $data.Plural }}/{{ $value.Name | urlize }}"> {{ $value.Name }} </a> {{ $value.Count }} </li> {{ range $key, $value := .Data.Index.Alphabetical }}
{{ end }} <li><a href="{{ $data.Plural }}/{{ $value.Name | urlize }}"> {{ $value.Name }} </a> {{ $value.Count }} </li>
</ul> {{ end }}
</ul>
{{% /highlight %}}
### Order by Popularity Example: ### Order by Popularity Example:
<ul> {{% highlight html %}}
{{ $data := .Data }} <ul>
{{ range $key, $value := .Data.Index.ByCount }} {{ $data := .Data }}
<li><a href="{{ $data.Plural }}/{{ $value.Name | urlize }}"> {{ $value.Name }} </a> {{ $value.Count }} </li> {{ range $key, $value := .Data.Index.ByCount }}
{{ end }} <li><a href="{{ $data.Plural }}/{{ $value.Name | urlize }}"> {{ $value.Name }} </a> {{ $value.Count }} </li>
</ul> {{ end }}
</ul>
{{% /highlight %}}
[See Also Index Lists](/indexes/lists/) [See Also Index Lists](/indexes/lists/)

View file

@ -1,5 +1,5 @@
--- ---
title: "Index Overview" title: "Indexes"
date: "2013-07-01" date: "2013-07-01"
aliases: ["/doc/indexes/", "/extras/indexes"] aliases: ["/doc/indexes/", "/extras/indexes"]
linktitle: "Overview" linktitle: "Overview"
@ -17,9 +17,9 @@ navigation, series and many more. Just think of an index as way to organize simi
It's important to understand what Indexes do. At it's most basic form an index It's important to understand what Indexes do. At it's most basic form an index
is simply a map of a key to a list of content values. is simply a map of a key to a list of content values.
In the hugo internals this is stored as Site.Indexes[Plural][key][]pages. In the hugo internals this is stored as `Site.Indexes[Plural][key][]pages`.
For example all the content tagged with GoLang would be found at For example all the content tagged with GoLang would be found at
Site.Indexes["tags"]["golang"]. `Site.Indexes["tags"]["golang"]`.
For a For a
more complete example see the source of [this docs site](http://github.com/spf13/hugo/docs/). more complete example see the source of [this docs site](http://github.com/spf13/hugo/docs/).
@ -35,16 +35,17 @@ we could use an inflection library to pluralize this, they currently
support only a few languages, so instead we've opted for user defined support only a few languages, so instead we've opted for user defined
pluralization. pluralization.
**config.yaml** ### config.yaml
---
indexes:
tag: "tags"
category: "categories"
baseurl: "http://spf13.com/"
title: "Steve Francia is spf13.com"
---
{{% highlight yaml %}}
---
indexes:
tag: "tags"
category: "categories"
baseurl: "http://spf13.com/"
title: "Steve Francia is spf13.com"
---
{{% /highlight %}}
## Assigning index values to content ## Assigning index values to content
@ -57,19 +58,22 @@ and assign all keys you want this content to match against.
**Index values are case insensitive** **Index values are case insensitive**
#### Example ### Example
{
"title": "Hugo: A fast and flexible static site generator", {{% highlight json %}}
"tags": [ {
"Development", "title": "Hugo: A fast and flexible static site generator",
"golang", "tags": [
"fast", "Development",
"Blogging" "golang",
], "fast",
"categories" : [ "Blogging"
"Development" ],
] "categories" : [
"slug": "hugo", "Development"
"project_url": "http://github.com/spf13/hugo" ]
} "slug": "hugo",
"project_url": "http://github.com/spf13/hugo"
}
{{% /highlight %}}

View file

@ -14,7 +14,7 @@ addresses the template used for the first type.
## Creating index templates ## Creating index templates
For each index type a template needs to be provided to render the index page. For each index type a template needs to be provided to render the index page.
In the case of tags, this will render the content for /tags/TAGNAME/. In the case of tags, this will render the content for `/tags/TAGNAME/`.
The template must be called the singular name of the index and placed in The template must be called the singular name of the index and placed in
layouts/indexes layouts/indexes
@ -26,7 +26,7 @@ layouts/indexes
The template will be provided Data about the index. The template will be provided Data about the index.
### Variables ## Variables
The following variables are available to the index template: The following variables are available to the index template:
@ -37,19 +37,19 @@ The following variables are available to the index template:
**.Data.Pages** The content that is assigned this index.<br> **.Data.Pages** The content that is assigned this index.<br>
**.Data.`singular`** The index itself.<br> **.Data.`singular`** The index itself.<br>
#### Example ## Example
{{% highlight html %}}
{{ template "chrome/header.html" . }}
{{ template "chrome/subheader.html" . }}
{{ template "chrome/header.html" . }} <section id="main">
{{ template "chrome/subheader.html" . }} <div>
<h1 id="title">{{ .Title }}</h1>
<section id="main"> {{ range .Data.Pages }}
<div> {{ .Render "summary"}}
<h1 id="title">{{ .Title }}</h1> {{ end }}
{{ range .Data.Pages }} </div>
{{ .Render "summary"}} </section>
{{ end }}
</div>
</section>
{{ template "chrome/footer.html" }}
{{ template "chrome/footer.html" }}
{{% /highlight %}}

View file

@ -30,53 +30,56 @@ used for both nodes and pages we can use the same chrome for both.
## example header.html ## example header.html
This header template is used for [spf13.com](http://spf13.com). This header template is used for [spf13.com](http://spf13.com).
<!DOCTYPE html> {{% highlight html %}}
<html class="no-js" lang="en-US" prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb#"> <!DOCTYPE html>
<head> <html class="no-js" lang="en-US" prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb#">
<meta charset="utf-8"> <head>
<meta charset="utf-8">
{{ template "chrome/meta.html" . }} {{ template "chrome/meta.html" . }}
<base href="{{ .Site.BaseUrl }}"> <base href="{{ .Site.BaseUrl }}">
<title> {{ .Title }} : spf13.com </title> <title> {{ .Title }} : spf13.com </title>
<link rel="canonical" href="{{ .Permalink }}"> <link rel="canonical" href="{{ .Permalink }}">
{{ if .RSSlink }}<link href="{{ .RSSlink }}" rel="alternate" type="application/rss+xml" title="{{ .Title }}" />{{ end }} {{ if .RSSlink }}<link href="{{ .RSSlink }}" rel="alternate" type="application/rss+xml" title="{{ .Title }}" />{{ end }}
{{ template "chrome/head_includes.html" . }}
</head>
<body lang="en">
{{ template "chrome/head_includes.html" . }}
</head>
<body lang="en">
{{% /highlight %}}
## example footer.html ## example footer.html
This header template is used for [spf13.com](http://spf13.com). This header template is used for [spf13.com](http://spf13.com).
<footer> {{% highlight html %}}
<div> <footer>
<p> <div>
&copy; 2013 Steve Francia. <p>
<a href="http://creativecommons.org/licenses/by/3.0/" title="Creative Commons Attribution">Some rights reserved</a>; &copy; 2013 Steve Francia.
please attribute properly and link back. Hosted by <a href="http://servergrove.com">ServerGrove</a>. <a href="http://creativecommons.org/licenses/by/3.0/" title="Creative Commons Attribution">Some rights reserved</a>;
</p> please attribute properly and link back. Hosted by <a href="http://servergrove.com">ServerGrove</a>.
</div> </p>
</footer> </div>
<script type="text/javascript"> </footer>
<script type="text/javascript">
var _gaq = _gaq || []; var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XYSYXYSY-X']); _gaq.push(['_setAccount', 'UA-XYSYXYSY-X']);
_gaq.push(['_trackPageview']); _gaq.push(['_trackPageview']);
(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);
})(); })();
</script> </script>
</body> </body>
</html> </html>
{{% /highlight %}}
**For examples of referencing these templates, see [content **For examples of referencing these templates, see [content
templates](/layout/content/) and [homepage templates](/layout/homepage/)** templates](/layout/content/) and [homepage templates](/layout/homepage/)**

View file

@ -12,7 +12,8 @@ variables](/layout/variables/) available to use in the templates.
bootstrapping a new site and template.* bootstrapping a new site and template.*
In addition to the standard node variables, the homepage has access to In addition to the standard node variables, the homepage has access to
all site content accessible from .Data.Pages all site content accessible from .Data.Pages . Details on how to use this
list of pages can be found in [Lists](/indexes/lists/)
▾ layouts/ ▾ layouts/
@ -21,32 +22,35 @@ all site content accessible from .Data.Pages
## example index.html ## example index.html
This content template is used for [spf13.com](http://spf13.com). This content template is used for [spf13.com](http://spf13.com).
It makes use of [chrome templates](/layout/chrome)
<!DOCTYPE html> It makes use of [chrome templates](/layout/chrome) and uses a [List](/indexes/lists/)
<html class="no-js" lang="en-US" prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb#">
<head>
<meta charset="utf-8">
{{ template "chrome/meta.html" . }} {{% highlight html %}}
<!DOCTYPE html>
<html class="no-js" lang="en-US" prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb#">
<head>
<meta charset="utf-8">
<base href="{{ .Site.BaseUrl }}"> {{ template "chrome/meta.html" . }}
<title>{{ .Site.Title }}</title>
<link rel="canonical" href="{{ .Permalink }}">
<link href="{{ .RSSlink }}" rel="alternate" type="application/rss+xml" title="{{ .Site.Title }}" />
{{ template "chrome/head_includes.html" . }} <base href="{{ .Site.BaseUrl }}">
</head> <title>{{ .Site.Title }}</title>
<body lang="en"> <link rel="canonical" href="{{ .Permalink }}">
<link href="{{ .RSSlink }}" rel="alternate" type="application/rss+xml" title="{{ .Site.Title }}" />
{{ template "chrome/subheader.html" . }} {{ template "chrome/head_includes.html" . }}
</head>
<body lang="en">
<section id="main"> {{ template "chrome/subheader.html" . }}
<div>
{{ range first 10 .Data.Pages }}
{{ .Render "summary"}}
{{ end }}
</div>
</section>
{{ template "chrome/footer.html" }} <section id="main">
<div>
{{ range first 10 .Data.Pages }}
{{ .Render "summary"}}
{{ end }}
</div>
</section>
{{ template "chrome/footer.html" }}
{{% /highlight %}}

View file

@ -43,21 +43,23 @@ It makes use of [chrome templates](/layout/chrome). All examples use a
[view](/layout/views/) called either "li" or "summary" which this example site [view](/layout/views/) called either "li" or "summary" which this example site
defined. defined.
{{ template "chrome/header.html" . }} {{% highlight html %}}
{{ template "chrome/subheader.html" . }} {{ template "chrome/header.html" . }}
{{ template "chrome/subheader.html" . }}
<section id="main"> <section id="main">
<div> <div>
<h1 id="title">{{ .Title }}</h1> <h1 id="title">{{ .Title }}</h1>
<ul id="list"> <ul id="list">
{{ range .Data.Pages }} {{ range .Data.Pages }}
{{ .Render "li"}} {{ .Render "li"}}
{{ end }} {{ end }}
</ul> </ul>
</div> </div>
</section> </section>
{{ template "chrome/footer.html" }} {{ template "chrome/footer.html" }}
{{% /highlight %}}
## Example index template (tag.html) ## Example index template (tag.html)
This content template is used for [spf13.com](http://spf13.com). This content template is used for [spf13.com](http://spf13.com).
@ -65,20 +67,21 @@ It makes use of [chrome templates](/layout/chrome). All examples use a
[view](/layout/views/) called either "li" or "summary" which this example site [view](/layout/views/) called either "li" or "summary" which this example site
defined. defined.
{{ template "chrome/header.html" . }} {{% highlight html %}}
{{ template "chrome/subheader.html" . }} {{ template "chrome/header.html" . }}
{{ template "chrome/subheader.html" . }}
<section id="main"> <section id="main">
<div> <div>
<h1 id="title">{{ .Title }}</h1> <h1 id="title">{{ .Title }}</h1>
{{ range .Data.Pages }} {{ range .Data.Pages }}
{{ .Render "summary"}} {{ .Render "summary"}}
{{ end }} {{ end }}
</div> </div>
</section> </section>
{{ template "chrome/footer.html" }}
{{ template "chrome/footer.html" }}
{{% /highlight %}}
## Example listing of indexes template (indexes.html) ## Example listing of indexes template (indexes.html)
This content template is used for [spf13.com](http://spf13.com). This content template is used for [spf13.com](http://spf13.com).
@ -95,29 +98,31 @@ the latter uses .Data.OrderedIndex. .Data.Index is alphabetical by key name, whi
.Data.Orderedindex is ordered by the quantity of content assigned to that particular .Data.Orderedindex is ordered by the quantity of content assigned to that particular
index key. In practice you would only use one of these approaches. index key. In practice you would only use one of these approaches.
{{ template "chrome/header.html" . }} {{% highlight html %}}
{{ template "chrome/subheader.html" . }} {{ template "chrome/header.html" . }}
{{ template "chrome/subheader.html" . }}
<section id="main"> <section id="main">
<div> <div>
<h1 id="title">{{ .Title }}</h1> <h1 id="title">{{ .Title }}</h1>
<ul> <ul>
{{ $data := .Data }} {{ $data := .Data }}
{{ range $key, $value := .Data.Index }} {{ range $key, $value := .Data.Index }}
<li><a href="{{ $data.Plural }}/{{ $key | urlize }}"> {{ $key }} </a> {{ len $value }} </li> <li><a href="{{ $data.Plural }}/{{ $key | urlize }}"> {{ $key }} </a> {{ len $value }} </li>
{{ end }} {{ end }}
</ul> </ul>
</div> </div>
<ul> <ul>
{{ range $data.OrderedIndex }} {{ range $data.OrderedIndex }}
<li><a href="{{ $data.Plural }}/{{ .Name | urlize }}"> {{ .Name }} </a> {{ .Count }} </li> <li><a href="{{ $data.Plural }}/{{ .Name | urlize }}"> {{ .Name }} </a> {{ .Count }} </li>
{{ end }} {{ end }}
</ul> </ul>
</section> </section>
{{ template "chrome/footer.html" }} {{ template "chrome/footer.html" }}
{{% /highlight %}}

View file

@ -21,27 +21,28 @@ all site content accessible from .Data.Pages
This rss template is used for [spf13.com](http://spf13.com). It adheres to the This rss template is used for [spf13.com](http://spf13.com). It adheres to the
ATOM 2.0 Spec. ATOM 2.0 Spec.
{{% highlight xml %}}
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"> <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel> <channel>
<title>{{ .Title }} on {{ .Site.Title }} </title> <title>{{ .Title }} on {{ .Site.Title }} </title>
<link>{{ .Permalink }}</link> <link>{{ .Permalink }}</link>
<language>en-us</language> <language>en-us</language>
<author>Steve Francia</author> <author>Steve Francia</author>
<rights>Copyright (c) 2008 - 2013, Steve Francia; all rights reserved.</rights> <rights>Copyright (c) 2008 - 2013, Steve Francia; all rights reserved.</rights>
<updated>{{ .Date }}</updated> <updated>{{ .Date }}</updated>
{{ range .Data.Pages }} {{ range .Data.Pages }}
<item> <item>
<title>{{ .Title }}</title> <title>{{ .Title }}</title>
<link>{{ .Permalink }}</link> <link>{{ .Permalink }}</link>
<pubDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 MST" }}</pubDate> <pubDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 MST" }}</pubDate>
<author>Steve Francia</author> <author>Steve Francia</author>
<guid>{{ .Permalink }}</guid> <guid>{{ .Permalink }}</guid>
<description>{{ .Content | html }}</description> <description>{{ .Content | html }}</description>
</item> </item>
{{ end }} {{ end }}
</channel> </channel>
</rss> </rss>
{{% /highlight %}}
*Important: Hugo will automatically add the following header line to this file *Important: Hugo will automatically add the following header line to this file
on render...please don't include this in the template as it's not valid HTML.* on render...please don't include this in the template as it's not valid HTML.*

View file

@ -20,19 +20,19 @@ is a great place to start.
There are 6 different kinds of templates that Hugo works with. There are 6 different kinds of templates that Hugo works with.
### [Homepage](/layout/homepage/) ### [Homepage](/layout/homepage/)
The homepage of your site. The homepage of your site
### [RSS](/layout/rss/) ### [RSS](/layout/rss/)
Used to render all rss documents. Used to render all rss documents
### [Index](/layout/indexes) ### [Index](/layout/indexes)
Page that list multiple pieces of content. Page that list multiple pieces of content
### [Content](/layout/content) ### [Content](/layout/content)
Templates to render a single piece of content. Render a single piece of content
### [Views](/layout/views) ### [Views](/layout/views)
Different ways of rendering each content type Different view of a single piece of content type
### [Chrome](/layout/chrome) ### [Chrome](/layout/chrome)
Simply the decoration of your site. Support for the above templates

View file

@ -43,38 +43,44 @@ variables](/layout/variables) for a complete list.
## Example li.html ## Example li.html
This content template is used for [spf13.com](http://spf13.com). This content template is used for [spf13.com](http://spf13.com).
<li> {{% highlight html %}}
<a href="{{ .Permalink }}">{{ .Title }}</a> <li>
<div class="meta">{{ .Date.Format "Mon, Jan 2, 2006" }}</div> <a href="{{ .Permalink }}">{{ .Title }}</a>
</li> <div class="meta">{{ .Date.Format "Mon, Jan 2, 2006" }}</div>
</li>
{{% /highlight %}}
## Example summary.html ## Example summary.html
This content template is used for [spf13.com](http://spf13.com). This content template is used for [spf13.com](http://spf13.com).
<article class="post"> {{% highlight html %}}
<header> <article class="post">
<h2><a href='{{ .Permalink }}'> {{ .Title }}</a> </h2> <header>
<div class="post-meta">{{ .Date.Format "Mon, Jan 2, 2006" }} - {{ .FuzzyWordCount }} Words </div> <h2><a href='{{ .Permalink }}'> {{ .Title }}</a> </h2>
</header> <div class="post-meta">{{ .Date.Format "Mon, Jan 2, 2006" }} - {{ .FuzzyWordCount }} Words </div>
</header>
{{ .Summary }} {{ .Summary }}
<footer> <footer>
<a href='{{ .Permalink }}'><nobr>Read more →</nobr></a> <a href='{{ .Permalink }}'><nobr>Read more →</nobr></a>
</footer> </footer>
</article> </article>
{{% /highlight %}}
## Example render of view ## Example render of view
Using the summary view inside of another ([index](/layout/index)) template. Using the summary view inside of another ([index](/layout/index)) template.
<section id="main"> {{% highlight html %}}
<div> <section id="main">
<h1 id="title">{{ .Title }}</h1> <div>
{{ range .Data.Pages }} <h1 id="title">{{ .Title }}</h1>
{{ .Render "summary"}} {{ range .Data.Pages }}
{{ end }} {{ .Render "summary"}}
</div> {{ end }}
</section> </div>
</section>
{{% /highlight %}}
In the above example you will notice that we have called .Render and passed in In the above example you will notice that we have called .Render and passed in
which view to render the content with. Render is a special function available on which view to render the content with. Render is a special function available on

View file

@ -8,12 +8,9 @@ groups_weight: 50
Hugo is released under the Simple Public License. Hugo is released under the Simple Public License.
## Simple Public License (SimPL-2.0)
Simple Public License (SimPL-2.0) ### Preamble
=================================
Preamble
--------
This Simple Public License 2.0 (SimPL-2.0 for short) is a plain language This Simple Public License 2.0 (SimPL-2.0 for short) is a plain language
implementation of GPL 2.0. The words are different, but the goal is the implementation of GPL 2.0. The words are different, but the goal is the
@ -22,8 +19,7 @@ software. If anyone wonders about the meaning of the SimPL, they should
interpret it as consistent with GPL 2.0. interpret it as consistent with GPL 2.0.
Simple Public License (SimPL) 2.0 ## Simple Public License (SimPL) 2.0
=================================
The SimPL applies to the software's source and object code and comes The SimPL applies to the software's source and object code and comes
with any rights that I have in it (other than trademarks). You agree to with any rights that I have in it (other than trademarks). You agree to
@ -68,8 +64,7 @@ automatically if:
- Anyone prevents you from distributing the software under the terms - Anyone prevents you from distributing the software under the terms
of the SimPL. of the SimPL.
License for the License ## License for the License
-----------------------
You may do anything that you want with the SimPL text; it's a license You may do anything that you want with the SimPL text; it's a license
form to use in any way that you find helpful. To avoid confusion, form to use in any way that you find helpful. To avoid confusion,

View file

@ -6,7 +6,7 @@ groups: ["meta"]
groups_weight: 10 groups_weight: 10
--- ---
* **0.9.0** ## **0.9.0** November 15, 2013
* New command based interface similar to git (hugo server -s ./ ) * New command based interface similar to git (hugo server -s ./ )
* Amber template support * Amber template support
* Aliases (redirects) * Aliases (redirects)
@ -38,7 +38,8 @@ groups_weight: 10
* Support for go 1.2 * Support for go 1.2
* Support for `first` in templates * Support for `first` in templates
* Support for site per-section permalink pattern specifications * Support for site per-section permalink pattern specifications
* **0.8.0** August 2, 2013
## **0.8.0** August 2, 2013
* Added support for pretty urls (filename/index.html vs filename.html) * Added support for pretty urls (filename/index.html vs filename.html)
* Hugo supports a destination directory * Hugo supports a destination directory
* Will efficiently sync content in static to destination directory * Will efficiently sync content in static to destination directory
@ -51,11 +52,14 @@ groups_weight: 10
* Support for series * Support for series
* Adding verbose output * Adding verbose output
* Loads of bugfixes * Loads of bugfixes
* **0.7.0** July 4, 2013
## **0.7.0** July 4, 2013
* Hugo now includes a simple server * Hugo now includes a simple server
* First public release * First public release
* **0.6.0** July 2, 2013
## **0.6.0** July 2, 2013
* Hugo includes an example documentation site which it builds * Hugo includes an example documentation site which it builds
* **0.5.0** June 25, 2013
## **0.5.0** June 25, 2013
* Hugo is quite usable and able to build spf13.com * Hugo is quite usable and able to build spf13.com

View file

@ -20,33 +20,34 @@ then look for a `config.json` file, followed by a `config.toml` file.
## Examples ## Examples
The following is an example of a yaml config file with the default values: The following is an example of a yaml config file with the default values:
{{% highlight yaml %}}
--- ---
contentdir: "content" contentdir: "content"
layoutdir: "layouts" layoutdir: "layouts"
publishdir: "public" publishdir: "public"
builddrafts: false builddrafts: false
indexes: indexes:
category: "categories" category: "categories"
tag: "tags" tag: "tags"
baseurl: "http://yoursite.example.com/" baseurl: "http://yoursite.example.com/"
... ...
{{% /highlight %}}
The following is an example of a json config file with the default values: The following is an example of a json config file with the default values:
{ {{% highlight json %}}
"contentdir": "content", {
"layoutdir": "layouts", "contentdir": "content",
"publishdir": "public", "layoutdir": "layouts",
"builddrafts": false, "publishdir": "public",
"indexes": { "builddrafts": false,
"category": "categories", "indexes": {
"tag": "tags" "category": "categories",
}, "tag": "tags"
"baseurl": "http://yoursite.example.com/" },
} "baseurl": "http://yoursite.example.com/"
}
{{% /highlight %}}
The following is an example of a toml config file with the default values: The following is an example of a toml config file with the default values:
@ -61,18 +62,19 @@ The following is an example of a toml config file with the default values:
Here is a yaml configuration file which sets a few more options Here is a yaml configuration file which sets a few more options
--- {{% highlight yaml %}}
baseurl: "http://yoursite.example.com/" ---
title: "Yoyodyne Widget Blogging" baseurl: "http://yoursite.example.com/"
permalinks: title: "Yoyodyne Widget Blogging"
post: /:year/:month/:title/ permalinks:
params: post: /:year/:month/:title/
Subtitle: "Spinning the cogs in the widgets" params:
AuthorName: "John Doe" Subtitle: "Spinning the cogs in the widgets"
GitHubUser: "spf13" AuthorName: "John Doe"
ListOfFoo: GitHubUser: "spf13"
- "foo1" ListOfFoo:
- "foo2" - "foo1"
SidebarRecentLimit: 5 - "foo2"
... SidebarRecentLimit: 5
...
{{% /highlight %}}