From: spf13 Date: Tue, 27 May 2014 22:32:57 +0000 (-0400) Subject: Updating / Rewriting / Adding all of the documentation in preparation for the next... X-Git-Tag: v0.11~19 X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=a87f171bd4446773e05198427e920571af63e650;p=brevno-suite%2Fhugo Updating / Rewriting / Adding all of the documentation in preparation for the next release --- diff --git a/docs/config.toml b/docs/config.toml index 852cb14c..11b968c7 100644 --- a/docs/config.toml +++ b/docs/config.toml @@ -1,27 +1,46 @@ baseurl = "http://hugo.spf13.com" +MetaDataFormat = "yaml" [indexes] tag = "tags" group = "groups" +[[menu.main]] + name = "about hugo" + pre = "" + weight = -110 + identifier = "about" [[menu.main]] name = "getting started" + pre = "" weight = -100 [[menu.main]] name = "content" + pre = "" weight = -90 [[menu.main]] - name = "layout" + name = "themes" + pre = "" + weight = -85 +[[menu.main]] + name = "templates" + identifier = "layout" + pre = "" weight = -80 [[menu.main]] - name = "taxonomy" + name = "taxonomies" + identifier = "taxonomy" + pre = "" weight = -70 [[menu.main]] name = "extras" + pre = "" weight = -60 [[menu.main]] name = "community" + pre = "" weight = -50 [[menu.main]] name = "tutorials" + pre = "" weight = -40 diff --git a/docs/content/community/contributing.md b/docs/content/community/contributing.md index c4f5aabd..74a74a10 100644 --- a/docs/content/community/contributing.md +++ b/docs/content/community/contributing.md @@ -6,11 +6,16 @@ weight: 30 menu: main: parent: 'community' +prev: "/community/press" +next: "/community/contributors" --- -We welcome all contributions. Feel free to pick something from the roadmap +All contributions to Hugo are welcome. Whether you want to scratch an itch, or simply contribute to the project. Feel free to pick something from the roadmap or contact [spf13](http://spf13.com) about what may make sense -to do next. Go ahead and fork the project and make your changes. *We encourage pull requests to discuss code changes.* +to do next. + +You should fork the project and make your changes. *We encourage pull requests to discuss code changes.* + When you're ready to create a pull request, be sure to: diff --git a/docs/content/community/contributors.md b/docs/content/community/contributors.md index 316c35d7..806cdae2 100644 --- a/docs/content/community/contributors.md +++ b/docs/content/community/contributors.md @@ -7,11 +7,12 @@ notoc: true menu: main: parent: 'community' +prev: "/community/contributing" +next: "/tutorials/github_pages_blog" --- Hugo was built with love and Go by: * Steve Francia - [spf13](https://github.com/spf13) -* Noah Campbell - [noahcampbell](https://github.com/noahcampbell) * [Many more](http://github.com/spf13/hugo/graphs/contributors) diff --git a/docs/content/community/mailing-list.md b/docs/content/community/mailing-list.md index 6a9dc813..cc9debac 100644 --- a/docs/content/community/mailing-list.md +++ b/docs/content/community/mailing-list.md @@ -5,6 +5,8 @@ weight: 10 menu: main: parent: 'community' +prev: "/extras/urls" +next: "/community/press" --- Hugo has two mailing lists: diff --git a/docs/content/community/press.md b/docs/content/community/press.md index c778e4e9..207ebd0a 100644 --- a/docs/content/community/press.md +++ b/docs/content/community/press.md @@ -4,6 +4,8 @@ date = 2014-03-24T20:00:00Z linktitle = "Press" weight = 20 notoc = true +prev = "/community/mailing-list" +next = "/community/contributing" [menu.main] parent = "community" +++ diff --git a/docs/content/content/archetypes.md b/docs/content/content/archetypes.md new file mode 100644 index 00000000..59287db9 --- /dev/null +++ b/docs/content/content/archetypes.md @@ -0,0 +1,76 @@ ++++ +title = "Archetypes" +date = 2014-05-14T02:13:50Z +weight = 50 +prev = "/content/types" +next = "/content/ordering" + +[menu] + [menu.main] + parent = "content" ++++ + +Hugo v0.11 introduced the concept of a content builder. Using the +command: `hugo new [relative new content path]` you can start a content file +with the date and title automatically set. This is a welcome feature, but +active writers need more. + +Hugo presents the concept of archetypes which are archetypal content files. + +## Example archetype + +In this example scenario I have a blog with a single content type (blog post). +I use ‘tags’ and ‘categories’ for my taxonomies. + +### archetypes/default.md + + +++ + tags = ["x", "y"] + categories = ["x", "y"] + +++ + + +## using archetypes + +If I wanted to create a new post in the `posts` section I would run the following command... + +`hugo new posts/my-new-post.md` + +Hugo would create the file with the following contents: + +### contents/posts/my-new-post.md + + +++ + title = "my new post" + date = 2014-05-14T02:13:50Z + tags = ["x", "y"] + categories = ["x", "y"] + +++ + + +## Using a different front matter format + +By default the front matter will be created in the TOML format +regardless of what format the archetype is using. + +You can specify a different default format in your config file using +the `MetaDataFormat` directive. Possible values are `toml`, `yaml` and `json`. + + +## Which archtype is being used + +The following rules apply: + +* If an archetype with a filename that matches the content type being created it will be used. +* If no match is found `archetypes/default.md` will be used. +* If neither are present and a theme is in use then within the theme... + * If an archetype with a filename that matches the content type being created it will be used. + * If no match is found `archetypes/default.md` will be used. +* If no archetype files are present then the one that ships with hugo will be used. + +Hugo provides a simple archetype which sets the title (based on the +file name) and the date based on now(). + +Content type is automatically detected based on the path. You are welcome to declare which +type to create using the `--kind` flag during creation. + diff --git a/docs/content/content/example.md b/docs/content/content/example.md index 2fc07015..fb9421af 100644 --- a/docs/content/content/example.md +++ b/docs/content/content/example.md @@ -6,8 +6,10 @@ linktitle: "Example" menu: main: parent: 'content' -weight: 50 +weight: 70 notoc: true +prev: '/content/ordering' +next: '/themes/overview' --- Somethings are better shown than explained. The following is a very basic example of a content file: diff --git a/docs/content/content/front-matter.md b/docs/content/content/front-matter.md index e67dafd9..eec83df9 100644 --- a/docs/content/content/front-matter.md +++ b/docs/content/content/front-matter.md @@ -2,10 +2,13 @@ title = "Front Matter" date = "2013-07-01" aliases = ["/doc/front-matter/"] -weight = 40 +weight = 20 +prev = "/content/organization" +next = "/content/sections" [menu.main] parent = "content" + +++ The front matter is one of the features that gives Hugo its strength. It enables diff --git a/docs/content/content/ordering.md b/docs/content/content/ordering.md index 926a539f..81fcf0e7 100644 --- a/docs/content/content/ordering.md +++ b/docs/content/content/ordering.md @@ -6,12 +6,16 @@ menu: main: parent: "content" weight: 60 +prev: '/content/archetypes' +next: '/content/example' --- -In Hugo you have a good degree of control of how your content can be ordered. +Hugo provides you with all the flexibility you need to organize how your content is ordered. -By default, content is ordered by weight, then by date with the most recent -date first, but alternative sorting (by title and linktitle) is also available. +By default, content is ordered by weight, then by date with the most +recent date first, but alternative sorting (by title and linktitle) is +also available. The order the content will appear will be specified in +the [list template](/templates/list). _Both the date and weight fields are optional._ @@ -29,71 +33,7 @@ guaranteed. +++ Front Matter with Ordered Pages 3 -## Order by Weight -> Date (default) - {{ range .Data.Pages }} -
  • - {{ .Title }} -
    {{ .Date.Format "Mon, Jan 2, 2006" }}
    -
  • - {{ end }} +## Ordering Content Within Taxonomies -## Order by Weight -> Date - - {{ range .Data.Pages.ByWeight }} -
  • - {{ .Title }} -
    {{ .Date.Format "Mon, Jan 2, 2006" }}
    -
  • - {{ end }} - -## Order by Date - - {{ range .Data.Pages.ByDate }} -
  • - {{ .Title }} -
    {{ .Date.Format "Mon, Jan 2, 2006" }}
    -
  • - {{ end }} - -## Order by Length - - {{ range .Data.Pages.ByLength }} -
  • - {{ .Title }} -
    {{ .Date.Format "Mon, Jan 2, 2006" }}
    -
  • - {{ end }} - -## Reverse Order -Can be applied to any of the above. Using Date for an example. - - {{ range .Data.Pages.ByDate.Reverse }} -
  • - {{ .Title }} -
    {{ .Date.Format "Mon, Jan 2, 2006" }}
    -
  • - {{ end }} - -## Order by Title - - {{ range .Data.Pages.ByTitle }} -
  • - {{ .Title }} -
    {{ .Date.Format "Mon, Jan 2, 2006" }}
    -
  • - {{ end }} - -## Order by LinkTitle - - {{ range .Data.Pages.ByLinkTitle }} -
  • - {{ .LinkTitle }} -
    {{ .Date.Format "Mon, Jan 2, 2006" }}
    -
  • - {{ end }} - - -## Ordering Content Within Indexes - -Please see the [Index Ordering Documentation](/indexes/ordering/) +Please see the [Taxonomy Ordering Documentation](/taxonomies/ordering/) diff --git a/docs/content/content/organization.md b/docs/content/content/organization.md index 832edc55..8f154486 100644 --- a/docs/content/content/organization.md +++ b/docs/content/content/organization.md @@ -7,17 +7,21 @@ weight: 10 menu: main: parent: 'content' +prev: '/overview/source-directory' +next: '/content/front-matter' --- -Hugo uses markdown files with headers commonly called the front matter. Hugo respects the organization -that you provide for your content to minimize any extra configuration, though this can be overridden -by additional configuration in the front matter. +Hugo uses markdown files with headers commonly called the front matter. Hugo +respects the organization that you provide for your content to minimize any +extra configuration, though this can be overridden by additional configuration +in the front matter. ## Organization -In Hugo the content should be arranged in the same way they are intended for the rendered website. -Without any additional configuration the following will just work. Hugo supports -content nested at any level. The top level is special in Hugo and is used as the -[section](/content/sections). + +In Hugo the content should be arranged in the same way they are intended for +the rendered website. Without any additional configuration the following will +just work. Hugo supports content nested at any level. The top level is special +in Hugo and is used as the [section](/content/sections). . └── content diff --git a/docs/content/content/sections.md b/docs/content/content/sections.md index ea9d75dd..94bb0289 100644 --- a/docs/content/content/sections.md +++ b/docs/content/content/sections.md @@ -4,8 +4,10 @@ date: "2013-07-01" menu: main: parent: 'content' -weight: 20 +weight: 30 notoc: true +prev: '/content/front-matter' +next: '/content/types' --- Hugo thinks that you organize your content with a purpose. The same structure @@ -26,6 +28,13 @@ The following example site uses two sections, "post" and "quote". ├── first.md // <- http://1.com/quote/first/ └── second.md // <- http://1.com/quote/second/ + +## Section Lists + +Hugo will automatically create pages for each section root that list all +of the content in that section. See [List Templates](/templates/list) +for details on customizing the way they appear. + ## Sections and Types By default everything created within a section will use the content type @@ -40,5 +49,3 @@ If a layout for a given type hasn't been provided a default type template will be used instead provided is exists. - - diff --git a/docs/content/content/types.md b/docs/content/content/types.md index 0448e026..563e6f7c 100644 --- a/docs/content/content/types.md +++ b/docs/content/content/types.md @@ -5,32 +5,63 @@ linktitle: "Types" menu: main: parent: 'content' -weight: 30 +weight: 40 +prev: '/content/sections' +next: '/content/archetypes' --- -Hugo has full support for multiple content types each with its own set -of meta data and template. A good example of when multiple types are -needed is to look at Tumblr. A piece of content could be a photo, quote -or post, each with different meta data and rendered differently. +Hugo has full support for different types of content. A content type can have a +unique set of meta data, template and can be automatically created by the new +command through using content [archetypes](/content/archetypes). + +A good example of when multiple types are needed is to look at Tumblr. A piece +of content could be a photo, quote or post, each with different meta data and +rendered differently. + +## Assigning a content type + +Hugo assumes that your site will be organized into [sections](/content/sections) +and each section will use the corresponding type. If you are taking advantage of +this then each new piece of content you place into a section will automatically +inherit the type. + +Alternatively you can set the type in the meta data under the key "type". + + +## Creating new content of a specific type + +Hugo has the ability to create a new content file and populate the front matter +with the data set corresponding to that type. Hugo does this by utilizing +[archetypes](/content/archetypes). + +To create a new piece of content use: + + hugo new relative/path/to/content.md + +For example if I wanted to create a new post inside the post section I would type: + + hugo new post/my-newest-post.md + ## Defining a content type -Creating a new content type is easy in Hugo. You simply provide the -templates that the new type will use. +Creating a new content type is easy in Hugo. You simply provide the templates and archetype +that the new type will use. You only need to define the templates, archetypes and/or views +unique to that content type. Hugo will fall back to using the general templates and default archetype +whenever a specific file is not present. -It is essential to provide the single render view template as well as a -list view template. +*Remember, all of the following are optional:* -### Step 1: Create Type Directory +### Create Type Directory Create a directory with the name of the type in layouts.Type is always singular. *Eg /layouts/post*. -### Step 2: Create template +### Create single template Create a file called single.html inside your directory. *Eg /layouts/post/single.html*. -### Step 3: Create list template -Create a file with the same name as your directory in /layouts/indexes/. *Eg /layouts/indexes/post.html*. +### Create list template +Create a file called list.html inside your directory *Eg /layouts/post/list.html*. -### Step 4: Create views +### Create views 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 of contents on a single page. Hugo makes no assumptions here about how you want @@ -38,13 +69,8 @@ to display your content, and will support as many different views of a content type as your site requires. All that is required for these additional views is that a template exists in each layout/type directory with the same name. -For these, reviewing this example site will be very helpful in order to understand how these types work. - -## Assigning a content type +### Create a corresponding archetype -Hugo assumes that your site will be organized into [sections](/content/sections) -and each section will use the corresponding type. If you are taking advantage of -this then each new piece of content you place into a section will automatically -inherit the type. +Create a file called `type`.md in the /archetypes directory *Eg /archetypes/post.md*. -Alternatively you can set the type in the meta data under the key "type". +More details about archetypes can be found at the [archetypes docs](/content/archetypes) diff --git a/docs/content/extras/aliases.md b/docs/content/extras/aliases.md index c2d6eb01..122e9981 100644 --- a/docs/content/extras/aliases.md +++ b/docs/content/extras/aliases.md @@ -5,10 +5,12 @@ aliases: - /doc/redirects/ - /doc/alias/ - /doc/aliases/ -weight: 20 +weight: 10 menu: main: parent: 'extras' +prev: "/taxonomies/ordering" +next: "/extras/builders" --- For people migrating existing published content to Hugo theres a good chance diff --git a/docs/content/extras/builders.md b/docs/content/extras/builders.md new file mode 100644 index 00000000..4fdae941 --- /dev/null +++ b/docs/content/extras/builders.md @@ -0,0 +1,60 @@ +--- +title: "Hugo Builders" +linktitle: "Builders" +date: "2014-05-26" +weight: 12 +menu: + main: + parent: 'extras' +prev: "/extras/aliases" +next: "/extras/comments" +--- + +Hugo provides the functionality to quickly get a site, theme or page +started. + + +## New Site + +Want to get a site built quickly?. + + hugo new site /path/to/site + +Hugo will create all the needed directories and files to get started +quickly. + +Hugo will only touch the files and create the directories (in the right +places), [configuration](/overview/configuration) and content are up to +you... but luckily we have builders for content (see below). + +## New Theme + +Want to design a new theme? + + hugo new theme `THEME_NAME` + +Run from your working directory, this will create a new theme with all +the needed files in your themes directory. Hugo will provide you with a +license and theme.toml file with most of the work done for you. + +Follow the [Theme Creation Guide](/themes/creation) once the builder is +done. + +## New Content + +You will use this builder the most of all. Every time you want to create +a new piece of content, the content builder will get you started right. + +Leveraging [content archetypes](/content/archetypes) the content builder +will not only insert the current date and appropriate metadata, but it +will pre-populate values based on the content type. + + hugo new relative/path/to/content + +This assumes it is being run from your working directory and the content +path starts from your content directory. + +I typically keep two different terminals open, one to run `hugo server +--watch`, and another to use the builders to create new content. + + diff --git a/docs/content/extras/comments.md b/docs/content/extras/comments.md new file mode 100644 index 00000000..3ff95134 --- /dev/null +++ b/docs/content/extras/comments.md @@ -0,0 +1,67 @@ +--- +title: "Comments in Hugo" +linktitle: "Comments" +date: "2014-05-26" +weight: 14 +menu: + main: + parent: 'extras' +prev: "/extras/builders" +next: "/extras/livereload" +--- + +As Hugo is a static site generator, the content produced is static and +doesn’t interact with the users. The most common interaction people ask +for is comment capability. + +Hugo ships with support for [disqus](http://disqus.com), a third party +service that provides comment and community capabilities to website via +javascript. + +Your theme may already support disqus, but even it if doesn’t it is easy +to add. + +# Disqus Support + +## Adding Disqus to a template + +Hugo comes with all the code you would need to include load disqus. +Simply include the following line where you want your comments to appear + + {{ template "_internal/disqus.html" . }} + + +## Configuring Disqus + +That template requires you to set a single value in your site config file, eg. config.yaml. + + disqusShortname = "XYW" + +Additionally you can optionally set the following in the front matter +for a given piece of content + + * **disqus_identifier** + * **disqus_title** + * **disqus_url** + +# Alternatives + +A few alternatives exist to Disqus. + +* [Intense Debate](http://intensedebate.com/) +* [LiveFyre](http://livefyre.com/) +* [Moot](http://muut.com) +* [Kaiju](http://github.com/spf13/kaiju) + + +[Kaiju](http://github.com/spf13/kaiju) is a open source project started +by [spf13](http://spf13.com) (Hugo’s author) to bring easy and fast real +time discussions to the web. + +Written using Go, Socket.io and MongoDB it is very fast and easy to +deploy. + +It is in early development but shows promise.. If you have interest +please help by contributing whether via a pull request, an issue or even +just a tweet. Everything helps. + diff --git a/docs/content/extras/highlighting.md b/docs/content/extras/highlighting.md index 6183ee42..de9812d0 100644 --- a/docs/content/extras/highlighting.md +++ b/docs/content/extras/highlighting.md @@ -1,10 +1,12 @@ --- -title: "Highlighting" +title: "Syntax Highlighting" date: "2013-07-01" -weight: 15 +weight: 50 menu: main: parent: 'extras' +prev: "/extras/shortcodes" +next: "/extras/toc" --- Hugo provides the ability for you to highlight source code in two different diff --git a/docs/content/extras/livereload.md b/docs/content/extras/livereload.md new file mode 100644 index 00000000..ee2a586b --- /dev/null +++ b/docs/content/extras/livereload.md @@ -0,0 +1,61 @@ +--- +title: "Live Reload" +date: "2014-05-26" +weight: 15 +menu: + main: + parent: 'extras' +prev: "/extras/comments" +next: "/extras/menus" +--- + +Hugo may not be the first static site generator to utilize live reload +technology, but it’s the first to do it right. + +The combination of Hugo’s insane build speed and live reload make +crafting your content pure joy. Virtually instantly after you hit save +your rebuilt content will appear in your browser. + +## Using livereload + +Hugo comes with livereload built in. There are no additional packages to +install. A common way to use hugo while developing a site is to have +hugo run a server and watch for changes. + + hugo server --watch + +This will run a full functioning web server while simultaneously +watching your file system for additions, deletions or changes within +your: + + * static files + * content + * layouts + * current theme + +Whenever anything changes Hugo will rebuild the site, continue to serve +the content and as soon as the build is finished it will tell the +browser and silently reload the page. Because most hugo builds are so +fast they are barely noticeable, you merely need to glance at your open +browser and you will see the change already there. + +This means that keeping the site open on a second monitor (or another +half of your current monitor), allows you to see exactly what your +content looks like without even leaving your text editor. + +## Disabling livereload + +Live reload accomplishes this by injecting javascript into the pages it +creates that creates a web socket client to the hugo web socket server. + +Awesome for development, but not something you would want to do in +production. Since many people use `hugo server --watch` in production to +instantly display any updated content, we’ve made it easy to disable the +live reload functionality. + + hugo server --watch --disableLiveReload + + + + + diff --git a/docs/content/extras/menus.md b/docs/content/extras/menus.md new file mode 100644 index 00000000..070729c0 --- /dev/null +++ b/docs/content/extras/menus.md @@ -0,0 +1,162 @@ ++++ +title = "Menus" +weight = 20 +prev = "/extras/livereload" +next = "/extras/permalinks" +date = 2014-05-14T02:36:37Z +[menu] + [menu.main] + parent = "extras" ++++ + +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. + +Some of the features of Hugo Menus: + +* Place content in one or many menus +* Handle nested menus with unlimited depth +* Create menu entries without being attached to any content +* Distinguish active element (and active branch) + +## What is a menu? + +A menus is a named array of menu entries accessible on the site under +.Site.Menus by name. For example if I have a menu called `main` I would +access it via .Site.Menus.main. + +A menu entry has the following properties: + +* **Url** string +* **Name** string +* **Menu** string +* **Identifier** string +* **Pre** template.HTML +* **Post** template.HTML +* **Weight** int +* **Parent** string +* **Children** Menu + + +Additionally there are some relevant functions available on the page: + + * **HasChildren** bool + * **IsMenuCurrent** (menu string, menuEntry *MenuEntry ) bool + * **HasMenuCurrent** (menu string, menuEntry *MenuEntry) bool + + +## Adding content to menus + +Hugo supports a couple of different methods of adding a piece of content +to the front matter. + +### Simple + +If all you need to do is add an entry to a menu, the simple form works +well. + +**A single menu:** + + --- + menu: "main" + --- + +**Multiple menus:** + + --- + menu: ["main", "footer"] + --- + + +### Advanced + +If more control is required, then the advanced approach gives you the +control you want. All of the menu entry properties listed above are +available. + + --- + menu: + main: + parent: 'extras' + weight: 20 + --- + + +## Adding (non-content) entries to a menu + +You can also add entries to menus that aren’t attached to a piece of +content. This takes place in the site wide config file. + +Here’s an example (in toml): + + [[menu.main]] + name = "about hugo" + pre = "" + weight = -110 + identifier = "about" + [[menu.main]] + name = "getting started" + pre = "" + weight = -100 + +## Nesting + +All nesting of content is done via the `parent` field. + +The parent of an entry should be the identifier of another entry. +Identifier should be unique (within a menu). + +The following order is used to determine identity Identifier > Name > +LinkTitle > Title. This means that the title will be used unless +linktitle is present, etc. In practice Name and Identifier are never +displayed and only used to structure relationships. + +In this example, the top level of the menu is defined in the config file +and all content entries are attached to one of these entries via the +`parent` field. + +## Rendering menus + +Hugo makes no assumptions about how your rendered HTML will be +structured, instead it provides all of the functions you will need to be +able to build your menu however you want. + + +The following is an example: + + + + diff --git a/docs/content/extras/permalinks.md b/docs/content/extras/permalinks.md index e36fb9d3..6282e61c 100644 --- a/docs/content/extras/permalinks.md +++ b/docs/content/extras/permalinks.md @@ -8,6 +8,8 @@ notoc: true menu: main: parent: 'extras' +prev: "/extras/menus" +next: "/extras/shortcodes" --- By default, content is laid out into the target `publishdir` (public) diff --git a/docs/content/extras/shortcodes.md b/docs/content/extras/shortcodes.md index a72b4b53..a9b2a31c 100644 --- a/docs/content/extras/shortcodes.md +++ b/docs/content/extras/shortcodes.md @@ -2,10 +2,12 @@ title: "Shortcodes" date: "2013-07-01" aliases: ["/doc/shortcodes/"] -weight: 10 +weight: 40 menu: main: parent: 'extras' +prev: "/extras/permalinks" +next: "/extras/highlighting" --- Because Hugo uses markdown for its simple content format, however there's a lot diff --git a/docs/content/extras/toc.md b/docs/content/extras/toc.md index bac221c6..f91511c2 100644 --- a/docs/content/extras/toc.md +++ b/docs/content/extras/toc.md @@ -1,10 +1,12 @@ --- title: "Table of Contents" date: "2013-07-09" -weight: 70 +weight: 60 menu: main: parent: 'extras' +prev: "/extras/highlighting" +next: "/extras/urls" --- Hugo will automatically parse the markdown for your content and create @@ -24,12 +26,12 @@ Hugo will take this markdown and create a table of contents stored in the This is example code of a [single.html template](/layout/content). - {{ template "chrome/header.html" . }} + {{ template "partials/header.html" . }}
    {{ .TableOfContents }}

    {{ .Title }}

    {{ .Content }} - {{ template "chrome/footer.html" . }} + {{ template "partials/footer.html" . }} diff --git a/docs/content/extras/urls.md b/docs/content/extras/urls.md index 043b472d..123bc87d 100644 --- a/docs/content/extras/urls.md +++ b/docs/content/extras/urls.md @@ -3,11 +3,13 @@ title: "URLs" date: "2014-01-03" aliases: - "/doc/urls/" -weight: 40 +weight: 70 notoc: true menu: main: parent: 'extras' +prev: "/extras/toc" +next: "/community/mailing-list" --- ## Pretty Urls @@ -16,7 +18,7 @@ By default Hugo will create content with 'pretty' urls. For example content created at /content/extras/urls.md will be rendered at /content/extras/urls/index.html and accessible at /content/extras/urls. No no standard server side configuration is required for these pretty urls to -work. +work. If you would like to have uglyurls you are in luck. Hugo supports the ability to create your entire site with ugly urls. Simply use the diff --git a/docs/content/layout/404.md b/docs/content/layout/404.md deleted file mode 100644 index f2e62a50..00000000 --- a/docs/content/layout/404.md +++ /dev/null @@ -1,35 +0,0 @@ ---- -title: "404.html Templates" -date: "2013-08-21" -notoc: true -menu: - main: - parent: 'layout' ---- - -When using Hugo with [github pages](http://pages.github.com/) you can provide -your own 404 template by creating a 404.html file in the root. - -404 pages are of the type "node" and have all the [node -variables](/layout/variables/) available to use in the templates. - -In addition to the standard node variables, the homepage has access to -all site content accessible from .Data.Pages - - ▾ layouts/ - 404.html - -## 404.html -This is a basic example of a 404.html template: - - {{ template "chrome/header.html" . }} - {{ template "chrome/subheader.html" . }} - -
    -
    -

    {{ .Title }}

    -
    -
    - - {{ template "chrome/footer.html" }} - diff --git a/docs/content/layout/chrome.md b/docs/content/layout/chrome.md deleted file mode 100644 index 9c586d0a..00000000 --- a/docs/content/layout/chrome.md +++ /dev/null @@ -1,82 +0,0 @@ ---- -title: "Chrome Templates" -date: "2013-07-01" -weight: 80 -menu: - main: - parent: 'layout' ---- -Chrome is a convention to create templates that are used by the other templates -throughout the site. There is nothing special about the name "chrome", feel free -to provide and use your own. - -It's not a requirement to have this, but in practice it's very convenient. Hugo doesn't -know anything about Chrome, it's simply a convention that you may likely find -beneficial. As you create the rest of your templates you will include templates -from the /layout/chrome directory. - -I've found it helpful to include a header and footer template in Chrome so I can -include those in the other full page layouts (index.html, indexes/ -type/single.html). There is nothing special about header.html and footer.html -other than they seem like good names to use for inclusion in your other -templates. - - ▾ layouts/ - ▾ chrome/ - header.html - footer.html - -By ensuring that we only reference [variables](/layout/variables/) variables -used for both nodes and pages we can use the same chrome for both. - -## example header.html -This header template is used for [spf13.com](http://spf13.com). - - - - - - - {{ template "chrome/meta.html" . }} - - - {{ .Title }} : spf13.com - - {{ if .RSSlink }}{{ end }} - - {{ template "chrome/head_includes.html" . }} - - - -## example footer.html -This header template is used for [spf13.com](http://spf13.com). - - - - - - -**For examples of referencing these templates, see [content -templates](/layout/content/) and [homepage templates](/layout/homepage/)** diff --git a/docs/content/layout/content.md b/docs/content/layout/content.md deleted file mode 100644 index f5efffed..00000000 --- a/docs/content/layout/content.md +++ /dev/null @@ -1,132 +0,0 @@ ---- -title: "Content Templates" -date: "2013-07-01" -menu: - main: - parent: 'layout' ---- - -Content templates are created in a directory matching the name of the content. - -Content pages are of the type "page" and have all the [page -variables](/layout/variables/) available to use in the templates. - -In the following examples we have created two different content types as well as -a default content type. - - ▾ layouts/ - ▾ post/ - single.html - ▾ project/ - single.html - -Hugo also has support for a default content template to be used in the event -that a specific template has not been provided for that type. The default type -works the same as the other types but the directory must be called "_default". -[Content views](/layout/views) can also be defined in the "_default" directory. - - - ▾ layouts/ - ▾ _default/ - single.html - - - - -## post/single.html -This content template is used for [spf13.com](http://spf13.com). -It makes use of [chrome templates](/layout/chrome) - - {{ template "chrome/header.html" . }} - {{ template "chrome/subheader.html" . }} - {{ $baseurl := .Site.BaseUrl }} - -
    -

    {{ .Title }}

    -
    -
    - {{ .Content }} -
    -
    -
    - - - - {{ template "chrome/disqus.html" . }} - {{ template "chrome/footer.html" . }} - - -## project/single.html -This content template is used for [spf13.com](http://spf13.com). -It makes use of [chrome templates](/layout/chrome) - - - {{ template "chrome/header.html" . }} - {{ template "chrome/subheader.html" . }} - {{ $baseurl := .Site.BaseUrl }} - -
    -

    {{ .Title }}

    -
    -
    - {{ .Content }} -
    -
    -
    - - - - {{if isset .Params "project_url" }} -
    - Fork me on GitHub -
    - {{ end }} - - {{ template "chrome/footer.html" }} - - -Notice how the project/single.html template uses an additional parameter unique -to this template. This doesn't need to be defined ahead of time. If the key is -present in the front matter than it can be used in the template. diff --git a/docs/content/layout/functions.md b/docs/content/layout/functions.md deleted file mode 100644 index f9cb7f8e..00000000 --- a/docs/content/layout/functions.md +++ /dev/null @@ -1,105 +0,0 @@ ---- -title: "Template Functions" -date: "2013-07-01" -linktitle: "Template Functions" -weight: 70 -menu: - main: - parent: 'layout' ---- - -Hugo uses the excellent go html/template library for its template engine. -It is an extremely lightweight engine that provides a very small amount of -logic. In our experience that it is just the right amount of logic to be able -to create a good static website. - -Go templates are lightweight but extensible. Hugo has added the following -functions to the basic template logic. - -Go documentation for the built-in functions can be found [here](http://golang.org/pkg/text/template/) - -## General - -### isset -Return true if the parameter is set. -Takes either a slice, array or channel and an index or a map and a key as input. - -eg. {{ if isset .Params "project_url" }} {{ index .Params "project_url" }}{{ end }} - -### echoParam -If parameter is set, then echo it. - -eg. {{echoParam .Params "project_url" }} - -### first -Slices an array to only the first X elements. - -eg. - {{ range first 10 .Data.Pages }} - {{ .Render "summary"}} - {{ end }} - - -## Math - -### add -Adds two integers. - -eg {{add 1 2}} -> 3 - -### sub -Subtracts two integers. - -eg {{sub 3 2}} -> 1 - -### div -Divides two integers. - -eg {{div 6 3}} -> 2 - -### mul -Multiplies two integers. - -eg {{mul 2 3}} -> 6 - -### mod -Modulus of two integers. - -eg {{mod 15 3}} -> 0 - -### modBool -Boolean of modulus of two integers. -true if modulus is 0. - -eg {{modBool 15 3}} -> true - -## Strings - -### urlize -Takes a string and sanitizes it for usage in urls, converts spaces to "-". - -eg. <a href="/tags/{{ . | urlize }}">{{ . }}</a> - -### safeHtml -Declares the provided string as "safe" so go templates will not filter it. - -eg. {{ .Params.CopyrightHTML | safeHtml }} - -### lower -Convert all characters in string to lowercase. - -eg {{lower "BatMan"}} -> "batman" - -### upper -Convert all characters in string to uppercase. - -eg {{upper "BatMan"}} -> "BATMAN" - -### title -Convert all characters in string to titlecase. - -eg {{title "BatMan"}} -> "Batman" - -### 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/highlight). diff --git a/docs/content/layout/go-templates.md b/docs/content/layout/go-templates.md deleted file mode 100644 index b00e6851..00000000 --- a/docs/content/layout/go-templates.md +++ /dev/null @@ -1,335 +0,0 @@ ---- -title: "Using Go Templates" -date: "2013-07-01" -weight: 15 -menu: - main: - parent: 'layout' ---- - -Hugo uses the excellent [go][] [html/template][gohtmltemplate] library for -its template engine. It is an extremely lightweight engine that provides a very -small amount of logic. In our experience that it is just the right amount of -logic to be able to create a good static website. If you have used other -template systems from different languages or frameworks you will find a lot of -similarities in go templates. - -This document is a brief primer on using go templates. The [go docs][gohtmltemplate] -provide more details. - -## Introduction to Go Templates - -Go templates provide an extremely simple template language. It adheres to the -belief that only the most basic of logic belongs in the template or view layer. -One consequence of this simplicity is that go templates parse very quickly. - -A unique characteristic of go templates is they are content aware. Variables and -content will be sanitized depending on the context of where they are used. More -details can be found in the [go docs][gohtmltemplate]. - -## Basic Syntax - -Go lang templates are html files with the addition of variables and -functions. - -**Go variables and functions are accessible within {{ }}** - -Accessing a predefined variable "foo": - - {{ foo }} - -**Parameters are separated using spaces** - -Calling the add function with input of 1, 2: - - {{ add 1 2 }} - -**Methods and fields are accessed via dot notation** - -Accessing the Page Parameter "bar" - - {{ .Params.bar }} - -**Parentheses can be used to group items together** - - {{ if or (isset .Params "alt") (isset .Params "caption") }} Caption {{ end }} - - -## Variables - -Each go template has a struct (object) made available to it. In hugo each -template is passed either a page or a node struct depending on which type of -page you are rendering. More details are available on the -[variables](/layout/variables) page. - -A variable is accessed by referencing the variable name. - - {{ .Title }} - -Variables can also be defined and referenced. - - {{ $address := "123 Main St."}} - {{ $address }} - - -## Functions - -Go template ship with a few functions which provide basic functionality. The go -template system also provides a mechanism for applications to extend the -available functions with their own. [Hugo template -functions](/layout/functions) provide some additional functionality we believe -are useful for building websites. Functions are called by using their name -followed by the required parameters separated by spaces. Template -functions cannot be added without recompiling hugo. - -**Example:** - - {{ add 1 2 }} - -## Includes - -When including another template you will pass to it the data it will be -able to access. To pass along the current context please remember to -include a trailing dot. The templates location will always be starting at -the /layout/ directory within Hugo. - -**Example:** - - {{ template "chrome/header.html" . }} - - -## Logic - -Go templates provide the most basic iteration and conditional logic. - -### Iteration - -Just like in go, the go templates make heavy use of range to iterate over -a map, array or slice. The following are different examples of how to use -range. - -**Example 1: Using Context** - - {{ range array }} - {{ . }} - {{ end }} - -**Example 2: Declaring value variable name** - - {{range $element := array}} - {{ $element }} - {{ end }} - -**Example 2: Declaring key and value variable name** - - {{range $index, $element := array}} - {{ $index }} - {{ $element }} - {{ end }} - -### Conditionals - -If, else, with, or, & and provide the framework for handling conditional -logic in Go Templates. Like range, each statement is closed with `end`. - - -Go Templates treat the following values as false: - -* false -* 0 -* any array, slice, map, or string of length zero - -**Example 1: If** - - {{ if isset .Params "title" }}

    {{ index .Params "title" }}

    {{ end }} - -**Example 2: If -> Else** - - {{ if isset .Params "alt" }} - {{ index .Params "alt" }} - {{else}} - {{ index .Params "caption" }} - {{ end }} - -**Example 3: And & Or** - - {{ if and (or (isset .Params "title") (isset .Params "caption")) (isset .Params "attr")}} - -**Example 4: With** - -An alternative way of writing "if" and then referencing the same value -is to use "with" instead. With rebinds the context `.` within its scope, -and skips the block if the variable is absent. - -The first example above could be simplified as: - - {{ with .Params.title }}

    {{ . }}

    {{ end }} - -**Example 5: If -> Else If** - - {{ if isset .Params "alt" }} - {{ index .Params "alt" }} - {{ else if isset .Params "caption" }} - {{ index .Params "caption" }} - {{ end }} - -## Pipes - -One of the most powerful components of go templates is the ability to -stack actions one after another. This is done by using pipes. Borrowed -from unix pipes, the concept is simple, each pipeline's output becomes the -input of the following pipe. - -Because of the very simple syntax of go templates, the pipe is essential -to being able to chain together function calls. One limitation of the -pipes is that they only can work with a single value and that value -becomes the last parameter of the next pipeline. - -A few simple examples should help convey how to use the pipe. - -**Example 1 :** - - {{ if eq 1 1 }} Same {{ end }} - -is the same as - - {{ eq 1 1 | if }} Same {{ end }} - -It does look odd to place the if at the end, but it does provide a good -illustration of how to use the pipes. - -**Example 2 :** - - {{ index .Params "disqus_url" | html }} - -Access the page parameter called "disqus_url" and escape the HTML. - -**Example 3 :** - - {{ if or (or (isset .Params "title") (isset .Params "caption")) (isset .Params "attr")}} - Stuff Here - {{ end }} - -Could be rewritten as - - {{ isset .Params "caption" | or isset .Params "title" | or isset .Params "attr" | if }} - Stuff Here - {{ end }} - - -## Context (aka. the dot) - -The most easily overlooked concept to understand about go templates is that {{ . }} -always refers to the current context. In the top level of your template this -will be the data set made available to it. Inside of a iteration it will have -the value of the current item. When inside of a loop the context has changed. . -will no longer refer to the data available to the entire page. If you need to -access this from within the loop you will likely want to set it to a variable -instead of depending on the context. - -**Example:** - - {{ $title := .Site.Title }} - {{ range .Params.tags }} -
  • {{ . }} - {{ $title }}
  • - {{ end }} - -Notice how once we have entered the loop the value of {{ . }} has changed. We -have defined a variable outside of the loop so we have access to it from within -the loop. - -# Hugo Parameters - -Hugo provides the option of passing values to the template language -through the site configuration (for sitewide values), or through the meta -data of each specific piece of content. You can define any values of any -type (supported by your front matter/config format) and use them however -you want to inside of your templates. - - -## Using Content (page) Parameters - -In each piece of content you can provide variables to be used by the -templates. This happens in the [front matter](/content/front-matter). - -An example of this is used in this documentation site. Most of the pages -benefit from having the table of contents provided. Sometimes the TOC just -doesn't make a lot of sense. We've defined a variable in our front matter -of some pages to turn off the TOC from being displayed. - -Here is the example front matter: - -``` ---- -title: "Permalinks" -date: "2013-11-18" -aliases: - - "/doc/permalinks/" -groups: ["extras"] -groups_weight: 30 -notoc: true ---- -``` - -Here is the corresponding code inside of the template: - - {{ if not .Params.notoc }} -
    - {{ .TableOfContents }} -
    - {{ end }} - - - -## Using Site (config) Parameters -In your top-level configuration file (eg, `config.yaml`) you can define site -parameters, which are values which will be available to you in chrome. - -For instance, you might declare: - -```yaml -params: - CopyrightHTML: "Copyright © 2013 John Doe. All Rights Reserved." - TwitterUser: "spf13" - SidebarRecentLimit: 5 -``` - -Within a footer layout, you might then declare a `