Compare commits

..

44 Commits

Author SHA1 Message Date
Bjørn Erik Pedersen 12b844daf0 releaser: Update /docs to 0.23 [ci skip] 2017-06-16 09:47:25 +02:00
Bjørn Erik Pedersen b502b9d8cc releaser: Bump versions for release of 0.23
[ci skip]
2017-06-16 09:41:39 +02:00
Bjørn Erik Pedersen 781a1539cc releaser: Update /docs [ci skip] 2017-06-16 09:41:39 +02:00
Bjørn Erik Pedersen af85eb62b4 releaser: Adjust 2017-06-16 09:40:47 +02:00
Bjørn Erik Pedersen 882b2b61fc releaser: Add release notes draft for 0.23
[ci skip]
2017-06-16 09:08:13 +02:00
Bjørn Erik Pedersen 00e2fe077a releaser: Adapt release logic to docs submodule 2017-06-16 08:51:43 +02:00
Bjørn Erik Pedersen ccb8300d38 Update logo link in README 2017-06-14 11:24:09 +02:00
Bjørn Erik Pedersen 214dbdfb6f Remove docs building from CI builds
We could probably get it working, but we have plenty of site tests now.
2017-06-14 11:16:06 +02:00
Bjørn Erik Pedersen 729be8074b commands: Adjust docs path 2017-06-14 10:37:58 +02:00
Bjørn Erik Pedersen 6cee0dfe53 Add docs as submodule 2017-06-14 10:35:24 +02:00
Bjørn Erik Pedersen 8be3934b59 docs: Remove
Docs site is moved to https://github.com/gohugoio/hugoDocs

Will be re-added here as a Git submodule.
2017-06-14 10:32:16 +02:00
Bjørn Erik Pedersen fbb25014e1 Update Gitter link in README
That is still running under spf13.
2017-06-13 23:39:55 +02:00
Bjørn Erik Pedersen bf5e59958d vendor: Update to new org name 2017-06-13 22:11:05 +02:00
Bjørn Erik Pedersen 86543d6a50 Change Windows build badge link, take #3 2017-06-13 22:05:39 +02:00
Bjørn Erik Pedersen 3b47805fdd Change Windows build badge link, take #2 2017-06-13 22:04:36 +02:00
Bjørn Erik Pedersen e6ae32a0ba Update Windows build link 2017-06-13 22:03:05 +02:00
Bjørn Erik Pedersen 5103935ae8 hugolib: Disable shaky leaktest on CI 2017-06-13 21:22:47 +02:00
digitalcraftsman 95386544e8 Update links in CONTRIBUTING.md due to the org transition 2017-06-13 19:37:30 +02:00
digitalcraftsman 7b99fb9f1c Update source path in Dockerfile due to the org transition 2017-06-13 19:34:20 +02:00
digitalcraftsman d531d17b3b Update clone folder in appveyor.yml due to the org transition 2017-06-13 19:32:14 +02:00
digitalcraftsman 9266bf9d4c Update import path in snapcraft.yaml due to the org transition 2017-06-13 19:28:34 +02:00
Bjørn Erik Pedersen 873a6f1885 Run gofmt to get imports in line vs gohugoio/hugo 2017-06-13 19:12:10 +02:00
Bjørn Erik Pedersen f503d76a3b Update Makefile vs gohugoio/hugo 2017-06-13 19:06:34 +02:00
Bjørn Erik Pedersen 93643860c9 Update README to point to gohugoio/hugo 2017-06-13 19:00:10 +02:00
Bjørn Erik Pedersen db46bcf82d examples: Update examples to point to gohugoio/hugo 2017-06-13 18:59:38 +02:00
Bjørn Erik Pedersen 66d4850b89 docs: Update layout references to gohugoio/hugo 2017-06-13 18:56:22 +02:00
Bjørn Erik Pedersen 715ff1f874 docs: Update content references to gohugoio/hugo 2017-06-13 18:54:42 +02:00
Bjørn Erik Pedersen c17ad675e8 all: Update textual references in Go source to point to gohugoio/hugo 2017-06-13 18:47:17 +02:00
Bjørn Erik Pedersen d8717cd4c7 all: Update import paths to gohugoio/hugo 2017-06-13 18:42:45 +02:00
Bjørn Erik Pedersen 2d08a296a2 vendor: Improve GitInfo
Closes #3533
Closes #3552
2017-06-13 17:47:54 +02:00
Bjørn Erik Pedersen a9e551a100 Fix handling of duplicate footnotes
Closes #1912
2017-06-13 15:03:08 +02:00
Bjørn Erik Pedersen 2aafb24766 Revert "releaser: Bump versions for release of 0.22.1"
This reverts commit dce70fb7c5.
2017-06-13 14:26:56 +02:00
Bjørn Erik Pedersen 4bd5ce7ef3 releaser: Prepare repository for 0.23-DEV 2017-06-13 14:25:19 +02:00
Bjørn Erik Pedersen 0f78dd06a4 releaser: Prepare repository for 0.22.1-DEV
[ci skip]
2017-06-13 14:22:14 +02:00
Bjørn Erik Pedersen 714594a8b7 releaser: Add relase notes to /docs for release of 0.22.1
[ci skip]
2017-06-13 14:17:45 +02:00
Bjørn Erik Pedersen dce70fb7c5 releaser: Bump versions for release of 0.22.1
[ci skip]
2017-06-13 14:17:15 +02:00
Bjørn Erik Pedersen c84079baa9 releaser: Add release notes draft for 0.22.1
[ci skip]
2017-06-13 14:16:56 +02:00
Bjørn Erik Pedersen a30023f5cb hugolib: Fix section logic for root folders with subfolders
This commit fixes an issue introduced in the recently released Hugo 0.22.

This logic did not handle the case with root sections with non-section subfolders very well.

Fixes #3586
2017-06-13 12:41:50 +02:00
Bjørn Erik Pedersen 1f26420d39 hugolib: Support sub-sections in permalink settings
This enables both the variants below:

Current (first level only):

```
"blog": ":section/:title",
```

Nested (all levels):

```
"blog": ":sections/:title",
```

Should ideally been part of Hugo 0.22, but better late than never ...

Fixes #3580
2017-06-13 11:42:32 +02:00
Bjørn Erik Pedersen ff54b6bddc commands: Adjust rlimit to 64000
See #3582
2017-06-12 20:43:19 +02:00
Bjørn Erik Pedersen 629e1439e8 commands: Make error on setting rlimit a warning only
And reduce it to 10000.

Closes #3582
2017-06-12 20:35:19 +02:00
Bjørn Erik Pedersen 26aa06a3db Revert "commands: Remove the rlimit tweaking on macOS"
This reverts commit bcd32f1086.

See #3582
2017-06-12 20:35:19 +02:00
daftaupe 52a0cea65d docs: Add note on updates for rpm-based distros 2017-06-12 19:44:16 +02:00
Bjørn Erik Pedersen 8ca586a6e5 releaser: Prepare repository for 0.23-DEV
[ci skip]
2017-06-12 09:07:46 +02:00
674 changed files with 725 additions and 27473 deletions
+4
View File
@@ -0,0 +1,4 @@
[submodule "docs"]
path = docs
url = https://github.com/gohugoio/hugoDocs.git
ignore = dirty
-2
View File
@@ -15,8 +15,6 @@ install:
- make vendor
script:
- make hugo-race check
- ./hugo -s docs/
- ./hugo --renderToMemory -s docs/
before_install:
# gem install must be run with sudo on OSX
- sudo gem install asciidoctor | gem install asciidoctor
+9 -9
View File
@@ -5,7 +5,7 @@ organization, tutorials, blog posts, bug reports, issues, feature requests,
feature implementations, pull requests, answering questions on the forum,
helping to manage issues, etc.
The Hugo community and maintainers are [very active](https://github.com/spf13/hugo/pulse/monthly) and helpful, and the project benefits greatly from this activity. We created a [step by step guide](https://gohugo.io/tutorials/how-to-contribute-to-hugo/) if you're unfamiliar with GitHub or contributing to open source projects in general.
The Hugo community and maintainers are [very active](https://github.com/gohugoio/hugo/pulse/monthly) and helpful, and the project benefits greatly from this activity. We created a [step by step guide](https://gohugo.io/tutorials/how-to-contribute-to-hugo/) if you're unfamiliar with GitHub or contributing to open source projects in general.
## Table of Contents
@@ -22,14 +22,14 @@ The Hugo community and maintainers are [very active](https://github.com/spf13/hu
## Asking Support Questions
We have an active [discussion forum](http://discuss.gohugo.io) where users and developers can ask questions.
We have an active [discussion forum](https://discuss.gohugo.io) where users and developers can ask questions.
Please don't use the GitHub issue tracker to ask questions.
## Reporting Issues
If you believe you have found a defect in Hugo or its documentation, use
the GitHub [issue tracker](https://github.com/spf13/hugo/issues) to report the problem to the Hugo maintainers.
If you're not sure if it's a bug or not, start by asking in the [discussion forum](http://discuss.gohugo.io).
the GitHub [issue tracker](https://github.com/gohugoio/hugo/issues) to report the problem to the Hugo maintainers.
If you're not sure if it's a bug or not, start by asking in the [discussion forum](https://discuss.gohugo.io).
When reporting the issue, please provide the version of Hugo in use (`hugo version`) and your operating system.
## Submitting Patches
@@ -48,12 +48,12 @@ To make the contribution process as seamless as possible, we ask for the followi
* Go ahead and fork the project and make your changes. We encourage pull requests to allow for review and discussion of code changes.
* When youre ready to create a pull request, be sure to:
* Sign the [CLA](https://cla-assistant.io/spf13/hugo).
* Sign the [CLA](https://cla-assistant.io/gohugoio/hugo).
* Have test cases for the new code. If you have questions about how to do this, please ask in your pull request.
* Run `go fmt`.
* Add documentation if you are adding new features or changing functionality. The docs site lives in `/docs`.
* Squash your commits into a single commit. `git rebase -i`. Its okay to force update your pull request with `git push -f`.
* Ensure that `make check` succeeds. [Travis CI](https://travis-ci.org/spf13/hugo) (Linux and macOS) and [AppVeyor](https://ci.appveyor.com/project/spf13/hugo/branch/master) (Windows) will fail the build if `make check` fails.
* Ensure that `make check` succeeds. [Travis CI](https://travis-ci.org/gohugoio/hugo) (Linux and macOS) and [AppVeyor](https://ci.appveyor.com/project/gohugoio/hugo/branch/master) (Windows) will fail the build if `make check` fails.
* Follow the **Git Commit Message Guidelines** below.
### Git Commit Message Guidelines
@@ -94,7 +94,7 @@ You **must use govendor** to fetch and manage Hugo's dependencies.
```
go get github.com/kardianos/govendor
govendor get github.com/spf13/hugo
govendor get github.com/gohugoio/hugo
```
### Using Git Remotes
@@ -108,7 +108,7 @@ started:
1. Change to the Hugo source directory:
```
cd $HOME/go/src/github.com/spf13/hugo
cd $HOME/go/src/github.com/gohugoio/hugo
```
1. Create a new branch for your changes (the branch name is arbitrary):
@@ -142,7 +142,7 @@ started:
### Build Hugo with Your Changes
```bash
cd $HOME/go/src/github.com/spf13/hugo
cd $HOME/go/src/github.com/gohugoio/hugo
make hugo
# or to install in $HOME/go/bin:
make install
+3 -3
View File
@@ -7,9 +7,9 @@ RUN apk update && apk add git make
# pre-install known dependencies before the source, so we don't redownload them whenever the source changes
RUN go get github.com/kardianos/govendor \
&& govendor get github.com/spf13/hugo
&& govendor get github.com/gohugoio/hugo
COPY . $GOPATH/src/github.com/spf13/hugo
COPY . $GOPATH/src/github.com/gohugoio/hugo
RUN cd $GOPATH/src/github.com/spf13/hugo \
RUN cd $GOPATH/src/github.com/gohugoio/hugo \
&& make install test
+4 -4
View File
@@ -1,6 +1,6 @@
# A Self-Documenting Makefile: http://marmelab.com/blog/2016/02/29/auto-documented-makefile.html
PACKAGE = github.com/spf13/hugo
PACKAGE = github.com/gohugoio/hugo
COMMIT_HASH = `git rev-parse --short HEAD 2>/dev/null`
BUILD_DATE = `date +%FT%T%z`
LDFLAGS = -ldflags "-X ${PACKAGE}/hugolib.CommitHash=${COMMIT_HASH} -X ${PACKAGE}/hugolib.BuildDate=${BUILD_DATE}"
@@ -50,14 +50,14 @@ test-race: ## Run tests with race detector
govendor test -race +local
fmt: ## Run gofmt linter
@for d in `govendor list -no-status +local | sed 's/github.com.spf13.hugo/./'` ; do \
@for d in `govendor list -no-status +local | sed 's/github.com.gohugoio.hugo/./'` ; do \
if [ "`gofmt -l $$d/*.go | tee /dev/stderr`" ]; then \
echo "^ improperly formatted go files" && echo && exit 1; \
fi \
done
lint: ## Run golint linter
@for d in `govendor list -no-status +local | sed 's/github.com.spf13.hugo/./'` ; do \
@for d in `govendor list -no-status +local | sed 's/github.com.gohugoio.hugo/./'` ; do \
if [ "`golint $$d | tee /dev/stderr`" ]; then \
echo "^ golint errors!" && echo && exit 1; \
fi \
@@ -68,7 +68,7 @@ vet: ## Run go vet linter
echo "^ go vet errors!" && echo && exit 1; \
fi
test-cover-html: PACKAGES = $(shell govendor list -no-status +local | sed 's/github.com.spf13.hugo/./')
test-cover-html: PACKAGES = $(shell govendor list -no-status +local | sed 's/github.com.gohugoio.hugo/./')
test-cover-html: ## Generate test coverage report
echo "mode: count" > coverage-all.out
$(foreach pkg,$(PACKAGES),\
+12 -12
View File
@@ -1,20 +1,20 @@
![Hugo](https://raw.githubusercontent.com/spf13/hugo/master/docs/static/img/hugo-logo.png)
![Hugo](https://raw.githubusercontent.com/gohugoio/hugoDocs/master/static/img/hugo-logo.png)
A Fast and Flexible Static Site Generator built with love by [spf13](http://spf13.com/) and [friends](https://github.com/spf13/hugo/graphs/contributors) in [Go][].
A Fast and Flexible Static Site Generator built with love by [spf13](http://spf13.com/) and [friends](https://github.com/gohugoio/hugo/graphs/contributors) in [Go][].
[Website](https://gohugo.io) |
[Forum](https://discuss.gohugo.io) |
[Developer Chat (no support)](https://gitter.im/spf13/hugo) |
[Developer Chat (no support)](https://gitter.im/gohugoio/hugo) |
[Documentation](https://gohugo.io/overview/introduction/) |
[Installation Guide](https://gohugo.io/overview/installing/) |
[Contribution Guide](CONTRIBUTING.md) |
[Twitter](http://twitter.com/gohugoio)
[![GoDoc](https://godoc.org/github.com/spf13/hugo?status.svg)](https://godoc.org/github.com/spf13/hugo)
[![Linux and macOS Build Status](https://api.travis-ci.org/spf13/hugo.svg?branch=master&label=Linux+and+macOS+build "Linux and macOS Build Status")](https://travis-ci.org/spf13/hugo)
[![Windows Build Status](https://ci.appveyor.com/api/projects/status/n2mo912b8s2505e8/branch/master?svg=true&label=Windows+build "Windows Build Status")](https://ci.appveyor.com/project/spf13/hugo/branch/master)
[![Dev chat at https://gitter.im/spf13/hugo](https://img.shields.io/badge/gitter-developer_chat-46bc99.svg)](https://gitter.im/spf13/hugo?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![Go Report Card](https://goreportcard.com/badge/github.com/spf13/hugo)](https://goreportcard.com/report/github.com/spf13/hugo)
[![GoDoc](https://godoc.org/github.com/gohugoio/hugo?status.svg)](https://godoc.org/github.com/gohugoio/hugo)
[![Linux and macOS Build Status](https://api.travis-ci.org/gohugoio/hugo.svg?branch=master&label=Linux+and+macOS+build "Linux and macOS Build Status")](https://travis-ci.org/gohugoio/hugo)
[![Windows Build Status](https://ci.appveyor.com/api/projects/status/a5mr220vsd091kua?svg=true&label=Windows+build "Windows Build Status")](https://ci.appveyor.com/project/bep/hugo/branch/master)
[![Dev chat at https://gitter.im/gohugoio/hugo](https://img.shields.io/badge/gitter-developer_chat-46bc99.svg)](https://gitter.im/spf13/hugo?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![Go Report Card](https://goreportcard.com/badge/github.com/gohugoio/hugo)](https://goreportcard.com/report/github.com/gohugoio/hugo)
## Overview
@@ -44,7 +44,7 @@ Hugo may also be compiled from source wherever the Go compiler tool chain can ru
If you want to use Hugo as your site generator, simply install the Hugo binaries.
The Hugo binaries have no external dependencies.
To contribute to the Hugo source code or documentation, you should [fork the Hugo GitHub project](https://github.com/spf13/hugo#fork-destination-box) and clone it to your local machine.
To contribute to the Hugo source code or documentation, you should [fork the Hugo GitHub project](https://github.com/gohugoio/hugo#fork-destination-box) and clone it to your local machine.
Finally, you can install the Hugo source code with `go`, build the binaries yourself, and run Hugo that way.
Building the binaries is an easy task for an experienced `go` getter.
@@ -57,13 +57,13 @@ Use the [installation instructions in the Hugo documentation](https://gohugo.io/
Add Hugo and its package dependencies to your go `src` directory.
go get -v github.com/spf13/hugo
go get -v github.com/gohugoio/hugo
Once the `get` completes, you should find your new `hugo` (or `hugo.exe`) executable sitting inside `$GOPATH/bin/`.
To update Hugos dependencies, use `go get` with the `-u` option.
go get -u -v github.com/spf13/hugo
go get -u -v github.com/gohugoio/hugo
## Contributing to Hugo
@@ -74,7 +74,7 @@ organization, tutorials, blog posts, bug reports, issues, feature requests,
feature implementations, pull requests, answering questions on the forum,
helping to manage issues, etc.
The Hugo community and maintainers are [very active](https://github.com/spf13/hugo/pulse/monthly) and helpful, and the project benefits greatly from this activity.
The Hugo community and maintainers are [very active](https://github.com/gohugoio/hugo/pulse/monthly) and helpful, and the project benefits greatly from this activity.
### Asking Support Questions
+1 -3
View File
@@ -5,7 +5,7 @@ init:
- go env
# clones and cd's to path
clone_folder: C:\GOPATH\src\github.com\spf13\hugo
clone_folder: C:\GOPATH\src\github.com\gohugoio\hugo
install:
- gem install asciidoctor
@@ -13,5 +13,3 @@ install:
build_script:
- make hugo-race check
- hugo -s docs/
- hugo --renderToMemory -s docs/
+3 -3
View File
@@ -14,9 +14,9 @@
package commands
import (
"github.com/spf13/hugo/deps"
"github.com/spf13/hugo/helpers"
"github.com/spf13/hugo/hugofs"
"github.com/gohugoio/hugo/deps"
"github.com/gohugoio/hugo/helpers"
"github.com/gohugoio/hugo/hugofs"
)
type commandeer struct {
+3 -3
View File
@@ -19,10 +19,10 @@ import (
"path/filepath"
"time"
"github.com/gohugoio/hugo/hugolib"
"github.com/gohugoio/hugo/parser"
"github.com/spf13/cast"
"github.com/spf13/cobra"
"github.com/spf13/hugo/hugolib"
"github.com/spf13/hugo/parser"
)
var outputDir string
@@ -136,7 +136,7 @@ func convertContents(mark rune) error {
page.SetDir(filepath.Join(contentDir, file.Dir()))
page.SetSourceContent(psr.Content())
if err = page.SetSourceMetaData(metadata, mark); err != nil {
site.Log.ERROR.Printf("Failed to set source metadata for file %q: %s. For more info see For more info see https://github.com/spf13/hugo/issues/2458", page.FullFilePath(), err)
site.Log.ERROR.Printf("Failed to set source metadata for file %q: %s. For more info see For more info see https://github.com/gohugoio/hugo/issues/2458", page.FullFilePath(), err)
continue
}
+2 -2
View File
@@ -20,10 +20,10 @@ import (
"strings"
"time"
"github.com/gohugoio/hugo/helpers"
"github.com/gohugoio/hugo/hugofs"
"github.com/spf13/cobra"
"github.com/spf13/cobra/doc"
"github.com/spf13/hugo/helpers"
"github.com/spf13/hugo/hugofs"
jww "github.com/spf13/jwalterweatherman"
)
+4 -2
View File
@@ -19,8 +19,8 @@ import (
"os"
"path/filepath"
"github.com/gohugoio/hugo/docshelper"
"github.com/spf13/cobra"
"github.com/spf13/hugo/docshelper"
)
type genDocsHelper struct {
@@ -41,7 +41,9 @@ func createGenDocsHelper() *genDocsHelper {
return g.generate()
}
g.cmd.PersistentFlags().StringVarP(&g.target, "dir", "", "docs/data", "data dir")
// Note that ./docs is a submodule, and writing to that would be suboptimal.
// Let us assume that the default is a sibling project.
g.cmd.PersistentFlags().StringVarP(&g.target, "dir", "", "../hugoDocs/data", "data dir")
return g
}
+2 -2
View File
@@ -17,10 +17,10 @@ import (
"fmt"
"strings"
"github.com/gohugoio/hugo/helpers"
"github.com/gohugoio/hugo/hugofs"
"github.com/spf13/cobra"
"github.com/spf13/cobra/doc"
"github.com/spf13/hugo/helpers"
"github.com/spf13/hugo/hugofs"
jww "github.com/spf13/jwalterweatherman"
)
+15 -10
View File
@@ -19,33 +19,34 @@ import (
"fmt"
"io/ioutil"
"github.com/spf13/hugo/hugofs"
"github.com/gohugoio/hugo/hugofs"
"log"
"net/http"
"os"
"path/filepath"
"runtime"
"strings"
"sync"
"time"
"github.com/spf13/hugo/config"
"github.com/gohugoio/hugo/config"
"github.com/spf13/hugo/parser"
"github.com/gohugoio/hugo/parser"
flag "github.com/spf13/pflag"
"regexp"
"github.com/fsnotify/fsnotify"
"github.com/gohugoio/hugo/deps"
"github.com/gohugoio/hugo/helpers"
"github.com/gohugoio/hugo/hugolib"
"github.com/gohugoio/hugo/livereload"
"github.com/gohugoio/hugo/utils"
"github.com/gohugoio/hugo/watcher"
"github.com/spf13/afero"
"github.com/spf13/cobra"
"github.com/spf13/fsync"
"github.com/spf13/hugo/deps"
"github.com/spf13/hugo/helpers"
"github.com/spf13/hugo/hugolib"
"github.com/spf13/hugo/livereload"
"github.com/spf13/hugo/utils"
"github.com/spf13/hugo/watcher"
jww "github.com/spf13/jwalterweatherman"
"github.com/spf13/nitro"
"github.com/spf13/viper"
@@ -655,7 +656,7 @@ func (c *commandeer) getDirList() []string {
}
// Skip .git directories.
// Related to https://github.com/spf13/hugo/issues/3468.
// Related to https://github.com/gohugoio/hugo/issues/3468.
if fi.Name() == ".git" {
return nil
}
@@ -758,6 +759,10 @@ func (c *commandeer) rebuildSites(events []fsnotify.Event) error {
// newWatcher creates a new watcher to watch filesystem events.
func (c *commandeer) newWatcher(port int) error {
if runtime.GOOS == "darwin" {
tweakLimit()
}
watcher, err := watcher.New(1 * time.Second)
var wg sync.WaitGroup
+4 -4
View File
@@ -25,13 +25,13 @@ import (
"strings"
"time"
"github.com/gohugoio/hugo/helpers"
"github.com/gohugoio/hugo/hugofs"
"github.com/gohugoio/hugo/hugolib"
"github.com/gohugoio/hugo/parser"
"github.com/spf13/afero"
"github.com/spf13/cast"
"github.com/spf13/cobra"
"github.com/spf13/hugo/helpers"
"github.com/spf13/hugo/hugofs"
"github.com/spf13/hugo/hugolib"
"github.com/spf13/hugo/parser"
jww "github.com/spf13/jwalterweatherman"
)
+85
View File
@@ -0,0 +1,85 @@
// Copyright 2015 The Hugo Authors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// Copyright 2015 The Hugo Authors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package commands
import (
"syscall"
"github.com/spf13/cobra"
jww "github.com/spf13/jwalterweatherman"
)
func init() {
checkCmd.AddCommand(limit)
}
var limit = &cobra.Command{
Use: "ulimit",
Short: "Check system ulimit settings",
Long: `Hugo will inspect the current ulimit settings on the system.
This is primarily to ensure that Hugo can watch enough files on some OSs`,
RunE: func(cmd *cobra.Command, args []string) error {
var rLimit syscall.Rlimit
err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &rLimit)
if err != nil {
return newSystemError("Error Getting Rlimit ", err)
}
jww.FEEDBACK.Println("Current rLimit:", rLimit)
jww.FEEDBACK.Println("Attempting to increase limit")
rLimit.Max = 999999
rLimit.Cur = 999999
err = syscall.Setrlimit(syscall.RLIMIT_NOFILE, &rLimit)
if err != nil {
return newSystemError("Error Setting rLimit ", err)
}
err = syscall.Getrlimit(syscall.RLIMIT_NOFILE, &rLimit)
if err != nil {
return newSystemError("Error Getting rLimit ", err)
}
jww.FEEDBACK.Println("rLimit after change:", rLimit)
return nil
},
}
func tweakLimit() {
var rLimit syscall.Rlimit
err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &rLimit)
if err != nil {
jww.ERROR.Println("Unable to obtain rLimit", err)
}
if rLimit.Cur < rLimit.Max {
rLimit.Max = 64000
rLimit.Cur = 64000
err = syscall.Setrlimit(syscall.RLIMIT_NOFILE, &rLimit)
if err != nil {
jww.WARN.Println("Unable to increase number of open files limit", err)
}
}
}
+32
View File
@@ -0,0 +1,32 @@
// Copyright 2015 The Hugo Authors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// +build !darwin
// Copyright 2015 The Hugo Authors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package commands
func tweakLimit() {
// nothing to do
}
+1 -1
View File
@@ -16,8 +16,8 @@ package commands
import (
"path/filepath"
"github.com/gohugoio/hugo/hugolib"
"github.com/spf13/cobra"
"github.com/spf13/hugo/hugolib"
jww "github.com/spf13/jwalterweatherman"
)
+7 -7
View File
@@ -22,13 +22,13 @@ import (
"strings"
"time"
"github.com/gohugoio/hugo/create"
"github.com/gohugoio/hugo/helpers"
"github.com/gohugoio/hugo/hugofs"
"github.com/gohugoio/hugo/hugolib"
"github.com/gohugoio/hugo/parser"
"github.com/spf13/afero"
"github.com/spf13/cobra"
"github.com/spf13/hugo/create"
"github.com/spf13/hugo/helpers"
"github.com/spf13/hugo/hugofs"
"github.com/spf13/hugo/hugolib"
"github.com/spf13/hugo/parser"
jww "github.com/spf13/jwalterweatherman"
"github.com/spf13/viper"
)
@@ -311,7 +311,7 @@ func touchFile(fs afero.Fs, x ...string) {
func createThemeMD(fs *hugofs.Fs, inpath string) (err error) {
by := []byte(`# theme.toml template for a Hugo theme
# See https://github.com/spf13/hugoThemes#themetoml for an example
# See https://github.com/gohugoio/hugoThemes#themetoml for an example
name = "` + strings.Title(helpers.MakeTitle(filepath.Base(inpath))) + `"
license = "MIT"
@@ -320,7 +320,7 @@ description = ""
homepage = "http://siteforthistheme.com/"
tags = []
features = []
min_version = "0.22"
min_version = "0.23"
[author]
name = ""
+1 -1
View File
@@ -17,7 +17,7 @@ import (
"path/filepath"
"testing"
"github.com/spf13/hugo/hugofs"
"github.com/gohugoio/hugo/hugofs"
"github.com/spf13/viper"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
+1 -1
View File
@@ -16,8 +16,8 @@
package commands
import (
"github.com/gohugoio/hugo/releaser"
"github.com/spf13/cobra"
"github.com/spf13/hugo/releaser"
)
func init() {
+2 -2
View File
@@ -24,10 +24,10 @@ import (
"strings"
"time"
"github.com/gohugoio/hugo/config"
"github.com/gohugoio/hugo/helpers"
"github.com/spf13/afero"
"github.com/spf13/cobra"
"github.com/spf13/hugo/config"
"github.com/spf13/hugo/helpers"
jww "github.com/spf13/jwalterweatherman"
)
+1 -1
View File
@@ -19,8 +19,8 @@ import (
"os"
"time"
"github.com/gohugoio/hugo/parser"
"github.com/spf13/cobra"
"github.com/spf13/hugo/parser"
)
var undraftCmd = &cobra.Command{
+1 -1
View File
@@ -21,7 +21,7 @@ import (
"testing"
"time"
"github.com/spf13/hugo/parser"
"github.com/gohugoio/hugo/parser"
)
var (
+2 -2
View File
@@ -20,10 +20,10 @@ import (
"strings"
"time"
"github.com/gohugoio/hugo/helpers"
"github.com/gohugoio/hugo/hugolib"
"github.com/kardianos/osext"
"github.com/spf13/cobra"
"github.com/spf13/hugo/helpers"
"github.com/spf13/hugo/hugolib"
jww "github.com/spf13/jwalterweatherman"
)
+4 -4
View File
@@ -22,11 +22,11 @@ import (
"strings"
"time"
"github.com/gohugoio/hugo/helpers"
"github.com/gohugoio/hugo/hugolib"
"github.com/gohugoio/hugo/parser"
"github.com/spf13/afero"
"github.com/spf13/cast"
"github.com/spf13/hugo/helpers"
"github.com/spf13/hugo/hugolib"
"github.com/spf13/hugo/parser"
jww "github.com/spf13/jwalterweatherman"
)
@@ -160,7 +160,7 @@ func FindArchetype(s *hugolib.Site, kind string) (outpath string) {
for _, x := range search {
// If the new content isn't in a subdirectory, kind == "".
// Therefore it should be excluded otherwise `is a directory`
// error will occur. github.com/spf13/hugo/issues/411
// error will occur. github.com/gohugoio/hugo/issues/411
var pathsToCheck []string
if kind == "" {
+5 -5
View File
@@ -19,17 +19,17 @@ import (
"strings"
"testing"
"github.com/spf13/hugo/deps"
"github.com/gohugoio/hugo/deps"
"github.com/spf13/hugo/hugolib"
"github.com/gohugoio/hugo/hugolib"
"fmt"
"github.com/spf13/hugo/hugofs"
"github.com/gohugoio/hugo/hugofs"
"github.com/gohugoio/hugo/create"
"github.com/gohugoio/hugo/helpers"
"github.com/spf13/afero"
"github.com/spf13/hugo/create"
"github.com/spf13/hugo/helpers"
"github.com/spf13/viper"
"github.com/stretchr/testify/require"
)
+5 -5
View File
@@ -5,11 +5,11 @@ import (
"log"
"os"
"github.com/spf13/hugo/config"
"github.com/spf13/hugo/helpers"
"github.com/spf13/hugo/hugofs"
"github.com/spf13/hugo/output"
"github.com/spf13/hugo/tpl"
"github.com/gohugoio/hugo/config"
"github.com/gohugoio/hugo/helpers"
"github.com/gohugoio/hugo/hugofs"
"github.com/gohugoio/hugo/output"
"github.com/gohugoio/hugo/tpl"
jww "github.com/spf13/jwalterweatherman"
)
Submodule
+1
Submodule docs added at d9fb81b49d
-1
View File
@@ -1 +0,0 @@
/.idea
-6
View File
@@ -1,6 +0,0 @@
+++
weight = 5
[menu]
[menu.main]
parent = "x"
+++
-14
View File
@@ -1,14 +0,0 @@
---
date: 2013-07-01T07:32:00Z
description: ""
license: ""
licenseLink: ""
sitelink: http://spf13.com/
sourceLink: https://github.com/spf13/spf13.com
tags:
- personal
- blog
thumbnail: /img/spf13-tn.jpg
title: spf13.com
---
-118
View File
@@ -1,118 +0,0 @@
title = "Hugo: A Fast and Flexible Website Generator"
baseurl = "http://gohugo.io/"
MetaDataFormat = "yaml"
pluralizeListTitles = false
[blackfriday]
plainIDAnchors = true
[params]
description = "Documentation of Hugo, a fast and flexible static site generator built with love by spf13, bep and friends in Go"
author = "Steve Francia (spf13) and friends"
release = "0.22"
[taxonomies]
tag = "tags"
group = "groups"
[[menu.main]]
name = "Download Hugo"
pre = "<i class='fa fa-download'></i>"
url = "https://github.com/spf13/hugo/releases"
weight = -200
[[menu.main]]
name = "Site Showcase"
pre = "<i class='fa fa-cubes'></i>"
url = "/showcase/"
weight = -180
[[menu.main]]
name = "Theme Showcase"
pre = "<i class='fa fa-puzzle-piece'></i>"
url = "http://themes.gohugo.io"
weight = -170
[[menu.main]]
name = "Press & Articles"
pre = "<i class='fa fa-bullhorn'></i>"
url = "/community/press/"
weight = -160
[[menu.main]]
name = "Discuss Hugo"
pre = "<i class='fa fa-comments'></i>"
url = "http://discuss.gohugo.io/"
weight = -150
[[menu.main]]
name = "About Hugo"
identifier = "about"
pre = "<i class='fa fa-heart'></i>"
weight = -110
[[menu.main]]
name = "Release Notes"
url = "/release-notes/"
pre = "<i class='fa fa-newspaper-o'></i>"
weight = -111
[[menu.main]]
name = "Getting Started"
identifier = "getting started"
pre = "<i class='fa fa-road'></i>"
weight = -100
[[menu.main]]
name = "Content"
identifier = "content"
pre = "<i class='fa fa-file-text'></i>"
weight = -90
[[menu.main]]
name = "Themes"
identifier = "themes"
pre = "<i class='fa fa-desktop'></i>"
weight = -85
[[menu.main]]
parent = "themes"
name = "Theme Showcase"
url = "http://themes.gohugo.io"
weight = -170
[[menu.main]]
name = "Templates"
identifier = "layout"
pre = "<i class='fa fa-columns'></i>"
weight = -80
[[menu.main]]
name = "Taxonomies"
identifier = "taxonomy"
pre = "<i class='fa fa-tags'></i>"
weight = -70
[[menu.main]]
name = "Extras"
identifier = "extras"
pre = "<i class='fa fa-gift'></i>"
weight = -60
[[menu.main]]
name = "Community"
identifier = "community"
pre = "<i class='fa fa-group'></i>"
weight = -50
[[menu.main]]
parent = "community"
name = "Discussion Forum"
url = "http://discuss.gohugo.io"
weight = 150
[[menu.main]]
name = "Tutorials"
identifier = "tutorials"
pre = "<i class='fa fa-book'></i>"
weight = -40
[[menu.main]]
name = "Troubleshooting"
identifier = "troubleshooting"
pre = "<i class='fa fa-wrench'></i>"
weight = -30
[[menu.main]]
name = "Tools"
url = "/tools/"
pre = "<i class='fa fa-cogs'></i>"
weight = -25
[[menu.main]]
name = "Hugo Cmd Reference"
identifier = "commands"
pre = "<i class='fa fa-space-shuttle'></i>"
weight = -20
url = "/commands/"
-79
View File
@@ -1,79 +0,0 @@
---
date: 2017-05-23T20:59:46+03:00
title: "hugo"
slug: hugo
url: /commands/hugo/
---
## hugo
hugo builds your site
### Synopsis
hugo is the main command, used to build your Hugo site.
Hugo is a Fast and Flexible Static Site Generator
built with love by spf13 and friends in Go.
Complete documentation is available at http://gohugo.io/.
```
hugo [flags]
```
### Options
```
-b, --baseURL string hostname (and path) to the root, e.g. http://spf13.com/
-D, --buildDrafts include content marked as draft
-E, --buildExpired include expired content
-F, --buildFuture include content with publishdate in the future
--cacheDir string filesystem path to cache directory. Defaults: $TMPDIR/hugo_cache/
--canonifyURLs if true, all relative URLs will be canonicalized using baseURL
--cleanDestinationDir remove files from destination not found in static directories
--config string config file (default is path/config.yaml|json|toml)
-c, --contentDir string filesystem path to content directory
-d, --destination string filesystem path to write files to
--disable404 do not render 404 page
--disableKinds stringSlice disable different kind of pages (home, RSS etc.)
--disableRSS do not build RSS files
--disableSitemap do not build Sitemap file
--enableGitInfo add Git revision, date and author info to the pages
--forceSyncStatic copy all files when static is changed.
-h, --help help for hugo
--i18n-warnings print missing translations
--ignoreCache ignores the cache directory
-l, --layoutDir string filesystem path to layout directory
--log enable Logging
--logFile string log File path (if set, logging enabled automatically)
--noChmod don't sync permission mode of files
--noTimes don't sync modification time of files
--pluralizeListTitles pluralize titles in lists using inflect (default true)
--preserveTaxonomyNames preserve taxonomy names as written ("Gérard Depardieu" vs "gerard-depardieu")
--quiet build in quiet mode
--renderToMemory render to memory (only useful for benchmark testing)
-s, --source string filesystem path to read files relative from
--stepAnalysis display memory and timing of different steps of the program
-t, --theme string theme to use (located in /themes/THEMENAME/)
--themesDir string filesystem path to themes directory
--uglyURLs if true, use /filename.html instead of /filename/
-v, --verbose verbose output
--verboseLog verbose logging
-w, --watch watch filesystem for changes and recreate as needed
```
### SEE ALSO
* [hugo benchmark](/commands/hugo_benchmark/) - Benchmark Hugo by building a site a number of times.
* [hugo config](/commands/hugo_config/) - Print the site configuration
* [hugo convert](/commands/hugo_convert/) - Convert your content to different formats
* [hugo env](/commands/hugo_env/) - Print Hugo version and environment info
* [hugo gen](/commands/hugo_gen/) - A collection of several useful generators.
* [hugo import](/commands/hugo_import/) - Import your site from others.
* [hugo list](/commands/hugo_list/) - Listing out various types of content
* [hugo new](/commands/hugo_new/) - Create new content for your site
* [hugo server](/commands/hugo_server/) - A high performance webserver
* [hugo undraft](/commands/hugo_undraft/) - Undraft changes the content's draft status from 'True' to 'False'
* [hugo version](/commands/hugo_version/) - Print the version number of Hugo
###### Auto generated by spf13/cobra on 23-May-2017
-72
View File
@@ -1,72 +0,0 @@
---
date: 2017-05-23T20:59:46+03:00
title: "hugo benchmark"
slug: hugo_benchmark
url: /commands/hugo_benchmark/
---
## hugo benchmark
Benchmark Hugo by building a site a number of times.
### Synopsis
Hugo can build a site many times over and analyze the running process
creating a benchmark.
```
hugo benchmark [flags]
```
### Options
```
-b, --baseURL string hostname (and path) to the root, e.g. http://spf13.com/
-D, --buildDrafts include content marked as draft
-E, --buildExpired include expired content
-F, --buildFuture include content with publishdate in the future
--cacheDir string filesystem path to cache directory. Defaults: $TMPDIR/hugo_cache/
--canonifyURLs if true, all relative URLs will be canonicalized using baseURL
--cleanDestinationDir remove files from destination not found in static directories
-c, --contentDir string filesystem path to content directory
-n, --count int number of times to build the site (default 13)
--cpuprofile string path/filename for the CPU profile file
-d, --destination string filesystem path to write files to
--disable404 do not render 404 page
--disableKinds stringSlice disable different kind of pages (home, RSS etc.)
--disableRSS do not build RSS files
--disableSitemap do not build Sitemap file
--enableGitInfo add Git revision, date and author info to the pages
--forceSyncStatic copy all files when static is changed.
-h, --help help for benchmark
--i18n-warnings print missing translations
--ignoreCache ignores the cache directory
-l, --layoutDir string filesystem path to layout directory
--memprofile string path/filename for the memory profile file
--noChmod don't sync permission mode of files
--noTimes don't sync modification time of files
--pluralizeListTitles pluralize titles in lists using inflect (default true)
--preserveTaxonomyNames preserve taxonomy names as written ("Gérard Depardieu" vs "gerard-depardieu")
--renderToMemory render to memory (only useful for benchmark testing)
-s, --source string filesystem path to read files relative from
--stepAnalysis display memory and timing of different steps of the program
-t, --theme string theme to use (located in /themes/THEMENAME/)
--themesDir string filesystem path to themes directory
--uglyURLs if true, use /filename.html instead of /filename/
```
### Options inherited from parent commands
```
--config string config file (default is path/config.yaml|json|toml)
--log enable Logging
--logFile string log File path (if set, logging enabled automatically)
--quiet build in quiet mode
-v, --verbose verbose output
--verboseLog verbose logging
```
### SEE ALSO
* [hugo](/commands/hugo/) - hugo builds your site
###### Auto generated by spf13/cobra on 23-May-2017
-31
View File
@@ -1,31 +0,0 @@
---
date: 2017-04-26T22:40:07+02:00
title: "hugo check"
slug: hugo_check
url: /commands/hugo_check/
---
## hugo check
Contains some verification checks
### Synopsis
Contains some verification checks
### Options inherited from parent commands
```
--config string config file (default is path/config.yaml|json|toml)
--log enable Logging
--logFile string log File path (if set, logging enabled automatically)
--quiet build in quiet mode
-v, --verbose verbose output
--verboseLog verbose logging
```
### SEE ALSO
* [hugo](/commands/hugo/) - hugo builds your site
* [hugo check ulimit](/commands/hugo_check_ulimit/) - Check system ulimit settings
###### Auto generated by spf13/cobra on 26-Apr-2017
@@ -1,35 +0,0 @@
---
date: 2017-04-26T22:40:07+02:00
title: "hugo check ulimit"
slug: hugo_check_ulimit
url: /commands/hugo_check_ulimit/
---
## hugo check ulimit
Check system ulimit settings
### Synopsis
Hugo will inspect the current ulimit settings on the system.
This is primarily to ensure that Hugo can watch enough files on some OSs
```
hugo check ulimit
```
### Options inherited from parent commands
```
--config string config file (default is path/config.yaml|json|toml)
--log enable Logging
--logFile string log File path (if set, logging enabled automatically)
--quiet build in quiet mode
-v, --verbose verbose output
--verboseLog verbose logging
```
### SEE ALSO
* [hugo check](/commands/hugo_check/) - Contains some verification checks
###### Auto generated by spf13/cobra on 26-Apr-2017
-40
View File
@@ -1,40 +0,0 @@
---
date: 2017-05-23T20:59:46+03:00
title: "hugo config"
slug: hugo_config
url: /commands/hugo_config/
---
## hugo config
Print the site configuration
### Synopsis
Print the site configuration, both default and custom settings.
```
hugo config [flags]
```
### Options
```
-h, --help help for config
```
### Options inherited from parent commands
```
--config string config file (default is path/config.yaml|json|toml)
--log enable Logging
--logFile string log File path (if set, logging enabled automatically)
--quiet build in quiet mode
-v, --verbose verbose output
--verboseLog verbose logging
```
### SEE ALSO
* [hugo](/commands/hugo/) - hugo builds your site
###### Auto generated by spf13/cobra on 23-May-2017
-44
View File
@@ -1,44 +0,0 @@
---
date: 2017-05-23T20:59:46+03:00
title: "hugo convert"
slug: hugo_convert
url: /commands/hugo_convert/
---
## hugo convert
Convert your content to different formats
### Synopsis
Convert your content (e.g. front matter) to different formats.
See convert's subcommands toJSON, toTOML and toYAML for more information.
### Options
```
-h, --help help for convert
-o, --output string filesystem path to write files to
-s, --source string filesystem path to read files relative from
--unsafe enable less safe operations, please backup first
```
### Options inherited from parent commands
```
--config string config file (default is path/config.yaml|json|toml)
--log enable Logging
--logFile string log File path (if set, logging enabled automatically)
--quiet build in quiet mode
-v, --verbose verbose output
--verboseLog verbose logging
```
### SEE ALSO
* [hugo](/commands/hugo/) - hugo builds your site
* [hugo convert toJSON](/commands/hugo_convert_tojson/) - Convert front matter to JSON
* [hugo convert toTOML](/commands/hugo_convert_totoml/) - Convert front matter to TOML
* [hugo convert toYAML](/commands/hugo_convert_toyaml/) - Convert front matter to YAML
###### Auto generated by spf13/cobra on 23-May-2017
@@ -1,44 +0,0 @@
---
date: 2017-05-23T20:59:46+03:00
title: "hugo convert toJSON"
slug: hugo_convert_toJSON
url: /commands/hugo_convert_tojson/
---
## hugo convert toJSON
Convert front matter to JSON
### Synopsis
toJSON converts all front matter in the content directory
to use JSON for the front matter.
```
hugo convert toJSON [flags]
```
### Options
```
-h, --help help for toJSON
```
### Options inherited from parent commands
```
--config string config file (default is path/config.yaml|json|toml)
--log enable Logging
--logFile string log File path (if set, logging enabled automatically)
-o, --output string filesystem path to write files to
--quiet build in quiet mode
-s, --source string filesystem path to read files relative from
--unsafe enable less safe operations, please backup first
-v, --verbose verbose output
--verboseLog verbose logging
```
### SEE ALSO
* [hugo convert](/commands/hugo_convert/) - Convert your content to different formats
###### Auto generated by spf13/cobra on 23-May-2017
@@ -1,44 +0,0 @@
---
date: 2017-05-23T20:59:46+03:00
title: "hugo convert toTOML"
slug: hugo_convert_toTOML
url: /commands/hugo_convert_totoml/
---
## hugo convert toTOML
Convert front matter to TOML
### Synopsis
toTOML converts all front matter in the content directory
to use TOML for the front matter.
```
hugo convert toTOML [flags]
```
### Options
```
-h, --help help for toTOML
```
### Options inherited from parent commands
```
--config string config file (default is path/config.yaml|json|toml)
--log enable Logging
--logFile string log File path (if set, logging enabled automatically)
-o, --output string filesystem path to write files to
--quiet build in quiet mode
-s, --source string filesystem path to read files relative from
--unsafe enable less safe operations, please backup first
-v, --verbose verbose output
--verboseLog verbose logging
```
### SEE ALSO
* [hugo convert](/commands/hugo_convert/) - Convert your content to different formats
###### Auto generated by spf13/cobra on 23-May-2017
@@ -1,44 +0,0 @@
---
date: 2017-05-23T20:59:46+03:00
title: "hugo convert toYAML"
slug: hugo_convert_toYAML
url: /commands/hugo_convert_toyaml/
---
## hugo convert toYAML
Convert front matter to YAML
### Synopsis
toYAML converts all front matter in the content directory
to use YAML for the front matter.
```
hugo convert toYAML [flags]
```
### Options
```
-h, --help help for toYAML
```
### Options inherited from parent commands
```
--config string config file (default is path/config.yaml|json|toml)
--log enable Logging
--logFile string log File path (if set, logging enabled automatically)
-o, --output string filesystem path to write files to
--quiet build in quiet mode
-s, --source string filesystem path to read files relative from
--unsafe enable less safe operations, please backup first
-v, --verbose verbose output
--verboseLog verbose logging
```
### SEE ALSO
* [hugo convert](/commands/hugo_convert/) - Convert your content to different formats
###### Auto generated by spf13/cobra on 23-May-2017
-40
View File
@@ -1,40 +0,0 @@
---
date: 2017-05-23T20:59:46+03:00
title: "hugo env"
slug: hugo_env
url: /commands/hugo_env/
---
## hugo env
Print Hugo version and environment info
### Synopsis
Print Hugo version and environment info. This is useful in Hugo bug reports.
```
hugo env [flags]
```
### Options
```
-h, --help help for env
```
### Options inherited from parent commands
```
--config string config file (default is path/config.yaml|json|toml)
--log enable Logging
--logFile string log File path (if set, logging enabled automatically)
--quiet build in quiet mode
-v, --verbose verbose output
--verboseLog verbose logging
```
### SEE ALSO
* [hugo](/commands/hugo/) - hugo builds your site
###### Auto generated by spf13/cobra on 23-May-2017
-39
View File
@@ -1,39 +0,0 @@
---
date: 2017-05-23T20:59:46+03:00
title: "hugo gen"
slug: hugo_gen
url: /commands/hugo_gen/
---
## hugo gen
A collection of several useful generators.
### Synopsis
A collection of several useful generators.
### Options
```
-h, --help help for gen
```
### Options inherited from parent commands
```
--config string config file (default is path/config.yaml|json|toml)
--log enable Logging
--logFile string log File path (if set, logging enabled automatically)
--quiet build in quiet mode
-v, --verbose verbose output
--verboseLog verbose logging
```
### SEE ALSO
* [hugo](/commands/hugo/) - hugo builds your site
* [hugo gen autocomplete](/commands/hugo_gen_autocomplete/) - Generate shell autocompletion script for Hugo
* [hugo gen doc](/commands/hugo_gen_doc/) - Generate Markdown documentation for the Hugo CLI.
* [hugo gen man](/commands/hugo_gen_man/) - Generate man pages for the Hugo CLI
###### Auto generated by spf13/cobra on 23-May-2017
@@ -1,58 +0,0 @@
---
date: 2017-05-23T20:59:46+03:00
title: "hugo gen autocomplete"
slug: hugo_gen_autocomplete
url: /commands/hugo_gen_autocomplete/
---
## hugo gen autocomplete
Generate shell autocompletion script for Hugo
### Synopsis
Generates a shell autocompletion script for Hugo.
NOTE: The current version supports Bash only.
This should work for *nix systems with Bash installed.
By default, the file is written directly to /etc/bash_completion.d
for convenience, and the command may need superuser rights, e.g.:
$ sudo hugo gen autocomplete
Add `--completionfile=/path/to/file` flag to set alternative
file-path and name.
Logout and in again to reload the completion scripts,
or just source them in directly:
$ . /etc/bash_completion
```
hugo gen autocomplete [flags]
```
### Options
```
--completionfile string autocompletion file (default "/etc/bash_completion.d/hugo.sh")
-h, --help help for autocomplete
--type string autocompletion type (currently only bash supported) (default "bash")
```
### Options inherited from parent commands
```
--config string config file (default is path/config.yaml|json|toml)
--log enable Logging
--logFile string log File path (if set, logging enabled automatically)
--quiet build in quiet mode
-v, --verbose verbose output
--verboseLog verbose logging
```
### SEE ALSO
* [hugo gen](/commands/hugo_gen/) - A collection of several useful generators.
###### Auto generated by spf13/cobra on 23-May-2017
-47
View File
@@ -1,47 +0,0 @@
---
date: 2017-05-23T20:59:46+03:00
title: "hugo gen doc"
slug: hugo_gen_doc
url: /commands/hugo_gen_doc/
---
## hugo gen doc
Generate Markdown documentation for the Hugo CLI.
### Synopsis
Generate Markdown documentation for the Hugo CLI.
This command is, mostly, used to create up-to-date documentation
of Hugo's command-line interface for http://gohugo.io/.
It creates one Markdown file per command with front matter suitable
for rendering in Hugo.
```
hugo gen doc [flags]
```
### Options
```
--dir string the directory to write the doc. (default "/tmp/hugodoc/")
-h, --help help for doc
```
### Options inherited from parent commands
```
--config string config file (default is path/config.yaml|json|toml)
--log enable Logging
--logFile string log File path (if set, logging enabled automatically)
--quiet build in quiet mode
-v, --verbose verbose output
--verboseLog verbose logging
```
### SEE ALSO
* [hugo gen](/commands/hugo_gen/) - A collection of several useful generators.
###### Auto generated by spf13/cobra on 23-May-2017
-43
View File
@@ -1,43 +0,0 @@
---
date: 2017-05-23T20:59:46+03:00
title: "hugo gen man"
slug: hugo_gen_man
url: /commands/hugo_gen_man/
---
## hugo gen man
Generate man pages for the Hugo CLI
### Synopsis
This command automatically generates up-to-date man pages of Hugo's
command-line interface. By default, it creates the man page files
in the "man" directory under the current directory.
```
hugo gen man [flags]
```
### Options
```
--dir string the directory to write the man pages. (default "man/")
-h, --help help for man
```
### Options inherited from parent commands
```
--config string config file (default is path/config.yaml|json|toml)
--log enable Logging
--logFile string log File path (if set, logging enabled automatically)
--quiet build in quiet mode
-v, --verbose verbose output
--verboseLog verbose logging
```
### SEE ALSO
* [hugo gen](/commands/hugo_gen/) - A collection of several useful generators.
###### Auto generated by spf13/cobra on 23-May-2017
-39
View File
@@ -1,39 +0,0 @@
---
date: 2017-05-23T20:59:46+03:00
title: "hugo import"
slug: hugo_import
url: /commands/hugo_import/
---
## hugo import
Import your site from others.
### Synopsis
Import your site from other web site generators like Jekyll.
Import requires a subcommand, e.g. `hugo import jekyll jekyll_root_path target_path`.
### Options
```
-h, --help help for import
```
### Options inherited from parent commands
```
--config string config file (default is path/config.yaml|json|toml)
--log enable Logging
--logFile string log File path (if set, logging enabled automatically)
--quiet build in quiet mode
-v, --verbose verbose output
--verboseLog verbose logging
```
### SEE ALSO
* [hugo](/commands/hugo/) - hugo builds your site
* [hugo import jekyll](/commands/hugo_import_jekyll/) - hugo import from Jekyll
###### Auto generated by spf13/cobra on 23-May-2017
@@ -1,43 +0,0 @@
---
date: 2017-05-23T20:59:46+03:00
title: "hugo import jekyll"
slug: hugo_import_jekyll
url: /commands/hugo_import_jekyll/
---
## hugo import jekyll
hugo import from Jekyll
### Synopsis
hugo import from Jekyll.
Import from Jekyll requires two paths, e.g. `hugo import jekyll jekyll_root_path target_path`.
```
hugo import jekyll [flags]
```
### Options
```
--force allow import into non-empty target directory
-h, --help help for jekyll
```
### Options inherited from parent commands
```
--config string config file (default is path/config.yaml|json|toml)
--log enable Logging
--logFile string log File path (if set, logging enabled automatically)
--quiet build in quiet mode
-v, --verbose verbose output
--verboseLog verbose logging
```
### SEE ALSO
* [hugo import](/commands/hugo_import/) - Import your site from others.
###### Auto generated by spf13/cobra on 23-May-2017
-42
View File
@@ -1,42 +0,0 @@
---
date: 2017-05-23T20:59:46+03:00
title: "hugo list"
slug: hugo_list
url: /commands/hugo_list/
---
## hugo list
Listing out various types of content
### Synopsis
Listing out various types of content.
List requires a subcommand, e.g. `hugo list drafts`.
### Options
```
-h, --help help for list
-s, --source string filesystem path to read files relative from
```
### Options inherited from parent commands
```
--config string config file (default is path/config.yaml|json|toml)
--log enable Logging
--logFile string log File path (if set, logging enabled automatically)
--quiet build in quiet mode
-v, --verbose verbose output
--verboseLog verbose logging
```
### SEE ALSO
* [hugo](/commands/hugo/) - hugo builds your site
* [hugo list drafts](/commands/hugo_list_drafts/) - List all drafts
* [hugo list expired](/commands/hugo_list_expired/) - List all posts already expired
* [hugo list future](/commands/hugo_list_future/) - List all posts dated in the future
###### Auto generated by spf13/cobra on 23-May-2017
-41
View File
@@ -1,41 +0,0 @@
---
date: 2017-05-23T20:59:46+03:00
title: "hugo list drafts"
slug: hugo_list_drafts
url: /commands/hugo_list_drafts/
---
## hugo list drafts
List all drafts
### Synopsis
List all of the drafts in your content directory.
```
hugo list drafts [flags]
```
### Options
```
-h, --help help for drafts
```
### Options inherited from parent commands
```
--config string config file (default is path/config.yaml|json|toml)
--log enable Logging
--logFile string log File path (if set, logging enabled automatically)
--quiet build in quiet mode
-s, --source string filesystem path to read files relative from
-v, --verbose verbose output
--verboseLog verbose logging
```
### SEE ALSO
* [hugo list](/commands/hugo_list/) - Listing out various types of content
###### Auto generated by spf13/cobra on 23-May-2017
@@ -1,42 +0,0 @@
---
date: 2017-05-23T20:59:46+03:00
title: "hugo list expired"
slug: hugo_list_expired
url: /commands/hugo_list_expired/
---
## hugo list expired
List all posts already expired
### Synopsis
List all of the posts in your content directory which has already
expired.
```
hugo list expired [flags]
```
### Options
```
-h, --help help for expired
```
### Options inherited from parent commands
```
--config string config file (default is path/config.yaml|json|toml)
--log enable Logging
--logFile string log File path (if set, logging enabled automatically)
--quiet build in quiet mode
-s, --source string filesystem path to read files relative from
-v, --verbose verbose output
--verboseLog verbose logging
```
### SEE ALSO
* [hugo list](/commands/hugo_list/) - Listing out various types of content
###### Auto generated by spf13/cobra on 23-May-2017
-42
View File
@@ -1,42 +0,0 @@
---
date: 2017-05-23T20:59:46+03:00
title: "hugo list future"
slug: hugo_list_future
url: /commands/hugo_list_future/
---
## hugo list future
List all posts dated in the future
### Synopsis
List all of the posts in your content directory which will be
posted in the future.
```
hugo list future [flags]
```
### Options
```
-h, --help help for future
```
### Options inherited from parent commands
```
--config string config file (default is path/config.yaml|json|toml)
--log enable Logging
--logFile string log File path (if set, logging enabled automatically)
--quiet build in quiet mode
-s, --source string filesystem path to read files relative from
-v, --verbose verbose output
--verboseLog verbose logging
```
### SEE ALSO
* [hugo list](/commands/hugo_list/) - Listing out various types of content
###### Auto generated by spf13/cobra on 23-May-2017
-51
View File
@@ -1,51 +0,0 @@
---
date: 2017-05-23T20:59:46+03:00
title: "hugo new"
slug: hugo_new
url: /commands/hugo_new/
---
## hugo new
Create new content for your site
### Synopsis
Create a new content file and automatically set the date and title.
It will guess which kind of file to create based on the path provided.
You can also specify the kind with `-k KIND`.
If archetypes are provided in your theme or site, they will be used.
```
hugo new [path] [flags]
```
### Options
```
--editor string edit new content with this editor, if provided
-f, --format string frontmatter format (default "toml")
-h, --help help for new
-k, --kind string content type to create
-s, --source string filesystem path to read files relative from
```
### Options inherited from parent commands
```
--config string config file (default is path/config.yaml|json|toml)
--log enable Logging
--logFile string log File path (if set, logging enabled automatically)
--quiet build in quiet mode
-v, --verbose verbose output
--verboseLog verbose logging
```
### SEE ALSO
* [hugo](/commands/hugo/) - hugo builds your site
* [hugo new site](/commands/hugo_new_site/) - Create a new site (skeleton)
* [hugo new theme](/commands/hugo_new_theme/) - Create a new theme
###### Auto generated by spf13/cobra on 23-May-2017
-45
View File
@@ -1,45 +0,0 @@
---
date: 2017-05-23T20:59:46+03:00
title: "hugo new site"
slug: hugo_new_site
url: /commands/hugo_new_site/
---
## hugo new site
Create a new site (skeleton)
### Synopsis
Create a new site in the provided directory.
The new site will have the correct structure, but no content or theme yet.
Use `hugo new [contentPath]` to create new content.
```
hugo new site [path] [flags]
```
### Options
```
--force init inside non-empty directory
-f, --format string config & frontmatter format (default "toml")
-h, --help help for site
```
### Options inherited from parent commands
```
--config string config file (default is path/config.yaml|json|toml)
--log enable Logging
--logFile string log File path (if set, logging enabled automatically)
--quiet build in quiet mode
-s, --source string filesystem path to read files relative from
-v, --verbose verbose output
--verboseLog verbose logging
```
### SEE ALSO
* [hugo new](/commands/hugo_new/) - Create new content for your site
###### Auto generated by spf13/cobra on 23-May-2017
-44
View File
@@ -1,44 +0,0 @@
---
date: 2017-05-23T20:59:46+03:00
title: "hugo new theme"
slug: hugo_new_theme
url: /commands/hugo_new_theme/
---
## hugo new theme
Create a new theme
### Synopsis
Create a new theme (skeleton) called [name] in the current directory.
New theme is a skeleton. Please add content to the touched files. Add your
name to the copyright line in the license and adjust the theme.toml file
as you see fit.
```
hugo new theme [name] [flags]
```
### Options
```
-h, --help help for theme
```
### Options inherited from parent commands
```
--config string config file (default is path/config.yaml|json|toml)
--log enable Logging
--logFile string log File path (if set, logging enabled automatically)
--quiet build in quiet mode
-s, --source string filesystem path to read files relative from
-v, --verbose verbose output
--verboseLog verbose logging
```
### SEE ALSO
* [hugo new](/commands/hugo_new/) - Create new content for your site
###### Auto generated by spf13/cobra on 23-May-2017
-86
View File
@@ -1,86 +0,0 @@
---
date: 2017-05-23T20:59:46+03:00
title: "hugo server"
slug: hugo_server
url: /commands/hugo_server/
---
## hugo server
A high performance webserver
### Synopsis
Hugo provides its own webserver which builds and serves the site.
While hugo server is high performance, it is a webserver with limited options.
Many run it in production, but the standard behavior is for people to use it
in development and use a more full featured server such as Nginx or Caddy.
'hugo server' will avoid writing the rendered and served content to disk,
preferring to store it in memory.
By default hugo will also watch your files for any changes you make and
automatically rebuild the site. It will then live reload any open browser pages
and push the latest content to them. As most Hugo sites are built in a fraction
of a second, you will be able to save and see your changes nearly instantly.
```
hugo server [flags]
```
### Options
```
--appendPort append port to baseURL (default true)
-b, --baseURL string hostname (and path) to the root, e.g. http://spf13.com/
--bind string interface to which the server will bind (default "127.0.0.1")
-D, --buildDrafts include content marked as draft
-E, --buildExpired include expired content
-F, --buildFuture include content with publishdate in the future
--cacheDir string filesystem path to cache directory. Defaults: $TMPDIR/hugo_cache/
--canonifyURLs if true, all relative URLs will be canonicalized using baseURL
--cleanDestinationDir remove files from destination not found in static directories
-c, --contentDir string filesystem path to content directory
-d, --destination string filesystem path to write files to
--disable404 do not render 404 page
--disableKinds stringSlice disable different kind of pages (home, RSS etc.)
--disableLiveReload watch without enabling live browser reload on rebuild
--disableRSS do not build RSS files
--disableSitemap do not build Sitemap file
--enableGitInfo add Git revision, date and author info to the pages
--forceSyncStatic copy all files when static is changed.
-h, --help help for server
--i18n-warnings print missing translations
--ignoreCache ignores the cache directory
-l, --layoutDir string filesystem path to layout directory
--meminterval string interval to poll memory usage (requires --memstats), valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h". (default "100ms")
--memstats string log memory usage to this file
--noChmod don't sync permission mode of files
--noTimes don't sync modification time of files
--pluralizeListTitles pluralize titles in lists using inflect (default true)
-p, --port int port on which the server will listen (default 1313)
--preserveTaxonomyNames preserve taxonomy names as written ("Gérard Depardieu" vs "gerard-depardieu")
--renderToDisk render to Destination path (default is render to memory & serve from there)
-s, --source string filesystem path to read files relative from
--stepAnalysis display memory and timing of different steps of the program
-t, --theme string theme to use (located in /themes/THEMENAME/)
--themesDir string filesystem path to themes directory
--uglyURLs if true, use /filename.html instead of /filename/
-w, --watch watch filesystem for changes and recreate as needed (default true)
```
### Options inherited from parent commands
```
--config string config file (default is path/config.yaml|json|toml)
--log enable Logging
--logFile string log File path (if set, logging enabled automatically)
--quiet build in quiet mode
-v, --verbose verbose output
--verboseLog verbose logging
```
### SEE ALSO
* [hugo](/commands/hugo/) - hugo builds your site
###### Auto generated by spf13/cobra on 23-May-2017
-42
View File
@@ -1,42 +0,0 @@
---
date: 2017-05-23T20:59:46+03:00
title: "hugo undraft"
slug: hugo_undraft
url: /commands/hugo_undraft/
---
## hugo undraft
Undraft changes the content's draft status from 'True' to 'False'
### Synopsis
Undraft changes the content's draft status from 'True' to 'False'
and updates the date to the current date and time.
If the content's draft status is 'False', nothing is done.
```
hugo undraft path/to/content [flags]
```
### Options
```
-h, --help help for undraft
```
### Options inherited from parent commands
```
--config string config file (default is path/config.yaml|json|toml)
--log enable Logging
--logFile string log File path (if set, logging enabled automatically)
--quiet build in quiet mode
-v, --verbose verbose output
--verboseLog verbose logging
```
### SEE ALSO
* [hugo](/commands/hugo/) - hugo builds your site
###### Auto generated by spf13/cobra on 23-May-2017
-40
View File
@@ -1,40 +0,0 @@
---
date: 2017-05-23T20:59:46+03:00
title: "hugo version"
slug: hugo_version
url: /commands/hugo_version/
---
## hugo version
Print the version number of Hugo
### Synopsis
All software has versions. This is Hugo's.
```
hugo version [flags]
```
### Options
```
-h, --help help for version
```
### Options inherited from parent commands
```
--config string config file (default is path/config.yaml|json|toml)
--log enable Logging
--logFile string log File path (if set, logging enabled automatically)
--quiet build in quiet mode
-v, --verbose verbose output
--verboseLog verbose logging
```
### SEE ALSO
* [hugo](/commands/hugo/) - hugo builds your site
###### Auto generated by spf13/cobra on 23-May-2017
-111
View File
@@ -1,111 +0,0 @@
---
aliases:
- /doc/contributing/
- /meta/contributing/
lastmod: 2015-02-12
date: 2013-07-01
menu:
main:
parent: community
next: /tutorials/automated-deployments
prev: /community/mailing-list
title: Contributing to Hugo
weight: 30
---
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]({{< relref "meta/roadmap.md" >}}) or contact the dev team via the [Forums](https://discuss.gohugo.io/) or [Gitter](https://gitter.im/spf13/hugo) about what may make sense 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:
* Have test cases for the new code. If you have questions about how to do it, please ask in your pull request.
* Run `go fmt`.
* Squash your commits into a single commit. `git rebase -i`. It's okay to force update your pull request.
* Run `make check` and ensure it succeeds. [Travis CI](https://travis-ci.org/spf13/hugo) and [Appveyor](https://ci.appveyor.com/project/spf13/hugo) will runs these checks and fail the build if `make check` fails.
## Contribution Overview
We wrote a [detailed guide]({{< relref "tutorials/how-to-contribute-to-hugo.md" >}}) for newcomers that guides you step by step to your first contribution. If you are more experienced, follow the guide below.
# Building from source
## Vendored Dependencies
Hugo uses [govendor][] to vendor dependencies, but we don't commit the vendored packages themselves to the Hugo git repository.
Therefore, a simple `go get` is not supported since `go get` is not vendor-aware.
You **must use govendor** to fetch Hugo's dependencies.
## Fetch the Sources
go get github.com/kardianos/govendor
govendor get github.com/spf13/hugo
## Running Hugo
cd $HOME/go/src/github.com/spf13/hugo
go run main.go
## Building Hugo
cd $HOME/go/src/github.com/spf13/hugo
make build
# or to install to $HOME/go/bin:
make install
# Showcase additions
You got your new website running and it's powered by Hugo? Great. You can add your website with a few steps to the [showcase](/showcase/).
First, make sure that you created a [fork](https://help.github.com/articles/fork-a-repo/) of Hugo on GitHub and cloned your fork on your local computer. Next, create a separate branch for your additions:
```
# You can choose a different descriptive branch name if you like
git checkout -b showcase-addition
```
Let's create a new document that contains some metadata of your homepage. Replace `example` in the following examples with something unique like the name of your website. Inside the terminal enter the following commands:
```
cd docs
hugo new showcase/example.md
```
You should find the new file at `content/showcase/example.md`. Open it in an editor. The file should contain a frontmatter with predefined variables like below:
```
---
date: 2016-02-12T21:01:18+01:00
description: ""
license: ""
licenseLink: ""
sitelink: http://spf13.com/
sourceLink: https://github.com/spf13/spf13.com
tags:
- personal
- blog
thumbnail: /img/spf13-tn.jpg
title: example
---
```
Add at least values for `sitelink`, `title`, `description` and a path for `thumbnail`.
Furthermore, we need to create the thumbnail of your website. **It's important that the thumbnail has the required dimensions of 600px by 400px.** Give your thumbnail a name like `example-tn.png`. Save it under `docs/static/img/`.
Check a last time that everything works as expected. Start Hugo's built-in server in order to inspect your local copy of the showcase in the browser:
hugo server
If everything looks fine, we are ready to commit your additions. For the sake of best practices, please make sure that your commit follows our [code contribution guideline](https://github.com/spf13/hugo#code-contribution-guideline).
git commit -m"docs: Add example.com to the showcase"
Last but not least, we're ready to create a [pull request](https://github.com/spf13/hugo/compare).
Don't forget to accept the contributor license agreement. Click on the yellow badge in the automatically added comment in the pull request.
[govendor]: https://github.com/kardianos/govendor
-51
View File
@@ -1,51 +0,0 @@
---
lastmod: 2015-05-25
date: 2013-07-01
menu:
main:
parent: community
next: /community/contributing
prev: /extras/urls
title: Mailing List
weight: 10
---
## Discussion Forum
Hugo has its own [discussion forum](http://discuss.gohugo.io/) powered by [Discourse](http://www.discourse.org/).
Please use this for all discussions, questions, etc.
### Twitter
Get the latest bite-sized news and themes from the Hugo community on Twitter by following [@gohugoio](http://twitter.com/gohugoio).
## Mailing List
Hugo has two mailing lists:
### Announcements
Very low traffic. Only releases will be emailed here.
https://groups.google.com/forum/#!forum/hugo-announce
### Discussion (Archive)
**This has been replaced with the [Hugo discussion forum](http://discuss.gohugo.io/).**
It is available for archival purposes.
https://groups.google.com/forum/#!forum/hugo-discuss
## Other Resources
### GoNuts
For general Go questions or discussion please refer to the Go mailing list.
https://groups.google.com/forum/#!forum/golang-nuts
### GitHub Issues
https://github.com/spf13/hugo/issues
-140
View File
@@ -1,140 +0,0 @@
---
lastmod: 2017-03-02
date: 2014-03-24T20:00:00Z
linktitle: Press
notoc: true
title: Press, Blogs and Media Coverage
weight: 20
---
### Help keep this list up to date
Know of a post, article or tutorial on Hugo? [Add it to this list](https://github.com/spf13/hugo/edit/master/docs/content/community/press.md).
## Press and Articles
Hugo has been featured in the following Blog Posts, Press and Media.
| Title | Author | Date |
| ------ | ------ | -----: |
| [Hugo Easy Gallery - Automagical PhotoSwipe image gallery with a one-line shortcode](https://www.liwen.id.au/heg/)| Li-Wen Yip | 2017-03-25 |
| [Hugo Tutorial: How to Build & Host a (Very Fast) Static E-Commerce Site](https://snipcart.com/blog/hugo-tutorial-static-site-ecommerce) | Snipcart | 2017-03-12 |
| [Automagical image gallery in Hugo with PhotoSwipe and jQuery](https://www.liwen.id.au/photoswipe/)| Li-Wen Yip | 2017-03-04 |
| [Adding Isso Comments to Hugo](https://stiobhart.net/2017-02-24-isso-comments/) | Stíobhart Matulevicz | 2017-02-24 |
| [Zero to HTTP/2 with AWS and Hugo](https://habd.as/zero-to-http-2-aws-hugo/) | Josh Habdas | 2017-02-16 |
| [How to Password Protect a Hugo Site](https://www.aerobatic.com/blog/password-protect-a-hugo-site/) | Aerobatic | 2017-02-19 |
| [Switching from Wordpress to Hugo](http://schnuddelhuddel.de/switching-from-wordpress-to-hugo/) | Mario Martelli | 2017-02-19 | ]
| [Deploy a Hugo site to Aerobatic with CircleCI ](https://www.aerobatic.com/blog/hugo-github-circleci/) | Aerobatic | 2017-02-14 |
| [NPM scripts for building and deploying Hugo site](https://www.aerobatic.com/blog/hugo-npm-buildtool-setup/) | Aerobatic | 2017-02-12 |
| [Getting started with Hugo and the plain-blog theme, on NearlyFreeSpeech.Net](https://www.penwatch.net/cms/get_started_plain_blog/) | Li-aung “Lewis” Yip | 2017-02-12 |
| [Build a Hugo site using Cloud9 IDE and host on App Engine](https://loyall.ch/lab/2017/01/build-a-static-website-with-cloud9-hugo-and-app-engine/)| Pascal Aubort | 2017-02-05 |
| [Hugo Continuous Deployment with Bitbucket Pipelines and Aerobatic](https://www.aerobatic.com/blog/hugo-bitbucket-pipelines/) | Aerobatic | 2017-02-04 |
| [How to use Firebase to host a Hugo site](https://www.m0d3rnc0ad.com/post/static-site-firebase/) | Andrew Cuga | 2017-02-04 |
| [A publishing workflow for teams using static site generators](https://www.keybits.net/post/publishing-workflow-for-teams-using-static-site-generators/) | Tom Atkins | 2017-01-02 |
| [How To Dynamically Use Google Fonts In A Hugo Website](https://stoned.io/web-development/hugo/How-To-Dynamically-Use-Google-Fonts-In-A-Hugo-Website/) | Hash Borgir | 2016-10-27 |
| [Embedding Facebook In A Hugo Template](https://stoned.io/web-development/hugo/Embedding-Facebook-In-A-Hugo-Template/) | Hash Borgir | 2016-10-22 |
| [通过 Gitlab-cl 将 Hugo blog 自动部署至 GitHub](https://zetaoyang.github.io/post/2016/10/17/gitlab-cl.html) <small>(Chinese, Continious integration)</small> | Zetao Yang | 2016-10-17 |
| [A Step-by-Step Guide: Hugo on Netlify](https://www.netlify.com/blog/2016/09/21/a-step-by-step-guide-hugo-on-netlify/) | Eli Williamson | 2016-09-21 |
| [Building our site: From Django & Wordpress to a static generator (Part I)](https://tryolabs.com/blog/2016/09/20/building-our-site-django-wordpress-to-static-part-i/) | Alan Descoins | 2016-09-20 |
| [Webseitenmaschine - Statische Websites mit Hugo erzeugen](http://www.heise.de/ct/ausgabe/2016-12-Statische-Websites-mit-Hugo-erzeugen-3211704.html) <small>(German, $)</small> | Christian Helmbold | 2016-05-27 |
| [Cómo hacer sitios web estáticos con Hugo y Go - Platzi](https://www.youtube.com/watch?v=qaXXpdiCHXE) <small>(Video tutorial)</small> | Verónica López | 2016-04-06 |
| [CDNOverview: A CDN comparison site made with Hugo](https://www.cloakfusion.com/cdnoverview-cdn-comparison-site-made-hugo/) | Thijs de Zoete | 2016-02-23 |
| [Hugo: A Modern WebSite Engine That Just Works](https://github.com/shekhargulati/52-technologies-in-2016/blob/master/07-hugo/README.md) | Shekhar Gulati | 2016-02-14 |
| [Minify Hugo Generated HTML](http://ratson.name/blog/minify-hugo-generated-html/) | Ratson | 2016-02-02 |
| [<span lang="ja">HugoのデプロイをWerckerからCircle CIに変更した</span> - log](http://log.deprode.net/logs/2016-01-17/) | Deprode | 2016-01-17 |
| [Static site generators: el futuro de las webs estáticas<br>(Hugo, Jekyll, Flask y otros)](http://sitelabs.es/static-site-generators-futuro-las-webs-estaticas/) | Eneko Sarasola | 2016-01-09 |
| [Writing a Lambda Function for Hugo](https://blog.jolexa.net/post/writing-a-lambda-function-for-hugo/) | Jeremy Olexa | 2016-01-01 |
| [Ein Blog mit Hugo erstellen - Tutorial](http://privat.albicker.org/tags/hugo.html) <small>(Deutsch/German)</small> | Bernhard Albicker | 2015-12-30 |
| [How to host Hugo static website generator on AWS Lambda](http://bezdelev.com/post/hugo-aws-lambda-static-website/) | Ilya Bezdelev | 2015-12-15 |
| [Migrating from Pelican to Hugo](http://www.softinio.com/post/migrating-from-pelican-to-hugo/) | Salar Rahmanian | 2015-11-29 |
| [Static Website Generators Reviewed: Jekyll, Middleman, Roots, Hugo](http://www.smashingmagazine.com/2015/11/static-website-generators-jekyll-middleman-roots-hugo-review/) | Mathias Biilmann Christensen | 2015-11-16 |
| [How To Deploy a Hugo Site to Production with Git Hooks on Ubuntu 14.04](https://www.digitalocean.com/community/tutorials/how-to-deploy-a-hugo-site-to-production-with-git-hooks-on-ubuntu-14-04) | Justin Ellingwood | 2015-11-12 |
| [How To Install and Use Hugo, a Static Site Generator, on Ubuntu 14.04](https://www.digitalocean.com/community/tutorials/how-to-install-and-use-hugo-a-static-site-generator-on-ubuntu-14-04) | Justin Ellingwood | 2015-11-09 |
| [Switching from Wordpress to Hugo](http://justinfx.com/2015/11/08/switching-from-wordpress-to-hugo/) | Justin Israel | 2015-11-08 |
| [Hands-on Experience with Hugo as a Static Site Generator](http://usersnap.com/blog/hands-on-experience-with-hugo-static-site-generator/) | Thomas Peham | 2015 -10-15 |
| [Statische Webseites mit Hugo erstellen/Vortrag mit Foliensatz (deutsch)](http://sfd.koelnerlinuxtreffen.de/2015/HaraldWeidner/) | Harald Weidner | 2015-09-19 |
| [Moving from WordPress to Hugo](http://abhipandey.com/2015/09/moving-to-hugo/) | Abhishek Pandey | 2015-09-15 |
| [<span lang="zh-CN">通过webhook将Hugo自动部署至GitHub Pages和GitCafe Pages</span> <small>(Automated&nbsp;deployment)</small>](http://blog.coderzh.com/2015/09/13/use-webhook-automated-deploy-hugo/) | CoderZh | 2015-09-13 |
| [<span lang="zh-CN">使用hugo搭建个人博客站点</span> <small>(Using Hugo to build a personal blog site)</small>](http://blog.coderzh.com/2015/08/29/hugo/) | CoderZh | 2015-08-29 |
| [Good-Bye Wordpress, Hello Hugo!](http://blog.arminhanisch.de/2015/08/blog-migration-zu-hugo/) <small>(German)</small> | Armin Hanisch | 2015-08-18 |
| [Générer votre site web statique avec Hugo <small>(Generate your static site with Hugo)<small>](http://www.linux-pratique.com/?p=191) | Benoît Benedetti | 2015-06-26 |
| [<span lang="ja">Hugo向けの新しいテーマを作った</span> <small>(I created a new theme for Hugo)<small>](https://yet.unresolved.xyz/blog/2016/10/03/how-to-make-of-hugo-theme/) | Daisuke Tsuji | 2015-06-20 |
| [Hugo - Gerando um site com conteúdo estático. (Portuguese Brazil)](http://blog.ffrizzo.com/posts/hugo/) | Fabiano Frizzo | 2015-06-02 |
| [An Introduction to Static Site Generators](http://davidwalsh.name/introduction-static-site-generators) | Eduardo Bouças | 2015-05-20 |
| [Hugo Still Rules](http://cheekycoder.com/2015/05/hugo-still-rules/) | Cheeky Coder | 2015-05-18 |
| [hugo - Static Site Generator](http://gscacco.github.io/post/hugo/) | G Scaccoio | 2015-05-04 |
| [<span lang="ja">WindowsでHugoを使う</span>](http://ureta.net/2015/05/hugo-on-windows/) | <span lang="ja">うれ太郎</span> | 2015-05-01 |
| [<span lang="ja">Hugoのshortcodesを用いてサイトにスライドなどを埋め込む</span>](http://blog.yucchiy.com/2015/04/29/hugo-shortcode/) | Yucchiy | 2015-04-29 |
| [<span lang="ja">HugoとCircleCIでGitHub PagesにBlogを公開してみたら超簡単だった</span>](http://hori-ryota.github.io/blog/create-blog-with-hugo-and-circleci/) | Hori Ryota | 2015-04-17 |
| [10 Best Static Site Generators](http://beebom.com/2015/04/best-static-site-generators) | Aniruddha Mysore | 2015-04-06 |
| [Goodbye WordPress; Hello Hugo](http://willwarren.com/2015/04/05/goodbye-wordpress-hello-hugo/) | Will Warren | 2015-04-05 |
| [Static Websites with Hugo on Google Cloud Storage](http://www.moxie.io/post/static-websites-with-hugo-on-google-cloud-storage/) | Moxie Input/Output | 2015-04-02 |
| [De nuevo iniciando un blog](https://alvarolizama.net/) | Alvaro Lizama | 2015-03-29 |
| [We moved our blog from Posthaven to Hugo after only three posts. Why?](http://blog.hypriot.com/post/moved-from-posthaven-to-hugo/) | Hypriot | 2015-03-27 |
| [Top Static Site Generators in 2015](http://superdevresources.com/static-site-generators-2015/) | Kanishk Kunal | 2015-03-12 |
| [Moving to Hugo](http://abiosoft.com/moving-to-hugo/) | Abiola Ibrahim | 2015-03-08 |
| [Migrating a blog (yes, this one!) from Wordpress to Hugo](http://justindunham.net/migrating-from-wordpress-to-hugo/) | Justin Dunham | 2015-02-13 |
| [<span lang="ja">blogをoctopressからHugoに乗り換えたメモ</span>](http://blog.jigyakkuma.org/2015/02/11/hugo/) | jigyakkuma | 2015-02-11 |
| [<span lang="ja">Hugoでブログをつくった</span>](http://porgy13.github.io/post/new-hugo-blog/) | porgy13 | 2015-02-07 |
| [<span lang="ja">Hugoにブログを移行した</span>](http://keichi.net/post/first/) | Keichi Takahashi | 2015-02-04 |
| [<span lang="zh-CN">Hugo静态网站生成器中文教程</span>](http://nanshu.wang/post/2015-01-31/) | Nanshu Wang | 2015-01-31 |
| [<span lang="ja">Hugo + GitHub Pages + Wercker CI = ¥0(無料)<br>でコマンド 1 発(自動化)でサイト<br>・ブログを公開・運営・分析・収益化</span>](http://qiita.com/yoheimuta/items/8a619cac356bed89a4c9) | Yohei Yoshimuta | 2015-01-31 |
| [Running Hugo websites on anynines](http://blog.anynines.com/running-hugo-websites-on-anynines/) | Julian Weber | 2015-01-30 |
| [MiddlemanからHugoへ移行した](http://re-dzine.net/2015/01/hugo/) | Haruki Konishi | 2015-01-21 |
| [WordPress から Hugo に乗り換えました](http://rakuishi.com/archives/wordpress-to-hugo/) | rakuishi | 2015-01-20 |
| [HUGOを使ってサイトを立ち上げる方法](http://qiita.com/syui/items/869538099551f24acbbf) | Syui | 2015-01-17 |
| [<span lang="ja">Jekyllが許されるのは小学生までだよね</span>](http://t32k.me/mol/log/hugo/) | Ishimoto Koji | 2015-01-16 |
| [Getting started with Hugo](http://anthonyfok.org/post/getting-started-with-hugo/) | Anthony Fok | 2015-01-12 |
| [<span lang="zh-CN">把这个博客静态化了</span> <small>(Migrate to Hugo)</small>](http://lich-eng.com/2015/01/03/migrate-to-hugo/)| Li Cheng | 2015-01-03 |
| [Porting my blog with Hugo](http://blog.srackham.com/posts/porting-my-blog-with-hugo/) | Stuart Rackham | 2014-12-30 |
| [Hugoを使ってみたときのメモ](http://machortz.github.io/posts/usinghugo/) | Machortz | 2014-12-29 |
| [OctopressからHugoへ移行した](http://deeeet.com/writing/2014/12/25/hugo/) | Taichi Nakashima | 2014-12-25 |
| [Migrating to Hugo From Octopress](http://nathanleclaire.com/blog/2014/12/22/migrating-to-hugo-from-octopress/) | Nathan LeClaire | 2014-12-22 |
| [Dynamic Pages with GoHugo.io](http://cyrillschumacher.com/2014/12/21/dynamic-pages-with-gohugo.io/) | Cyrill Schumacher | 2014-12-21 |
| [6 Static Blog Generators That Arent Jekyll](http://www.sitepoint.com/6-static-blog-generators-arent-jekyll/) | David Turnbull | 2014-12-08 |
| [Travel Blogging Setup](http://www.stou.dk/2014/11/travel-blogging-setup/) | Rasmus Stougaard | 2014-11-23 |
| [Hosting A Hugo Website Behind Nginx](http://www.bigbeeconsultants.co.uk/blog/hosting-hugo-website-behind-nginx) | Rick Beton | 2014-11-20 |
| [<span lang="zh-CN">使用Hugo搭建免费个人Blog</span> <small>(How to use Hugo)</small>](http://ulricqin.com/post/how-to-use-hugo/) | Ulric Qin <span lang="zh-CN">秦晓辉</span> | 2014-11-11 |
| [Built in Speed and Built for Speed by Hugo](http://cheekycoder.com/2014/10/built-for-speed-by-hugo/) | Cheeky Coder | 2014-10-30 |
| [Hugo para crear sitios web estáticos](http://www.webbizarro.com/noticias/1076/hugo-para-crear-sitios-web-estaticos/) | Web Bizarro | 2014-08-19 |
| [Going with hugo](http://www.markuseliasson.se/article/going-with-hugo/) | Markus Eliasson | 2014-08-18 |
| [Benchmarking Jekyll, Hugo and Wintersmith](http://fredrikloch.me/post/2014-08-12-Jekyll-and-its-alternatives-from-a-site-generation-point-of-view/) | Fredrik Loch | 2014-08-12 |
| [Goodbye Octopress, Hello Hugo!](http://andreimihu.com/blog/2014/08/11/goodbye-octopress-hello-hugo/) | Andrei Mihu | 2014-08-11 |
| [Beautiful sites for Open Source projects](http://beautifulopen.com/2014/08/09/hugo/) | Beautiful Open | 2014-08-09 |
| [Hugo: Beyond the Defaults](http://npf.io/2014/08/hugo-beyond-the-defaults/) | Nate Finch | 2014-08-08 |
| [First Impressions of Hugo](https://peteraba.com/blog/first-impressions-of-hugo/) | Peter Aba | 2014-06-06 |
| [New Site Workflow](http://vurt.co.uk/post/new_website/) | Giles Paterson | 2014-08-05 |
| [How I Learned to Stop Worrying and Love the (Static) Web](http://cognition.ca/post/about-hugo/) | Joshua McKenty | 2014-08-04 |
| [Hugo - Static Site Generator](http://kenwoo.io/blog/hugo---static-site-generator/) | Kenny Woo | 2014-08-03 |
| [Hugo Is Friggin' Awesome](http://npf.io/2014/08/hugo-is-awesome/) | Nate Finch | 2014-08-01 |
| [<span lang="zh-CN">再次搬家</span> <small>(Move from WordPress to Hugo)</small>](http://www.chingli.com/misc/move-from-wordpress-to-hugo/) | <span lang="zh-CN">青砾</span> (chingli) | 2014-07-12 |
| [Embedding Gists in Hugo](http://danmux.com/posts/embedded_gists/) | Dan Mull | 2014-07-05 |
| [An Introduction To Hugo](http://www.cirrushosting.com/web-hosting-blog/an-introduction-to-hugo/) | Dan Silber | 2014-07-01 |
| [Moving to Hugo](http://danmux.com/posts/hugo_based_blog/) | Dan Mull | 2014-05-29 |
| [<span lang="zh-CN">开源之静态站点生成器排行榜</span><br><small>(Leaderboard of open-source static website generators)</small>](http://code.csdn.net/news/2819909) | CSDN.net | 2014-05-23 |
| [Finally, a satisfying and effective blog setup](http://michaelwhatcott.com/now-powered-by-hugo/) | Michael Whatcott | 2014-05-20 |
| [Hugo from scratch](http://zackofalltrades.com/notes/2014/05/hugo-from-scratch/) | Zack Williams | 2014-05-18 |
| [Why I switched away from Jekyll](http://www.jakejanuzelli.com/why-I-switched-away-from-jekyll/) | Jake Januzelli | 2014-05-10 |
| [Welcome our new blog](http://blog.ninya.io/posts/welcome-our-new-blog/) | Ninya.io | 2014-04-11 |
| [Mission Not Accomplished](http://johnsto.co.uk/blog/mission-not-accomplished/) | Dave Johnston | 2014-04-03 |
| [Hugo - A Static Site Builder in Go](http://deepfriedcode.com/post/hugo/) | Deep Fried Code | 2014-03-30 |
| [Adventures in Angular Podcast](http://devchat.tv/adventures-in-angular/003-aia-gdes) | Matias Niemela | 2014-03-28 |
| [Hugo](http://bra.am/post/hugo/) | bra.am | 2014-03-23 |
| [Converting Blogger To Markdown](http://trishagee.github.io/project/atom-to-hugo/) | Trisha Gee | 2014-03-20 |
| [Moving to Hugo Static Web Pages](http://tepid.org/tech/hugo-web/) | Tobias Weingartner | 2014-03-16 |
| [New Blog Engine: Hugo](https://blog.afoolishmanifesto.com/posts/hugo/) | fREW Schmidt | 2014-03-15 |
| [Hugo + gulp.js = Huggle](http://ktmud.github.io/huggle/en/intro/) ([English](http://ktmud.github.io/huggle/en/intro/), [<span lang="zh-CN">中文</span>](http://ktmud.github.io/huggle/zh/intro/)) | Jesse Yang <span lang="zh-CN">杨建超</span> | 2014-03-08 |
| [Powered by Hugo](http://kieranhealy.org/blog/archives/2014/02/24/powered-by-hugo/) | Kieran Healy | 2014-02-24 |
| [<span lang="ja">静的サイトを素早く構築するために<br>GoLangで作られたジェネレータHugo</span>](http://hamasyou.com/blog/2014/02/21/hugo/)| <div lang="ja" style="line-height: 1.1;">Shogo Hamada<br>濱田章吾</div> | 2014-02-21 |
| [Latest Roundup of Useful Tools For Developers](http://codegeekz.com/latest-roundup-of-useful-tools-for-developers/) | CodeGeekz | 2014-02-13 |
| [Hugo: Static Site Generator written in Go](http://www.braveterry.com/2014/02/06/hugo-static-site-generator-written-in-go/) | Brave Terry | 2014-02-06 |
| [10 Useful HTML5 Tools for Web Designers and Developers](http://designdizzy.com/10-useful-html5-tools-for-web-designers-and-developers/) | Design Dizzy | 2014-02-04 |
| [Hugo Fast, Flexible Static Site Generator](http://cube3x.com/hugo-fast-flexible-static-site-generator/) | Joby Joseph | 2014-01-18 |
| [Hugo: A new way to build static website](http://www.w3update.com/opensource/hugo-a-new-way-to-build-static-website.html) | w3update | 2014-01-17 |
| [Xaprb now uses Hugo](http://xaprb.com/blog/2014/01/15/using-hugo/) | Baron Schwartz | 2014-01-15 |
| [New jQuery Plugins And Resources That Web Designers Need](http://www.designyourway.net/blog/resources/new-jquery-plugins-and-resources-that-web-designers-need/) | Design Your Way | 2014-01-01 |
| [On Blog Construction](http://alexla.sh/post/on-blog-construction/) | Alexander Lash | 2013-12-27 |
| [Hugo](http://onethingwell.org/post/69070926608/hugo) | One Thing Well | 2013-12-05 |
| [In Praise Of Hugo](http://sound-guru.com/blog/post/hello-world/) | sound-guru.com | 2013-10-19 |
| [Hosting a blog on S3 and Cloudfront](http://www.danesparza.net/2013/07/hosting-a-blog-on-s3-and-cloudfront/) | Dan Esparza | 2013-07-24 |
-330
View File
@@ -1,330 +0,0 @@
---
lastmod: 2016-10-01
date: 2014-05-14T02:13:50Z
menu:
main:
parent: content
next: /content/ordering
prev: /content/types
title: Archetypes
weight: 50
toc: true
---
Typically, each piece of content you create within a Hugo project will have [front matter](/content/front-matter/) that follows a consistent structure. If you write blog posts, for instance, you might use the following front matter for the vast majority of those posts:
```toml
+++
title = ""
date = ""
slug = ""
tags = [
""
]
categories = [
""
]
draft = true
+++
```
You can always add non-typical front matter to any piece of content, but since it takes extra work to develop a theme that handles unique metadata, consistency is simpler.
With this in mind, Hugo has a convenient feature known as *archetypes* that allows users to define default front matter for new pieces of content.
By using archetypes, we can:
1. **Save time**. Stop writing the same front matter over and over again.
2. **Avoid errors**. Reduce the odds of typos, improperly formatted syntax, and other simple mistakes.
3. **Focus on more important things**. Avoid having to remember all of the fields that need to be associated with each piece of content. (This is particularly important for larger projects with complex front matter and a variety of content types.)
Let's explore how they work.
## Built-in Archetypes
If you've been using Hugo for a while, there's a decent chance you've come across archetypes without even realizing it. This is because Hugo includes a basic, built-in archetype that is used by default whenever it generates a content file.
To see this in action, open the command line, navigate into your project's directory, and run the following command:
```bash
hugo new hello-world.md
```
This `hugo new` command creates a new content file inside the project's `content` directory — in this case, a file named `hello-world.md` — and if you open this file, you'll notice it contains the following front matter:
```toml
+++
date = "2017-05-31T15:18:11+10:00"
draft = true
title = "hello world"
+++
```
Here, we can see that three fields have been added to the document: a `title` field that is based on the file name we defined, a `draft` field that ensures this content won't be published by default, and a `date` field that is auto-populated with the current date and time in the [RFC 3339](https://stackoverflow.com/questions/522251/whats-the-difference-between-iso-8601-and-rfc-3339-date-formats) format.
This, in its most basic form, is an example of an archetype. To understand how useful they can be though, it's best if we create our own.
## Creating Archetypes
In this section, we're going to create an archetype that will override the built-in archetype, allowing us to define custom front matter that will be included in any content files that we generate with the `hugo new` command.
To achieve this, create a file named `default.md` inside the `archetypes` folder of a Hugo project. (If the folder doesn't exist, create it.)
Then, inside this file, define the following front matter:
```toml
+++
slug = ""
tags = []
categories = []
draft = true
+++
```
You'll notice that we haven't defined a `title` or `date` field. This is because Hugo will automatically add these fields to the beginning of the front matter. We do, however, need to define the `draft` field if we want it to exist in our front matter.
You'll also notice that we're writing the front matter in the TOML format. It's possible to define archetype front matter in other formats, but a setting needs to be changed in the configuration file for this to be possible. See the "[Archetype Formats](#archetype-formats)" section of this article for more details.
Next, run the following command:
```bash
hugo new my-archetype-example.md
```
This command will generate a file named `my-archetype-example.md` inside the `content` directory, and this file will contain the following output:
```toml
+++
categories = []
date = "2017-05-31T15:21:13+10:00"
draft = true
slug = ""
tags = []
title = "my archetype example"
+++
```
As we can see, the file contains the `title` and `date` property that Hugo created for us, along with the front matter that we defined in the `archetypes/default.md` file.
You'll also notice that the fields have been sorted into alphabetical order. This is an unintentional side-effect that stems from the underlying code libraries that Hugo relies upon. It is, however, [a known issue that is actively being discussed](https://github.com/spf13/hugo/issues/452).
## Section Archetypes
By creating the `archetypes/default.md` file, we've created a default archetype that is more useful than the built-in archetype, but since Hugo encourages us to [organize our content into sections](/content/sections/), each of which will likely have different front matter requirements, a "one-size-fits-all" archetype isn't necessarily the best approach.
To accommodate for this, Hugo allows us to create archetypes for each section of our project. This means, whenever we generate content for a certain section, the appropriate front matter for that section will be automatically included in the generated file.
To see this in action, create a "photo" section by creating a directory named "photo" inside the `content` directory.
Then create a file named `photo.md` inside the `archetypes` directory and include the following front matter inside this file:
```toml
+++
image_url = ""
camera = ""
lens = ""
aperture = ""
iso = ""
draft = true
+++
```
Here, the critical detail is that the `photo.md` file in the `archetypes` directory is named after the `photo` section that we just created. By sharing a name, Hugo can understand that there's a relationship between them.
Next, run the following command:
```bash
hugo new photo/my-pretty-cat.md
```
This command will generate a file named `my-pretty-cat.md` inside the `content/photo` directory, and this file will contain the following output:
```toml
+++
aperture = ""
camera = ""
date = "2017-05-31T15:25:18+10:00"
draft = true
image_url = ""
iso = ""
lens = ""
title = "my pretty cat"
+++
```
As we can see, the `title` and `date` fields are still included by Hugo, but the rest of the front matter is being generated from the `photo.md` archetype instead of the `default.md` archetype.
### Tip: Default Values
To make archetypes more useful, define default values for any fields that will always be set to a range of limited options. In the case of the `photo.md` archetype, for instance, you could include lists of the various cameras and lenses that you own:
```toml
+++
image_url = ""
camera = [
"Sony RX100 Mark IV",
"Canon 5D Mark III",
"iPhone 6S"
]
lens = [
"Canon EF 50mm f/1.8",
"Rokinon 14mm f/2.8"
]
aperture = ""
iso = ""
draft = true
+++
```
Then, after generating a content file, simply remove the values that aren't relevant. This saves you from typing out the same options over and over again while ensuring consistency in how they're written.
## Scaffolding Content
Archetypes aren't limited to defining default front matter. They can also be used to define a default structure for the body of Markdown documents.
For example, imagine creating a `review.md` archetype for the purpose of writing camera reviews. This is what the front matter for such an archetype might look like:
```toml
+++
manufacturer = ""
model = ""
price = ""
releaseDate = ""
rating = ""
+++
```
But reviews tend to follow strict formats and need to answer specific questions, and it's with these expectations of precise structure that archetypes can prove to be even more useful.
For the sake of writing reviews, for instance, we could define the structure of a review beneath the front matter of the `review.md` file:
```markdown
+++
manufacturer = ""
model = ""
price = ""
releaseDate = ""
rating = ""
+++
## Introduction
## Sample Photos
## Conclusion
```
Then, whenever we use the `hugo new` command to create a new review, not only will the default front matter be copied into the newly created Markdown document, but the body of the `review.md` archetype will also be copied.
To take this further though — and to ensure authors on multi-author websites are on the same page about how content should be written — we could include notes and reminders within the archetype:
```markdown
+++
manufacturer = ""
model = ""
price = ""
releaseDate = ""
rating = ""
+++
## Introduction
<!--
What is the selling point of the camera?
What has changed since last year's model?
Include a bullet-point list of key features.
-->
## Sample Photos
<!-- TODO: Take at least 12 photos in a variety of situations. -->
## Conclusion
<!--
Is this camera worth the money?
Does it accomplish what it set out to achieve?
Are there any specific groups of people who should/shouldn't buy it?
Would you recommend it to a friend?
Are there alternatives on the horizon?
-->
```
That way, each time we generate a new content file, we have a series of handy notes to push us closer to a piece of writing that's suitable for publishing.
(If you're wondering why the notes are wrapped in the HTML comment syntax, it's to ensure they won't appear inside the preview window of whatever Markdown editor the author happens to be using. They're not strictly necessary though.)
This is still a fairly simple example, but if your content usually contains a variety of components — headings, bullet-points, images, [short-codes](/extras/shortcodes/), etc — it's not hard to see the time-saving benefits of placing these components in the body of an archetype file.
## Theme Archetypes
Whenever you generate a content file with the `hugo new` command, Hugo will start by searching for archetypes in the `archetypes` directory, initially looking for an archetype that matches the content's section and falling-back on the `default.md` archetype (if one is present). If no archetypes are found in this directory, Hugo will continue its search in the `archetypes` directory of the currently active theme. In other words, it's possible for themes to come packaged with their own archetypes, ensuring that users of that theme format their content files with correctly structured front matter.
To allow Hugo to use archetypes from a theme, [that theme must be activated via the project's configuration file](/themes/usage/):
```toml
theme = "ThemeNameGoesHere"
```
If an archetype doesn't exist in the `archetypes` directory at the top-level of a project or inside the `archetypes` directory of an active theme, the built-in archetype will be used.
{{< figure src="/img/content/archetypes/archetype-hierarchy.png" alt="How Hugo Decides Which Archetype To Use" >}}
## Archetype Formats
By default, the `hugo new` command will generate front matter in the TOML format. This means, even if we define the front matter in our archetype files as YAML or JSON, it will be converted to the TOML format before it ends up in our content files.
Fortunately, this functionality can be overwritten.
Inside the project's configuration file, simply define a `metaDataFormat` property:
```toml
metaDataFormat = ""
```
Then set this property to any of the following values:
* toml
* yaml
* json
By defining this option, any front matter will be generated in your preferred format.
It's worth noting, however, that when generating front matter in the TOML format, you might encounter the following error:
```bash
Error: cannot convert type <nil> to TomlTree
```
This is because, to generate TOML, all of the fields in the front matter need to have a default value, even if that default value is just an empty string.
For example, this YAML would *not* successfully compile into the TOML format:
```yaml
---
slug:
tags:
categories:
draft:
---
```
But this YAML *would* successfully compile:
```yaml
---
slug: ""
tags:
-
categories:
-
draft: true
---
```
It's a subtle yet important detail to remember.
## Notes
* Prior to Hugo v0.13, some users received [an "EOF" error when using archetypes](https://github.com/spf13/hugo/issues/776), related to what text editor they used to create the archetype. As of Hugo v0.13, this error has been [resolved](https://github.com/spf13/hugo/pull/785).
-91
View File
@@ -1,91 +0,0 @@
---
aliases:
- /doc/example/
lastmod: 2015-12-23
date: 2013-07-01
linktitle: Example
menu:
main:
parent: content
prev: /content/multilingual
next: /content/using-index-md
notoc: true
title: Example Content File
weight: 70
---
Some things are better shown than explained. The following is a very basic example of a content file written in [Markdown](https://help.github.com/articles/github-flavored-markdown/):
**mysite/content/project/nitro.md → http://mysite.com/project/nitro.html**
With TOML front matter:
<pre><code class="language-toml">+++
date = "2013-06-21T11:27:27-04:00"
title = "Nitro: A quick and simple profiler for Go"
description = "Nitro is a simple profiler for your Golang applications"
tags = [ "Development", "Go", "profiling" ]
topics = [ "Development", "Go" ]
slug = "nitro"
project_url = "https://github.com/spf13/nitro"
+++
</code><code class="language-markdown"># Nitro
Quick and easy performance analyzer library for [Go](http://golang.org/).
## Overview
Nitro is a quick and easy performance analyzer library for Go.
It is useful for comparing A/B against different drafts of functions
or different functions.
## Implementing Nitro
Using Nitro is simple. First, use `go get` to install the latest version
of the library.
$ go get github.com/spf13/nitro
Next, include nitro in your application.
</code></pre>
You may also use the equivalent YAML front matter:
```yaml
---
lastmod: 2015-12-23
date: "2013-06-21T11:27:27-04:00"
title: "Nitro: A quick and simple profiler for Go"
description: "Nitro is a simple profiler for your Go lang applications"
tags: [ "Development", "Go", "profiling" ]
topics: [ "Development", "Go" ]
slug: "nitro"
project_url: "https://github.com/spf13/nitro"
---
```
`nitro.md` would be rendered as follows:
> # Nitro
>
> Quick and easy performance analyzer library for [Go](http://golang.org/).
>
> ## Overview
>
> Nitro is a quick and easy performance analyzer library for Go.
> It is useful for comparing A/B against different drafts of functions
> or different functions.
>
> ## Implementing Nitro
>
> Using Nitro is simple. First, use `go get` to install the latest version
> of the library.
>
> $ go get github.com/spf13/nitro
>
> Next, include nitro in your application.
The source `nitro.md` file is converted to HTML by the excellent
[Blackfriday](https://github.com/russross/blackfriday) Markdown processor,
which supports extended features found in the popular
[GitHub Flavored Markdown](https://help.github.com/articles/github-flavored-markdown/).
-119
View File
@@ -1,119 +0,0 @@
---
aliases:
- /doc/front-matter/
lastmod: 2015-12-23
date: 2013-07-01
menu:
main:
parent: content
next: /content/sections
prev: /content/organization
title: Front Matter
weight: 20
toc: true
---
The **front matter** is one of the features that gives Hugo its strength. It enables
you to include the meta data of the content right with it. Hugo supports a few
different formats, each with their own identifying tokens.
Supported formats:
* **[TOML][]**, identified by '`+++`'.
* **[YAML][]**, identified by '`---`'.
* **[JSON][]**, a single JSON object which is surrounded by '`{`' and '`}`', followed by a newline.
[TOML]: https://github.com/toml-lang/toml "Tom's Obvious, Minimal Language"
[YAML]: http://www.yaml.org/ "YAML Ain't Markup Language"
[JSON]: http://www.json.org/ "JavaScript Object Notation"
## TOML Example
<pre><code class="language-toml">+++
title = "spf13-vim 3.0 release and new website"
description = "spf13-vim is a cross platform distribution of vim plugins and resources for Vim."
tags = [ ".vimrc", "plugins", "spf13-vim", "vim" ]
date = "2012-04-06"
categories = [
"Development",
"VIM"
]
slug = "spf13-vim-3-0-release-and-new-website"
+++
</code><code class="language-markdown">Content of the file goes Here
</code></pre>
## YAML Example
```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."
tags: [ ".vimrc", "plugins", "spf13-vim", "vim" ]
lastmod: 2015-12-23
date: "2012-04-06"
categories:
- "Development"
- "VIM"
slug: "spf13-vim-3-0-release-and-new-website"
---
Content of the file goes Here
```
## JSON Example
```json
{
"title": "spf13-vim 3.0 release and new website",
"description": "spf13-vim is a cross platform distribution of vim plugins and resources for Vim.",
"tags": [ ".vimrc", "plugins", "spf13-vim", "vim" ],
"date": "2012-04-06",
"categories": [
"Development",
"VIM"
],
"slug": "spf13-vim-3-0-release-and-new-website"
}
Content of the file goes Here
```
## Variables
There are a few predefined variables that Hugo is aware of and utilizes. The user can also create
any variable they want. These will be placed into the `.Params` variable available to the templates.
Field names are always normalized to lowercase (e.g. `camelCase: true` is available as `.Params.camelcase`).
### Required variables
* **title** The title for the content
* **description** The description for the content
* **date** The date the content will be sorted by
* **taxonomies** These will use the field name of the plural form of the index (see tags and categories above)
### Optional variables
* **aliases** An array of one or more aliases
(e.g. old published path of a renamed content)
that would be created to redirect to this content.
See [Aliases]({{< relref "extras/aliases.md" >}}) for details.
* **draft** If true, the content will not be rendered unless `hugo` is called with `--buildDrafts`
* **publishdate** If in the future, content will not be rendered unless `hugo` is called with `--buildFuture`
* **expirydate** Content already expired will not be rendered unless `hugo` is called with `--buildExpired`
* **type** The type of the content (will be derived from the directory automatically if unset)
* **isCJKLanguage** If true, explicitly treat the content as CJKLanguage (`.Summary` and `.WordCount` can work properly in CJKLanguage)
* **weight** Used for sorting
* **markup** *(Experimental)* Specify `"rst"` for reStructuredText (requires
`rst2html`) or `"md"` (default) for Markdown
* **slug** appears as tail of the url. It can be used to change the part of the url that is based on the filename.
* **url** The full path to the content from the web root. It makes no assumptions about the path of the content file. It also ignores any language prefixes of the multilingual feature.
*If neither `slug` or `url` is present, the filename will be used.*
## Configure Blackfriday rendering
It's possible to set some options for Markdown rendering in the page's front matter as an override to the site wide configuration.
See [Configuration]({{< ref "overview/configuration.md#configure-blackfriday-rendering" >}}) for more.
-49
View File
@@ -1,49 +0,0 @@
---
aliases:
- /doc/supported-formats/
lastmod: 2016-07-22
date: 2016-07-22
menu:
main:
parent: content
prev: /content/summaries
next: /content/multilingual
title: Markdown Extras
weight: 66
toc: false
---
Hugo provides some convenient markdown extensions.
## Task lists
Hugo supports GitHub styled task lists (TODO lists) for the Blackfriday renderer (md-files). See [Blackfriday config](/overview/configuration/#configure-blackfriday-rendering) for how to turn it off.
Example:
```markdown
- [ ] a task list item
- [ ] list syntax required
- [ ] incomplete
- [x] completed
```
Renders as:
- [ ] a task list item
- [ ] list syntax required
- [ ] incomplete
- [x] completed
And produces this HTML:
```html
<ul class="task-list">
<li><input type="checkbox" disabled="" class="task-list-item"> a task list item</li>
<li><input type="checkbox" disabled="" class="task-list-item"> list syntax required</li>
<li><input type="checkbox" disabled="" class="task-list-item"> incomplete</li>
<li><input type="checkbox" checked="" disabled="" class="task-list-item"> completed</li>
</ul>
```
-232
View File
@@ -1,232 +0,0 @@
---
date: 2016-01-02T21:21:00Z
menu:
main:
parent: content
prev: /content/markdown-extras
next: /content/example
title: Multilingual Mode
weight: 68
toc: true
---
Hugo supports multiple languages side-by-side (added in `Hugo 0.17`). Define the available languages in a `Languages` section in your top-level `config.toml` (or equivalent).
Example:
```
DefaultContentLanguage = "en"
copyright = "Everything is mine"
[params.navigation]
help = "Help"
[Languages]
[Languages.en]
title = "My blog"
weight = 1
[Languages.en.params]
linkedin = "english-link"
[Languages.fr]
copyright = "Tout est à moi"
title = "Mon blog"
weight = 2
[Languages.fr.params]
linkedin = "lien-francais"
[Languages.fr.navigation]
help = "Aide"
```
Anything not defined in a `[Languages]` block will fall back to the global
value for that key (like `copyright` for the English (`en`) language in this example).
With the config above, all content, sitemap, RSS feeds, paginations
and taxonomy pages will be rendered below `/` in English (your default content language), and below `/fr` in French.
When working with params in frontmatter pages, omit the `params` in the key for the translation.
If you want all of the languages to be put below their respective language code, enable `defaultContentLanguageInSubdir: true` in your configuration.
Only the obvious non-global options can be overridden per language. Examples of global options are `BaseURL`, `BuildDrafts`, etc.
Taxonomies and Blackfriday configuration can also be set per language, example:
```
[Taxonomies]
tag = "tags"
[blackfriday]
angledQuotes = true
hrefTargetBlank = true
[Languages]
[Languages.en]
weight = 1
title = "English"
[Languages.en.blackfriday]
angledQuotes = false
[Languages.fr]
weight = 2
title = "Français"
[Languages.fr.Taxonomies]
plaque = "plaques"
```
### Translating your content
Translated articles are identified by the name of the content file.
Example of translated articles:
1. `/content/about.en.md`
2. `/content/about.fr.md`
You can also have:
1. `/content/about.md`
2. `/content/about.fr.md`
In which case the config variable `defaultContentLanguage` will be used to affect the default language `about.md`. This way, you can
slowly start to translate your current content without having to rename everything.
If left unspecified, the value for `defaultContentLanguage` defaults to `en`.
By having the same _base file name_, the content pieces are linked together as translated pieces.
If you need distinct URLs per language you can set the slug in the non-default language file. Just define the custom slug for the french translation in your `/content/about.fr.md` file:
```
---
slug: "a-propos"
---
```
You will get both `/about/` and `/a-propos/` URLs in your build, properly linked as translated pieces.
### Link to translated content
To create a list of links to translated content, use a template similar to this:
```
{{ if .IsTranslated }}
<h4>{{ i18n "translations" }}</h4>
<ul>
{{ range .Translations }}
<li>
<a href="{{ .Permalink }}">{{ .Lang }}: {{ .Title }}{{ if .IsPage }} ({{ i18n "wordCount" . }}){{ end }}</a>
</li>
{{ end}}
</ul>
{{ end }}
```
The above can be put in a `partial` and included in any template, be it for a content page or the home page. It will not print anything if there are no translations for a given page, or if it is -- in the case of the home page, section listing etc. -- a site with only one language.
The above also uses the `i18n` func, see [Translation of strings](#translation-of-strings).
### Translation of strings
Hugo uses [go-i18n](https://github.com/nicksnyder/go-i18n) to support string translations. Follow the link to find tools to manage your translation workflows.
Translations are collected from the `themes/[name]/i18n/` folder (built into the theme), as well as translations present in `i18n/` at the root of your project. In the `i18n`, the translations will be merged and take precedence over what is in the theme folder. Language files should be named according to RFC 5646 with names such as `en-US.toml`, `fr.toml`, etc.
From within your templates, use the `i18n` function like this:
```
{{ i18n "home" }}
```
This uses a definition like this one in `i18n/en-US.toml`:
```
[home]
other = "Home"
```
Often you will want to use to the page variables in the translations strings. To do that, pass on the "." context when calling `i18n`:
```
{{ i18n "wordCount" . }}
```
This uses a definition like this one in `i18n/en-US.toml`:
```
[wordCount]
other = "This article has {{ .WordCount }} words."
```
An example of singular and plural form:
```
[readingTime]
one = "One minute read"
other = "{{.Count}} minutes read"
```
And then in the template:
```
{{ i18n "readingTime" .ReadingTime }}
```
To track down missing translation strings, run Hugo with the `--i18n-warnings` flag:
```bash
hugo --i18n-warnings | grep i18n
i18n|MISSING_TRANSLATION|en|wordCount
```
### Menus
You can define your menus for each language independently. The [creation of a menu]({{< relref "extras/menus.md" >}}) works analogous to earlier versions of Hugo, except that they have to be defined in their language-specific block in the configuration file:
```toml
defaultContentLanguage = "en"
[languages.en]
weight = 0
languageName = "English"
[[languages.en.menu.main]]
url = "/"
name = "Home"
weight = 0
[languages.de]
weight = 10
languageName = "Deutsch"
[[languages.de.menu.main]]
url = "/"
name = "Startseite"
weight = 0
```
The rendering of the main navigation works as usual. `.Site.Menus` will just contain the menu of the current language. Pay attention to the generation of the menu links. `absLangURL` takes care that you link to the correct locale of your website. Otherwise, both menu entries would link to the English version because it's the default content language that resides in the root directory.
```html
<ul>
{{- $currentPage := . -}}
{{ range .Site.Menus.main -}}
<li class="{{ if $currentPage.IsMenuCurrent "main" . }}active{{ end }}">
<a href="{{ .URL | absLangURL }}">{{ .Name }}</a>
</li>
{{- end }}
</ul>
```
### Missing translations
If a string does not have a translation for the current language, Hugo will use the value from the default language. If no default value is set, an empty string will be shown.
While translating a Hugo site, it can be handy to have a visual indicator of missing translations. The `EnableMissingTranslationPlaceholders` config option will flag all untranslated strings with the placeholder `[i18n] identifier`, where `identifier` is the id of the missing translation.
**Remember: Hugo will generate your website with these placeholders. It might not be suited for production environments.**
### Multilingual Themes support
To support Multilingual mode in your themes, some considerations must be taken for the URLs in the templates. If there are more than one language, URLs must either come from the built-in `.Permalink` or `.URL`, be constructed with `relLangURL` or `absLangURL` template funcs -- or prefixed with `{{.LanguagePrefix }}`.
If there are more than one language defined, the`LanguagePrefix` variable will equal `"/en"` (or whatever your `CurrentLanguage` is). If not enabled, it will be an empty string, so it is harmless for single-language sites.
-41
View File
@@ -1,41 +0,0 @@
---
lastmod: 2015-12-23
date: 2014-03-06
linktitle: Ordering
menu:
main:
parent: content
next: /content/summaries
prev: /content/archetypes
title: Ordering Content
weight: 60
---
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. The order the content would appear is specified in
the [list template](/templates/list/).
_Both the `date` and `weight` fields are optional._
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 is provided,
content will be ordered based on how it's read off the disk, and no order is
guaranteed.
## Assigning weight to content
```toml
+++
weight = 4
title = "Three"
date = "2012-04-06"
+++
Front Matter with Ordered Pages 3
```
## Ordering Content Within Taxonomies
Please see the [Taxonomy Ordering Documentation](/taxonomies/ordering/).
-175
View File
@@ -1,175 +0,0 @@
---
aliases:
- /doc/organization/
lastmod: 2015-09-27
date: 2013-07-01
linktitle: Organization
menu:
main:
parent: content
next: /content/supported-formats
prev: /overview/source-directory
title: Content Organization
weight: 10
toc: true
---
Hugo uses files (see [supported formats](/content/supported-formats/)) 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/).
.
└── content
└── about
| └── _index.md // <- http://1.com/about/
├── post
| ├── firstpost.md // <- http://1.com/post/firstpost/
| ├── happy
| | └── ness.md // <- http://1.com/post/happy/ness/
| └── secondpost.md // <- http://1.com/post/secondpost/
└── quote
├── first.md // <- http://1.com/quote/first/
└── second.md // <- http://1.com/quote/second/
**Here's the same organization run with `hugo --uglyURLs`**
.
└── content
└── about
| └── _index.md // <- http://1.com/about/
├── post
| ├── firstpost.md // <- http://1.com/post/firstpost.html
| ├── happy
| | └── ness.md // <- http://1.com/post/happy/ness.html
| └── secondpost.md // <- http://1.com/post/secondpost.html
└── quote
├── first.md // <- http://1.com/quote/first.html
└── second.md // <- http://1.com/quote/second.html
## Destinations
Hugo believes that you organize your content with a purpose. The same structure
that works to organize your source content is used to organize the rendered
site. As displayed above, the organization of the source content will be
mirrored in the destination.
Notice that the first level `about/` page URL was created using a directory
named "about" with a single `_index.md` file inside. Find out more about `_index.md` specifically in [content for the homepage and other list pages](https://gohugo.io/overview/source-directory#content-for-home-page-and-other-list-pages).
There are times when one would need more control over their content. In these
cases, there are a variety of things that can be specified in the front matter
to determine the destination of a specific piece of content.
The following items are defined in order; latter items in the list will override
earlier settings.
### filename
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.
### slug
Defined in the front matter, the `slug` can take the place of the filename for the
destination.
### filepath
The actual path to the file on disk. Destination will create the destination
with the same path. Includes [section](/content/sections/).
### section
`section` is determined by its location on disk and *cannot* be specified in the front matter. See [section](/content/sections/).
### type
`type` is also determined by its location on disk but, unlike `section`, it *can* be specified in the front matter. See [type](/content/types/).
### path
`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. Includes [section](/content/sections/).
### url
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 "/").
When a `url` is provided, it will be used exactly. Using `url` will ignore the
`--uglyURLs` setting.
## Path breakdown in Hugo
### Content
. path slug
. ⊢-------^----⊣ ⊢------^-------⊣
content/extras/indexes/category-example/index.html
. section slug
. ⊢--^--⊣ ⊢------^-------⊣
content/extras/indexes/category-example/index.html
. section slug
. ⊢--^--⊣⊢--^--⊣
content/extras/indexes/index.html
### Destination
permalink
⊢--------------^-------------⊣
http://spf13.com/projects/hugo
baseURL section slug
⊢-----^--------⊣ ⊢--^---⊣ ⊢-^⊣
http://spf13.com/projects/hugo
baseURL section slug
⊢-----^--------⊣ ⊢--^--⊣ ⊢--^--⊣
http://spf13.com/extras/indexes/example
baseURL path slug
⊢-----^--------⊣ ⊢------^-----⊣ ⊢--^--⊣
http://spf13.com/extras/indexes/example
baseURL url
⊢-----^--------⊣ ⊢-----^-----⊣
http://spf13.com/projects/hugo
baseURL url
⊢-----^--------⊣ ⊢--------^-----------⊣
http://spf13.com/extras/indexes/example
**section** = which type the content is by default
* 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 excluding slug
* based on path to content location
**url** = relative URL
* defined in front matter
* overrides all the above
-54
View File
@@ -1,54 +0,0 @@
---
lastmod: 2015-12-23
date: 2013-07-01
menu:
main:
parent: content
next: /content/types
notoc: true
prev: /content/front-matter
title: Sections
weight: 30
---
Hugo believes that you organize your content with a purpose. The same structure
that works to organize your source content is used to organize the rendered
site (see [Organization](/content/organization/)). Following this pattern Hugo
uses the top level of your content organization as **the Section**.
The following example site uses two sections, "post" and "quote".
{{< nohighlight >}}.
└── content
├── post
| ├── firstpost.md // <- http://1.com/post/firstpost/
| ├── happy
| | └── ness.md // <- http://1.com/post/happy/ness/
| └── secondpost.md // <- http://1.com/post/secondpost/
└── quote
├── first.md // <- http://1.com/quote/first/
└── second.md // <- http://1.com/quote/second/
{{< /nohighlight >}}
## 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.
Section pages can also have a content file and frontmatter, see [Source Organization]({{< relref "overview/source-directory.md#content-for-home-page-and-other-list-pages" >}}).
## Sections and Types
By default everything created within a section will use the content type
that matches the section name.
Section defined in the front matter have the same impact.
To change the type of a given piece of content, simply define the type
in the front matter.
If a layout for a given type hasn't been provided, a default type template will
be used instead provided it exists.
-54
View File
@@ -1,54 +0,0 @@
---
lastmod: 2015-01-27
date: 2013-07-01
menu:
main:
parent: content
notoc: true
prev: /content/ordering
next: /content/markdown-extras
title: Summaries
weight: 65
---
With the use of the `.Summary` [page variable](/templates/variables/), Hugo can generate summaries of content to show snippets in summary views. The summary view snippets are automatically generated by Hugo. Where a piece of content is split for the content summary depends on whether the split is Hugo-defined or user-defined.
Content summaries may also provide links to the original content, usually in the form of a "Read More..." link, with the help of the `.RelPermalink` or `.Permalink` variable, as well as the `.Truncated` boolean variable to determine whether such "Read More..." link is necessary.
## Hugo-defined: automatic summary split
By default, Hugo automatically takes the first 70 words of your content as its summary and stores it into the `.Summary` variable, which you may use in your templates.
* Pros: Automatic, no additional work on your part.
* Cons: All HTML tags are stripped from the summary, and the first 70 words, whether they belong to a heading or to different paragraphs, are all lumped into one paragraph. Some people like it, but some people don't.
## User-defined: manual summary split:
Alternatively, you may add the <code>&#60;&#33;&#45;&#45;more&#45;&#45;&#62;</code> summary divider[^1] (for org content, use <code># more</code>) where you want to split the article. Content prior to the summary divider will be used as that content's summary, and stored into the `.Summary` variable with all HTML formatting intact.
[^1]: The **summary divider** is also called "more tag", "excerpt separator", etc. in other literature.
* Pros: Freedom, precision, and improved rendering. All formatting is preserved.
* Cons: Need to remember to type <code>&#60;&#33;&#45;&#45;more&#45;&#45;&#62;</code> (or <code># more</code> for org content) in your content file. :-)
Be careful to enter <code>&#60;&#33;&#45;&#45;more&#45;&#45;&#62;</code> (or <code># more</code> for org content) exactly, i.e. all lowercase with no whitespace, otherwise it would be treated as regular comment and ignored.
If there is nothing but spaces and newlines after the summary divider then `.Truncated` will be false.
## Showing Summaries
You can show content summaries with the following code. You could do this, for example, on a [list](/templates/list/) page.
{{ range first 10 .Data.Pages }}
<div class="summary">
<h4><a href="{{ .RelPermalink }}">{{ .Title }}</a></h4>
{{ .Summary }}
</div>
{{ if .Truncated }}
<div class="read-more-link">
<a href="{{ .RelPermalink }}">Read More…</a>
</div>
{{ end }}
{{ end }}
Note how the `.Truncated` boolean valuable may be used to hide the "Read More..." link when the content is not truncated, i.e. when the summary contains the entire article.
-27
View File
@@ -1,27 +0,0 @@
---
aliases:
- /doc/supported-formats/
lastmod: 2015-08-01
date: 2015-08-01
menu:
main:
parent: content
next: /content/front-matter
prev: /content/organization
title: Supported Formats
weight: 15
toc: true
---
Since 0.14, Hugo has defined a new concept called _external helpers_. It means that you can write your content using Asciidoc[tor], reStructuredText or Org-Mode. If you have files with associated extensions ([details](https://github.com/spf13/hugo/blob/77c60a3440806067109347d04eb5368b65ea0fe8/helpers/general.go#L65)), then Hugo will call external commands to generate the content (the exception being Org-Mode content, which is parsed natively).
This means that you will have to install the associated tool on your machine to be able to use those formats.
For example, for Asciidoc files, Hugo will try to call __asciidoctor__ or __asciidoc__ command.
To use those formats, just use the standard extension and the front matter exactly as you would do with natively supported _.md_ files.
Notes:
* as these are external commands, generation performance for that content will heavily depend on the performance of those external tools.
* this feature is still in early stage, hence feedback is even more welcome.
-80
View File
@@ -1,80 +0,0 @@
---
lastmod: 2015-09-28
date: 2013-07-01
linktitle: Types
menu:
main:
parent: content
next: /content/archetypes
prev: /content/sections
title: Content Types
weight: 40
toc: true
---
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 `hugo new`
command through using content [archetypes](/content/archetypes/).
A good example of when multiple types are needed is to look at [Tumblr](https://www.tumblr.com/). 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 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.
*Remember, all of the following are optional:*
### Create Type Directory
Create a directory with the name of the type in `/layouts`. Type is always singular. *E.g. `/layouts/post`*.
### Create single template
Create a file called `single.html` inside your directory. *E.g. `/layouts/post/single.html`*.
### Create list template
Create a file called `post.html` inside the section lists template directory, `/layouts/section`. *E.g. `/layouts/section/post.html`*.
### 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](/templates/list).
Hugo makes no assumptions here about how you want 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 `/layouts/TYPE` directory
with the same name.
### Create a corresponding archetype
Create a file called <code><em>type</em>.md</code> in the `/archetypes` directory. *E.g. `/archetypes/post.md`*.
More details about archetypes can be found at the [archetypes docs](/content/archetypes/).
-118
View File
@@ -1,118 +0,0 @@
---
aliases:
- /doc/using-index-md/
lastmod: 2017-02-22
date: 2017-02-22
linktitle: Using _index.md
menu:
main:
parent: content
prev: /content/example
next: /themes/overview
notoc: true
title: Using _index.md
weight: 70
---
# \_index.md and 'Everything is a Page'
As of version v0.18 Hugo now treats '[everything as a page](http://bepsays.com/en/2016/12/19/hugo-018/)'. This allows you to add content and frontmatter to any page - including List pages like [Sections](/content/sections/), [Taxonomies](/taxonomies/overview/), [Taxonomy Terms pages](/templates/terms/) and even to potential 'special case' pages like the [Home page](/templates/homepage/).
In order to take advantage of this behaviour you need to do a few things.
1. Create an \_index.md file that contains the frontmatter and content you would like to apply.
2. Place the \_index.md file in the correct place in the directory structure.
3. Ensure that the respective template is configured to display `{{ .Content }}` if you wish for the content of the \_index.md file to be rendered on the respective page.
## How \_index.md pages work
Before continuing it's important to know that this page must reference certain templates to describe how the \_index.md page will be rendered. Hugo has a multitude of possible templates that can be used and placed in various places (think theme templates for instance). For simplicity/brevity the default/top level template location will be used to refer to the entire range of places the template can be placed.
If this is confusing or you are unfamiliar with Hugo's template hierarchy, visit the various template pages listed below. You may need to find the 'active' template responsible for any particular page on your own site by going through the template hierarchy and matching it to your particular setup/theme you are using.
- [Home page template](/templates/homepage/)
- [Content List templates](/templates/list/)
- [Single Content templates](/templates/content/)
- [Taxonomy Terms templates](/templates/terms/)
Now that you've got a handle on templates lets recap some Hugo basics to understand how to use an \_index.md file with a List page.
1. Sections and Taxonomies are 'List' pages, NOT single pages.
2. List pages are rendered using the template hierarchy found in the [Content - List Template](/templates/list/) docs.
3. The Home page, though technically a List page, can have [its own template](/templates/homepage/) at layouts/index.html rather than \_default/list.html. Many themes exploit this behaviour so you are likely to encounter this specific use case.
4. Taxonomy terms pages are 'lists of metadata' not lists of content, so [have their own templates](/templates/terms/).
Let's put all this information together:
> **\_index.md files used in List pages, Terms pages or the Home page are NOT rendered as single pages or with Single Content templates.**
> **All pages, including List pages, can have frontmatter and frontmatter can have markdown content - meaning \_index.md files are the way to _provide_ frontmatter and content to the respective List/Terms/Home page.**
Here are a couple of examples to make it clearer...
| \_index.md location | Page affected | Rendered by |
| ------------------- | ------------ | ----------- |
| /content/post/\_index.md | site.com/post/ | /layouts/section/post.html |
| /content/categories/hugo/\_index.md | site.com/categories/hugo/ | /layouts/taxonomy/hugo.html |
## Why \_index.md files are used
With a Single page such as a post it's possible to add the frontmatter and content directly into the .md page itself. With List/Terms/Home pages this is not possible so \_index.md files can be used to provide that frontmatter/content to them.
## How to display content from \_index.md files
From the information above it should follow that content within an \_index.md file won't be rendered in its own Single Page, instead it'll be made available to the respective List/Terms/Home page.
To **_actually render that content_** you need to ensure that the relevant template responsible for rendering the List/Terms/Home page contains (at least) `{{ .Content }}`.
This is the way to actually display the content within the \_index.md file on the List/Terms/Home page.
A very simple/naive example of this would be:
```html
{{ partial "header.html" . }}
<main>
{{ .Content }}
{{ range .Paginator.Pages }}
{{ partial "summary.html" . }}
{{ end }}
{{ partial "pagination.html" . }}
</main>
{{ partial "sidebar.html" . }}
{{ partial "footer.html" . }}
```
You can see `{{ .Content }}` just after the `<main>` element. For this particular example, the content of the \_index.md file will show before the main list of summaries.
## Where to organise an \_index.md file
To add content and frontmatter to the home page, a section, a taxonomy or a taxonomy terms listing, add a markdown file with the base name \_index on the relevant place on the file system.
```bash
└── content
├── _index.md
├── categories
│   ├── _index.md
│   └── photo
│   └── _index.md
├── post
│   ├── _index.md
│   └── firstpost.md
└── tags
├── _index.md
└── hugo
└── _index.md
```
In the above example \_index.md pages have been added to each section/taxonomy.
An \_index.md file has also been added in the top level 'content' directory.
### Where to place \_index.md for the Home page
Hugo themes are designed to use the 'content' directory as the root of the website, so adding an \_index.md file here (like has been done in the example above) is how you would add frontmatter/content to the home page.
-103
View File
@@ -1,103 +0,0 @@
---
aliases:
- /doc/redirects/
- /doc/alias/
- /doc/aliases/
lastmod: 2015-12-23
date: 2013-07-09
menu:
main:
parent: extras
next: /extras/analytics
prev: /taxonomies/methods
title: Aliases
---
For people migrating existing published content to Hugo, there's a good chance you need a mechanism to handle redirecting old URLs.
Luckily, redirects can be handled easily with _aliases_ in Hugo.
## Example
Given a post on your current Hugo site, with a path of:
``content/posts/my-awesome-blog-post.md``
... you create an "aliases" section in the frontmatter of your post, and add previous paths to that.
### TOML frontmatter
```toml
+++
...
aliases = [
"/posts/my-original-url/",
"/2010/01/01/even-earlier-url.html"
]
...
+++
```
### YAML frontmatter
```yaml
---
...
aliases:
- /posts/my-original-url/
- /2010/01/01/even-earlier-url.html
...
---
```
Now when you visit any of the locations specified in aliases, _assuming the same site domain_, you'll be redirected to the page they are specified on.
## Important Behaviors
1. *Hugo makes no assumptions about aliases. They also don't change based
on your UglyURLs setting. You need to provide absolute path to your webroot
and the complete filename or directory.*
2. *Aliases are rendered prior to any content and will be overwritten by
any content with the same location.*
## Multilingual example
On [multilingual sites]({{< relref "content/multilingual.md" >}}), each translation of a post can have unique aliases. To use the same alias across multiple languages, prefix it with the language code.
In `/posts/my-new-post.es.md`:
```yaml
---
aliases:
- /es/posts/my-original-post/
---
```
## How Hugo Aliases Work
When aliases are specified, Hugo creates a physical folder structure to match the alias entry, and, an html file specifying the canonical URL for the page, and a redirect target.
Assuming a baseURL of `mysite.tld`, the contents of the html file will look something like:
```html
<!DOCTYPE html>
<html>
<head>
<title>http://mysite.tld/posts/my-original-url</title>
<link rel="canonical" href="http://mysite.tld/posts/my-original-url"/>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<meta http-equiv="refresh" content="0; url=http://mysite.tld/posts/my-original-url"/>
</head>
</html>
```
The `http-equiv="refresh"` line is what performs the redirect, in 0 seconds in this case.
## Customizing
You may customize this alias page by creating an alias.html template in the
layouts folder of your site. In this case, the data passed to the template is
* Permalink - the link to the page being aliased
* Page - the Page data for the page being aliased
-28
View File
@@ -1,28 +0,0 @@
---
date: 2016-02-06
linktitle: Analytics
menu:
main:
parent: extras
next: /extras/builders
prev: /extras/aliases
title: Analytics in Hugo
---
Hugo ships with prebuilt internal templates for Google Analytics tracking, including both synchronous and asynchronous tracking codes.
## Configuring Google Analytics
Provide your tracking id in your configuration file, e.g. config.yaml.
googleAnalytics = "UA-123-45"
## Example
Include the internal template in your templates like so:
{{ template "_internal/google_analytics.html" . }}
For async include the async template:
{{ template "_internal/google_analytics_async.html" . }}
-56
View File
@@ -1,56 +0,0 @@
---
lastmod: 2015-12-24
date: 2014-05-26
linktitle: Builders
menu:
main:
parent: extras
next: /extras/comments
prev: /extras/analytics
title: Hugo Builders
---
Hugo provides the functionality to quickly get a site, theme or page
started.
## New Site
Want to get a site built quickly?
{{< nohighlight >}}$ hugo new site <i>path/to/site</i>
{{< /nohighlight >}}
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. Now, Hugo watches your content directory by default and rebuilds your entire website if any change occurs.
-99
View File
@@ -1,99 +0,0 @@
---
lastmod: 2015-08-04
date: 2014-05-26
linktitle: Comments
menu:
main:
parent: extras
next: /extras/crossreferences
prev: /extras/builders
title: Comments in Hugo
---
As Hugo is a static site generator, the content produced is static and doesnt interact with the users. The most common interaction people ask for is comment capability.
Hugo ships with support for [Disqus](https://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 doesnt, 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, e.g. 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**
## Conditional Loading of Disqus Comments
Users have noticed that enabling Disqus comments when running the Hugo web server on localhost causes the creation of unwanted discussions on the associated Disqus account. In order to prevent this, a slightly tweaked partial template is required. So, rather than using the built-in `"_internal/disqus.html"` template referenced above, create a template in your `partials` folder that looks like this:
```html
<div id="disqus_thread"></div>
<script type="text/javascript">
(function() {
// Don't ever inject Disqus on localhost--it creates unwanted
// discussions from 'localhost:1313' on your Disqus account...
if (window.location.hostname == "localhost")
return;
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
var disqus_shortname = '{{ .Site.DisqusShortname }}';
dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
<a href="http://disqus.com/" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>
```
Notice that there is a simple `if` statement that detects when you are running on localhost and skips the initialization of the Disqus comment injection.
Now, reference the partial template from your page template:
{{ partial "disqus.html" . }}
# Alternatives
A few alternatives exist to [Disqus](https://disqus.com/):
* [txtpen](https://txtpen.com)
* [Discourse](http://www.discourse.org)
* [IntenseDebate](http://intensedebate.com/)
* [Livefyre](http://www.adobe.com/marketing-cloud/enterprise-content-management/ugc-content-platform.html)
* [Muut](http://muut.com/)
* [多说](http://duoshuo.com/) ([Duoshuo](http://duoshuo.com/), popular in China)
* [isso](http://posativ.org/isso/) (Self-hosted, Python)
* [Kaiju](https://github.com/spf13/kaiju)
## Kaiju
[Kaiju](https://github.com/spf13/kaiju) is an open-source project started by [spf13](http://spf13.com/) (Hugos 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.
## txtpen
[txtpen](https://txtpen.com) adds highlighting an in-line commenting similar to Medium to your Hugo blog.
## Discourse
Additionally, you may recognize [Discourse](http://www.discourse.org) as the system that powers the [Hugo Discussion Forum](http://discuss.gohugo.io).
-153
View File
@@ -1,153 +0,0 @@
---
lastmod: 2015-12-23
date: 2014-11-25
menu:
main:
parent: extras
next: /extras/robots-txt
prev: /extras/comments
title: Cross-References
toc: true
---
Hugo makes it easy to link documents together with the `ref` and `relref` shortcodes. These shortcodes are also used to safely provide links to headings inside of your content, whether across documents or within a document. The only difference between `ref` and `relref` is whether the resulting URL is absolute (`http://1.com/about/`) or relative (`/about/`).
## Using `ref` and `relref`
```django
{{</* ref "document" */>}}
{{</* ref "#anchor" */>}}
{{</* ref "document#anchor" */>}}
{{</* relref "document" */>}}
{{</* relref "#anchor" */>}}
{{</* relref "document#anchor" */>}}
```
The single parameter to `ref` is a string with a content _document name_ (`about.md`), an in-document _anchor_ (`#who`), or both (`about.md#who`).
### Document Names
The _document name_ is the name of a document including the format extension; this may be just the filename, or the relative path from the `content/` directory. With a document `content/blog/post.md`, either format will produce the same result.
{{</* relref "blog/post.md" */>}} ⇒ `/blog/post/`
{{</* relref "post.md" */>}} ⇒ `/blog/post/`
If you have multiple sections with the same filename, you should only use the relative path format, because the behaviour is _undefined_. So, if I also have a document `link/post.md`, the output of `ref` is unknown for `post.md`.
{{</* relref "blog/post.md" */>}} ⇒ `/blog/post/`
{{</* relref "post.md" */>}} ⇒ `/blog/post/` (maybe)
{{</* relref "post.md" */>}} ⇒ `/link/post/` (maybe)
{{</* relref "link/post.md" */>}} ⇒ `/link/post/`
A relative document name must *not* begin with a slash (`/`).
{{</* relref "/blog/post.md" */>}} ⇒ `""`
### Anchors
When an _anchor_ is provided by itself, the current pages unique identifier will be appended; when an _anchor_ is provided with a document name, the found page's unique identifier will be appended.
{{</* relref "#who" */>}} ⇒ `#who:9decaf7`
{{</* relref "blog/post.md#who" */>}} ⇒ `/blog/post/#who:badcafe`
More information about document unique identifiers and headings can be found [below]({{< ref "#hugo-heading-anchors" >}}).
### Examples
* `{{</* ref "blog/post.md" */>}}``http://1.com/blog/post/`
* `{{</* ref "post.md#tldr" */>}}``http://1.com/blog/post/#tldr:caffebad`
* `{{</* relref "post.md" */>}}``/blog/post/`
* `{{</* relref "blog/post.md#tldr" */>}}``/blog/post/#tldr:caffebad`
* `{{</* ref "#tldr" */>}}``#tldr:badcaffe`
* `{{</* relref "#tldr" */>}}``#tldr:badcaffe`
## Hugo Heading Anchors
When using Markdown document types, Hugo generates heading anchors automatically. The generated anchor for this section is `hugo-heading-anchors`. Because the heading anchors are generated automatically, Hugo takes some effort to ensure that heading anchors are unique both inside a document and across the entire site.
Ensuring heading uniqueness across the site is accomplished with a unique identifier for each document based on its path. Unless a document is renamed or moved between sections *in the filesystem*, the unique identifier for the document will not change: `blog/post.md` will always have a unique identifier of `81df004c333b392d34a49fd3a91ba720`.
`ref` and `relref` were added so you can make these reference links without having to know the documents unique identifier. (The links in document tables of contents are automatically up-to-date with this value.)
{{</* relref "extras/crossreferences.md#hugo-heading-anchors" */>}}
/extras/crossreferences/#hugo-heading-anchors:77cd9ea530577debf4ce0f28c8dca242
> What follows is a deeper discussion of *why* and *how* Hugo generates heading anchors. It is not necessary to know this to use `ref` and `relref`, but it may be useful in understanding how some anchors may not match your expectations.
### How to Generate a Heading Anchor
Convert the text of the heading to lowercase.
Hugo: A Fast & Modern Static Web Engine
hugo: a fast & modern static web engine
Replace anything that isn't an ASCII letter (`a-z`) or number (`0-9`) with a dash (`-`).
hugo: a fast & modern static web engine
hugo--a-fast---modern-static-web-engine
Get rid of extra dashes.
hugo--a-fast---modern-static-web-engine
hugo-a-fast-modern-static-web-engine
You have just converting the text of a heading to a suitable anchor. If your document has unique heading text, all of the anchors will be unique, too.
#### Specifying Heading Anchors
You can also tell Hugo to use a particular heading anchor.
# Hugo: A Fast & Modern Static Web Engine {#hugo-main}
Hugo will use `hugo-main` as the heading anchor.
### What About Duplicate Heading Anchors?
The technique outlined above works well enough, but some documents have headings with identical text, like the [shortcodes](/extras/shortcodes/) page—there are three headings with the text "Example". You can specify heading anchors manually:
### Example {#example-1}
### Example {#example-2}
### Example {#example-3}
Its easy to forget to do that all the time, and Hugo is smart enough to do it for you. It just adds `-x` to the end of each heading it has already seen.
* `### Example``example`
* `### Example``example-1`
* `### Example``example-2`
Sometimes it's a little harder, but Hugo can recover from those, too, by adding more suffixes:
* `# Heading``heading`
* `# Heading 1``heading-1`
* `# Heading``heading-1-1`
* `# Heading``heading-1-2`
* `# Heading 1``heading-2`
This can even affect specified heading anchors that come after a generated heading anchor.
* `# My Heading``my-heading`
* `# My Heading {#my-heading}``my-heading-1`
> This particular collision and override is unfortunate, but unavoidable because Hugo processes each heading for collision detection as it sees it during conversion.
This technique works well for documents rendered on individual pages, like blog posts. What about on Hugo list pages?
### Unique Heading Anchors in Lists
Hugo converts each document from Markdown independently. it doesnt know that `blog/post.md` has an "Example" heading that will collide with the "Example" heading in `blog/post2.md`. Even if it did know this, the addition of `blog/post3.md` should not cause the anchors for the headings in the other blog posts to change.
Enter the documents unique identifier. To prevent this sort of collision on
list pages, Hugo always appends the document's to a generated heading anchor.
So, the "Example" heading in `blog/post.md` actually turns into
`#example:81df004…`, and the "Example" heading in `blog/post2.md` actually
turns into `#example:8cf1599…`. All you have to know is the heading anchor that
was generated, not the document identifier; `ref` and `relref` take care of the
rest for you.
<a href='{{</* relref "blog/post.md#example" */>}}'>Post Example</a>
<a href='/blog/post.md#81df004…'>Post Example</a>
[Post Two Example]({{</* relref "blog/post2.md#example" */>}})
<a href='/blog/post2.md#8cf1599…'>Post Two Example</a>
Now you know.
-142
View File
@@ -1,142 +0,0 @@
---
aliases:
- /doc/datadrivencontent/
lastmod: 2016-03-03
date: 2015-02-14
menu:
main:
parent: extras
next: /extras/gitinfo
prev: /extras/datafiles
title: Data-driven Content
toc: true
---
Data-driven content with a static site generator? Yes, it is possible!
In addition to the [data files](/extras/datafiles/) feature, we have also
implemented the feature "Data-driven Content", which lets you load
any [JSON](http://www.json.org/) or
[CSV](http://en.wikipedia.org/wiki/Comma-separated_values) file
from nearly any resource.
"Data-driven Content" currently consists of two functions, `getJSON`
and `getCSV`, which are available in **all template files**.
## Implementation details
### Calling the functions with an URL
In any HTML template or Markdown document, call the functions like this:
{{ $dataJ := getJSON "url" }}
{{ $dataC := getCSV "separator" "url" }}
or, if you use a prefix or postfix for the URL, the functions
accept [variadic arguments](http://en.wikipedia.org/wiki/Variadic_function):
{{ $dataJ := getJSON "url prefix" "arg1" "arg2" "arg n" }}
{{ $dataC := getCSV "separator" "url prefix" "arg1" "arg2" "arg n" }}
The separator for `getCSV` must be put in the first position and can only
be one character long.
All passed arguments will be joined to the final URL; for example:
{{ $urlPre := "https://api.github.com" }}
{{ $gistJ := getJSON $urlPre "/users/GITHUB_USERNAME/gists" }}
will resolve internally to:
{{ $gistJ := getJSON "https://api.github.com/users/GITHUB_USERNAME/gists" }}
Finally, you can range over an array. This example will output the
first 5 gists for a GitHub user:
<ul>
{{ $urlPre := "https://api.github.com" }}
{{ $gistJ := getJSON $urlPre "/users/GITHUB_USERNAME/gists" }}
{{ range first 5 $gistJ }}
{{ if .public }}
<li><a href="{{ .html_url }}" target="_blank">{{ .description }}</a></li>
{{ end }}
{{ end }}
</ul>
### Example for CSV files
For `getCSV`, the one-character long separator must be placed in the
first position followed by the URL.
<table>
<thead>
<tr>
<th>Name</th>
<th>Position</th>
<th>Salary</th>
</tr>
</thead>
<tbody>
{{ $url := "http://a-big-corp.com/finance/employee-salaries.csv" }}
{{ $sep := "," }}
{{ range $i, $r := getCSV $sep $url }}
<tr>
<td>{{ index $r 0 }}</td>
<td>{{ index $r 1 }}</td>
<td>{{ index $r 2 }}</td>
</tr>
{{ end }}
</tbody>
</table>
The expression `{{index $r number}}` must be used to output the nth-column from
the current row.
### Caching of URLs
Each downloaded URL will be cached in the default folder `$TMPDIR/hugo_cache/`.
The variable `$TMPDIR` will be resolved to your system-dependent
temporary directory.
With the command-line flag `--cacheDir`, you can specify any folder on
your system as a caching directory.
You can also set `cacheDir` in the main configuration file.
If you don't like caching at all, you can fully disable caching with the
command line flag `--ignoreCache`.
### Authentication when using REST URLs
Currently, you can only use those authentication methods that can
be put into an URL. [OAuth](http://en.wikipedia.org/wiki/OAuth) or
other authentication methods are not implemented.
### Loading local files
To load local files with the two functions `getJSON` and `getCSV`, the
source files must reside within Hugo's working directory. The file
extension does not matter but the content does.
It applies the same output logic as in the topic: *Calling the functions with an URL*.
## LiveReload
There is no chance to trigger a [LiveReload](/extras/livereload/) when
the content of an URL changes. However, when a local JSON/CSV file changes,
then a LiveReload will be triggered of course. Symlinks are not supported.
**URLs and LiveReload**: If you change any local file and the LiveReload
is triggered, Hugo will either read the URL content from the cache or, if
you have disabled the cache, Hugo will re-download the content.
This can create huge traffic and you may also reach API limits quickly.
As downloading of content takes a while, Hugo stops processing
your Markdown files until the content has been downloaded.
## Examples
- Photo gallery JSON powered: [https://github.com/pcdummy/hugo-lightslider-example](https://github.com/pcdummy/hugo-lightslider-example)
- GitHub Starred Repositories [in a posts](https://github.com/SchumacherFM/blog-cs/blob/master/content%2Fposts%2Fgithub-starred.md) with the related [short code](https://github.com/SchumacherFM/blog-cs/blob/master/layouts%2Fshortcodes%2FghStarred.html).
- More? Please tell us!
-106
View File
@@ -1,106 +0,0 @@
---
aliases:
- /doc/datafiles/
lastmod: 2015-08-04
date: 2015-01-22
menu:
main:
parent: extras
next: /extras/datadrivencontent
prev: /extras/robots-txt
title: Data Files
---
In addition to the [built-in variables](/templates/variables/) available from Hugo, you can specify your own custom data that can be accessed via templates or shortcodes.
Hugo supports loading data from [YAML](http://yaml.org/), [JSON](http://www.json.org/), and [TOML](https://github.com/toml-lang/toml) files located in the `data` directory.
**It even works with [LiveReload](/extras/livereload/).**
Data Files can also be used in [themes](/themes/overview/), but note: If the same `key` is used in both the main data folder and in the theme's data folder, the main one will win. So, for theme authors, for theme specific data items that shouldn't be overridden, it can be wise to prefix the folder structure with a namespace, e.g. `mytheme/data/mytheme/somekey/...`. To check if any such duplicate exists, run hugo with the `-v` flag, e.g. `hugo -v`.
## The Data Folder
The `data` folder is where you can store additional data for Hugo to use when generating your site. Data files aren't used to generate standalone pages - rather they're meant to supplement the content files. This feature can extend the content in case your frontmatter would grow immensely. Or perhaps you want to show a larger dataset in a template (see example below). In both cases it's a good idea to outsource the data in their own file.
These files must be YAML, JSON or TOML files (using either the `.yml`, `.yaml`, `.json` or `toml` extension) and the data will be accessible as a `map` in `.Site.Data`.
**The keys in this map will be a dot chained set of _path_, _filename_ and _key_ in file (if applicable).**
This is best explained with an example:
## Example: Jaco Pastorius' Solo Discography
[Jaco Pastorius](http://en.wikipedia.org/wiki/Jaco_Pastorius_discography) was a great bass player, but his solo discography is short enough to use as an example. [John Patitucci](http://en.wikipedia.org/wiki/John_Patitucci) is another bass giant.
The example below is a bit constructed, but it illustrates the flexibility of Data Files. It uses TOML as file format.
Given the files:
* `data/jazz/bass/jacopastorius.toml`
* `data/jazz/bass/johnpatitucci.toml`
`jacopastorius.toml` contains the content below, `johnpatitucci.toml` contains a similar list:
```
discography = [
"1974 Modern American Music … Period! The Criteria Sessions",
"1974 Jaco",
"1976 - Jaco Pastorius",
"1981 - Word of Mouth",
"1981 - The Birthday Concert (released in 1995)",
"1982 - Twins I & II (released in 1999)",
"1983 - Invitation",
"1986 - Broadway Blues (released in 1998)",
"1986 - Honestly Solo Live (released in 1990)",
"1986 - Live In Italy (released in 1991)",
"1986 - Heavy'n Jazz (released in 1992)",
"1991 - Live In New York City, Volumes 1-7.",
"1999 - Rare Collection (compilation)",
"2003 - Punk Jazz: The Jaco Pastorius Anthology (compilation)",
"2007 - The Essential Jaco Pastorius (compilation)"
]
```
The list of bass players can be accessed via `.Site.Data.jazz.bass`, a single bass player by adding the filename without the suffix, e.g. `.Site.Data.jazz.bass.jacopastorius`.
You can now render the list of recordings for all the bass players in a template:
```
{{ range $.Site.Data.jazz.bass }}
{{ partial "artist.html" . }}
{{ end }}
```
And then in `partial/artist.html`:
```
<ul>
{{ range .discography }}
<li>{{ . }}</li>
{{ end }}
</ul>
```
Discover a new favourite bass player? Just add another TOML-file.
## Example: Accessing named values in a Data File
Assuming you have the following YAML structure to your `User0123.yml` Data File located directly in `data/`
```
Name: User0123
"Short Description": "He is a **jolly good** fellow."
Achievements:
- "Can create a Key, Value list from Data File"
- "Learns Hugo"
- "Reads documentation"
```
To render the `Short Description` in your `layout` File following code is required.
```
<div>Short Description of {{.Site.Data.User0123.Name}}: <p>{{ index .Site.Data.User0123 "Short Description" | markdownify }}</p></div>
```
Note the use of the `markdownify` template function. This will send the description through the Blackfriday Markdown rendering engine.
-50
View File
@@ -1,50 +0,0 @@
---
aliases:
- /doc/gitinfo/
lastmod: 2016-12-11
date: 2016-12-11
menu:
main:
parent: extras
next: /extras/livereload
prev: /extras/datadrivencontent
title: GitInfo
---
Hugo provides a way to integrate Git data into your site.
## Prerequisites
1. The Hugo site must be in a Git-enabled directory.
1. The Git executable must be installed and in your system `PATH`.
1. Enable the GitInfo feature in Hugo by using `--enableGitInfo` on the command
line or by setting `enableGitInfo` to `true` in your site configuration.
## The GitInfo Object
The `GitInfo` object contains the following fields:
AbbreviatedHash
: abbreviated commit hash, e.g. `866cbcc`
AuthorName
: author name, respecting `.mailmap`
AuthorEmail
: author email address, respecting `.mailmap`
AuthorDate
: the author date
Hash
: commit hash, e.g. `866cbccdab588b9908887ffd3b4f2667e94090c3`
Subject
: commit message subject, e.g. `tpl: Add custom index function`
## Performance Considerations
The Git integrations should be fairly performant, but it does add some time to the build, which depends somewhat on the Git history size.
-197
View File
@@ -1,197 +0,0 @@
---
aliases:
- /extras/highlight/
lastmod: 2015-10-27
date: 2013-07-01
menu:
main:
parent: extras
next: /extras/toc
prev: /extras/shortcodes
title: Syntax Highlighting
toc: true
---
Hugo provides the ability for you to highlight source code in _two different ways_ &mdash; either pre-processed server side from your content, or to defer the processing to the client side, using a JavaScript library.
**The advantage of server side** is that it doesnt depend on a JavaScript library and consequently works very well when read from an RSS feed.
**The advantage of client side** is that it doesnt cost anything when building your site and some of the highlighting scripts available cover more languages than Pygments does.
## Server-side
For the pre-processed approach, highlighting is performed by an external Python-based program called [Pygments](http://pygments.org/) and is triggered via an embedded Hugo shortcode (see example below). If Pygments is absent from the path, it will silently simply pass the content along unhighlighted.
### Pygments
If you have never worked with Pygments before, here is a brief primer:
+ Install Python from [python.org](https://www.python.org/downloads/). Version 2.7.x is already sufficient.
+ Run `pip install Pygments` in order to install Pygments. Once installed, Pygments gives you a command `pygmentize`. Make sure it sits in your PATH, otherwise Hugo cannot find it.
On Debian and Ubuntu systems, you may also install Pygments by running `sudo apt-get install python3-pygments`.
Hugo gives you two options that you can set with the variable `pygmentsuseclasses` (default `false`) in `config.toml` (or `config.yaml`).
1. Color-codes for highlighting keywords are directly inserted if `pygmentsuseclasses = false` (default). See in the example below. The color-codes depend on your choice of the `pygmentsstyle` (default `"monokai"`). You can explore the different color styles on [pygments.org](http://pygments.org/) after inserting some example code.
2. If you choose `pygmentsuseclasses = true`, Hugo includes class names in your code instead of color-codes. For class-names to be meaningful, you need to include a `.css`-file in your website representing your color-scheme. You can either generate this `.css`-files according to this [description](http://pygments.org/docs/cmdline/) or download the standard ones from the [GitHub pygments-css repository](https://github.com/richleland/pygments-css).
### Usage
Highlighting is carried out via the in-built shortcode `highlight`. `highlight` takes exactly one required parameter of language, and requires a closing shortcode. Note that `highlight` is _not_ used for client-side javascript highlighting.
### Example
```
{{</* highlight html */>}}
<section id="main">
<div>
<h1 id="title">{{ .Title }}</h1>
{{ range .Data.Pages }}
{{ .Render "summary"}}
{{ end }}
</div>
</section>
{{</* /highlight */>}}
```
### Example Output
```
<span style="color: #f92672">&lt;section</span> <span style="color: #a6e22e">id=</span><span style="color: #e6db74">&quot;main&quot;</span><span style="color: #f92672">&gt;</span>
<span style="color: #f92672">&lt;div&gt;</span>
<span style="color: #f92672">&lt;h1</span> <span style="color: #a6e22e">id=</span><span style="color: #e6db74">&quot;title&quot;</span><span style="color: #f92672">&gt;</span>{{ .Title }}<span style="color: #f92672">&lt;/h1&gt;</span>
{{ range .Data.Pages }}
{{ .Render &quot;summary&quot;}}
{{ end }}
<span style="color: #f92672">&lt;/div&gt;</span>
<span style="color: #f92672">&lt;/section&gt;</span>
```
### Options
Options to control highlighting can be added as a quoted, comma separated key-value list as the second argument in the shortcode. The example below will highlight as language `go` with inline line numbers, with line number 2 and 3 highlighted.
```
{{</* highlight go "linenos=inline,hl_lines=2 3" */>}}
var a string
var b string
var c string
var d string
{{</* / highlight */>}}
```
Supported keywords: `style`, `encoding`, `noclasses`, `hl_lines`, `linenos`. Note that `style` and `noclasses` will override the similar setting in the global config.
The keywords are the same you would using with Pygments from the command line, see the [Pygments doc](http://pygments.org/docs/) for more info.
### Code fences
It is also possible to add syntax highlighting with GitHub flavoured code fences. To enable this, set the `PygmentsCodeFences` to `true` in Hugo's configuration file.
````
``` html
<section id="main">
<div>
<h1 id="title">{{ .Title }}</h1>
{{ range .Data.Pages }}
{{ .Render "summary"}}
{{ end }}
</div>
</section>
```
````
### Disclaimers
* Pygments is relatively slow and _causes a performance hit when building your site_, but Hugo has been designed to cache the results to disk.
* The caching can be turned off by setting the `--ignoreCache` flag to `true`.
* Languages available depends on your Pygments installation.
## Client-side
Alternatively, code highlighting can be done in client-side JavaScript.
Client-side syntax highlighting is very simple to add. You'll need to pick
a library and a corresponding theme. Some popular libraries are:
- [Highlight.js]
- [Prism]
- [Rainbow]
- [Syntax Highlighter]
- [Google Prettify]
### Highlight.js example
This example uses the popular [Highlight.js] library, hosted by [Yandex], a popular Russian search engine.
In your `./layouts/partials/` (or `./layouts/chrome/`) folder, depending on your specific theme, there will be a snippet that will be included in every generated HTML page, such as `header.html` or `header.includes.html`. Simply add the css and js to initialize [Highlight.js]:
~~~
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.6.0/styles/default.min.css">
<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.6.0/highlight.min.js"></script>
<script>hljs.initHighlightingOnLoad();</script>
~~~
### Prism example
Prism is another popular highlighter library, used on some major sites. Similar to Highlight.js, you simply load `prism.css` in your `<head>` via whatever Hugo partial template is creating that part of your pages, like so:
```html
...
<link href="/css/prism.css" rel="stylesheet" />
...
```
... and add `prism.js` near the bottom of your `<body>` tag, again in whatever Hugo partial template is appropriate for your site or theme.
```html
...
<script src="/js/prism.js"></script>
...
</body>
```
In this example, the local paths indicate that your own copy of these files are being added to the site, typically under `./static/`.
### Using Client-side highlighting
To use client-side highlighting, most of these javascript libraries expect your code to be wrapped in semantically correct `<code>` tags, with the language expressed in a class attribute on the `<code>` tag, such as `class="language-abc"`, where the `abc` is the code the highlighter script uses to represent that language.
The script would be looking for classes like `language-go`, `language-html`, or `language-css`. If you look at the page's source, it would be marked up like so:
~~~html
<pre>
<code class="language-css">
body {
font-family: "Noto Sans", sans-serif;
}
</code>
</pre>
~~~
The markup in your content pages (e.g. `my-css-tutorial.md`) needs to look like the following, with the name of the language to be highlighted entered directly after the first "fence", in a fenced code block:
<pre><code class="language-css">&#126;&#126;&#126;css
body {
font-family: "Noto Sans", sans-serif;
}
&#126;&#126;&#126;</code></pre>
When passed through the highlighter script, it would yield something like this output when viewed on your rendered page:
~~~css
body {
font-family: "Noto Sans", sans-serif;
}
~~~
Please see individual libraries' documentation for how to implement each of the JavaScript-based libraries.
[Prism]: http://prismjs.com
[Highlight.js]: http://highlightjs.org/
[Rainbow]: http://craig.is/making/rainbows
[Syntax Highlighter]: http://alexgorbatchev.com/SyntaxHighlighter/
[Google Prettify]: https://github.com/google/code-prettify
[Yandex]: http://yandex.ru/
-74
View File
@@ -1,74 +0,0 @@
---
lastmod: 2016-08-09
date: 2014-05-26
menu:
main:
parent: extras
next: /extras/menus
prev: /extras/gitinfo
title: LiveReload
---
Hugo may not be the first static site generator to utilize LiveReload
technology, but its the first to do it right.
The combination of Hugos insane build speed and LiveReload 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:
{{< nohighlight >}}$ hugo server
{{< /nohighlight >}}
This will run a full functioning web server while simultaneously
watching your file system for additions, deletions or changes within
your:
* static files
* content
* data files
* layouts
* current theme
* configuration files
Whenever anything changes, Hugo will rebuild the site while continuing to serve
the content. 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 Watch
If for some reason you don't want the Hugo server's watch functionality,
just do:
{{< nohighlight >}}$ hugo server --watch=false
{{< /nohighlight >}}
## Disabling LiveReload
LiveReload works by injecting JavaScript into the pages Hugo generates,
which creates a connection from the browser 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` in production to
instantly display any updated content, weve made it easy to disable the
LiveReload functionality:
{{< nohighlight >}}$ hugo server --disableLiveReload
{{< /nohighlight >}}
## Notes
You must have a closing `</body>` tag for LiveReload to work.
Hugo injects the LiveReload `<script>` before this tag.
-57
View File
@@ -1,57 +0,0 @@
---
aliases:
- /doc/localfiles/
lastmod: 2016-09-12
date: 2015-06-12
menu:
main:
parent: extras
next: /extras/urls
notoc: true
prev: /extras/toc
title: Traversing Local Files
---
## Traversing Local Files
Using Hugo's function `readDir`,
you can traverse your web site's files on your server.
## Using _readDir_
The `readDir` function returns an array
of [`os.FileInfo`](https://golang.org/pkg/os/#FileInfo).
It takes a single, string argument: a path.
This path can be to any directory of your web site
(as found on your server's filesystem).
Whether the path is absolute or relative makes no difference,
because&mdash;at least for `readDir`&mdash;the root of your web site (typically `./public/`)
in effect becomes both:
1. The filesystem root; and
1. The current working directory.
## New Shortcode
So, let's create a new shortcode using `readDir`:
**layouts/shortcodes/directoryindex.html**
```html
{{< readfile "layouts/shortcodes/directoryindex.html" >}}
```
For the files in any given directory,
this shortcode usefully lists their basenames and sizes,
while providing links to them.
Already&mdash;actually&mdash;this shortcode
has been included in this very web site.
So, let's list some of its CSS files.
(If you click on their names, you can reveal the contents.)
{{< directoryindex path="/static/css" pathURL="/css" >}}
<br />
This is the call that rendered the above output:
```html
{{</* directoryindex path="/static/css" pathURL="/css" */>}}
```
By the way,
regarding the pathURL argument, the initial slash `/` is important.
Otherwise, it becomes relative to the current web page.
-393
View File
@@ -1,393 +0,0 @@
---
lastmod: 2015-08-04
date: 2014-05-14T02:36:37Z
toc: true
menu:
main:
parent: extras
next: /extras/pagination
prev: /extras/livereload
title: Menus
---
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.
*TIP:* If all you want is a simple menu for your sections, see [Section Menu for "the Lazy Blogger"]({{< relref "#section-menu-for-the-lazy-blogger" >}}).
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 menu 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`.
If you make use of the [multilingual feature]({{< relref "content/multilingual.md#menus">}}) you can define menus language independent.
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`
And the following functions:
* `HasChildren() bool`
Additionally, the `Page` object has two functions, which can be used when rendering menus:
* `IsMenuCurrent (menu string, menuEntry *MenuEntry ) bool`
* `HasMenuCurrent** (menu string, menuEntry *MenuEntry) bool`
See [Menu Functions](#menu-functions) for explanations of these functions, and [Rendering Nested Menus](#rendering-nested-menus) for an example of their use.
## 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 arent attached to a piece of
content. This takes place in the sitewide [config file](/overview/configuration/).
Heres an example `config.toml`:
[[menu.main]]
name = "about hugo"
pre = "<i class='fa fa-heart'></i>"
weight = -110
identifier = "about"
url = "/about/"
[[menu.main]]
name = "getting started"
pre = "<i class='fa fa-road'></i>"
weight = -100
url = "/getting-started/"
And the equivalent example `config.yaml`:
---
menu:
main:
- Name: "about hugo"
Pre: "<i class='fa fa-heart'></i>"
Weight: -110
Identifier: "about"
URL: "/about/"
- Name: "getting started"
Pre: "<i class='fa fa-road'></i>"
Weight: -100
URL: "/getting-started/"
---
**NOTE:** The URLs must be relative to the context root. If the `baseURL` is `http://example.com/mysite/`, then the URLs in the menu must not include the context root `mysite`. Using an absolute URL will overide the baseURL. If the `URL` is `http://subdomain.example.com/`, the output will be `http://subdomain.example.com`.
## 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 an 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:
<!--sidebar start-->
<aside>
<div id="sidebar" class="nav-collapse">
<!-- sidebar menu start-->
<ul class="sidebar-menu">
{{ $currentPage := . }}
{{ range .Site.Menus.main }}
{{ if .HasChildren }}
<li class="sub-menu{{if $currentPage.HasMenuCurrent "main" . }} active{{end}}">
<a href="javascript:;" class="">
{{ .Pre }}
<span>{{ .Name }}</span>
<span class="menu-arrow arrow_carrot-right"></span>
</a>
<ul class="sub">
{{ range .Children }}
<li{{if $currentPage.IsMenuCurrent "main" . }} class="active"{{end}}><a href="{{.URL}}"> {{ .Name }} </a> </li>
{{ end }}
</ul>
{{else}}
<li>
<a href="{{.URL}}">
{{ .Pre }}
<span>{{ .Name }}</span>
</a>
{{end}}
</li>
{{end}}
<li> <a href="https://github.com/spf13/hugo/issues" target="blank">Questions and Issues</a> </li>
<li> <a href="#" target="blank">Edit this Page</a> </li>
</ul>
<!-- sidebar menu end-->
</div>
</aside>
<!--sidebar end-->
> **Note**: use the `absLangURL` or `relLangURL` if your theme makes use of the [multilingual feature]({{< relref "content/multilingual.md" >}}). In contrast to `absURL` and `relURL` it adds the correct language prefix to the url. [Read more]({{< relref "templates/functions.md#urls" >}}).
## Section Menu for "the Lazy Blogger"
To enable this menu, add this to your site config, i.e. `config.toml`:
```
SectionPagesMenu = "main"
```
The menu name can be anything, but take a note of what it is.
This will create a menu with all the sections as menu items and all the sections' pages as "shadow-members". The _shadow_ implies that the pages isn't represented by a menu-item themselves, but this enables you to create a top-level menu like this:
```
<nav class="sidebar-nav">
{{ $currentPage := . }}
{{ range .Site.Menus.main }}
<a class="sidebar-nav-item{{if or ($currentPage.IsMenuCurrent "main" .) ($currentPage.HasMenuCurrent "main" .) }} active{{end}}" href="{{.URL}}">{{ .Name }}</a>
{{ end }}
</nav>
```
In the above, the menu item is marked as active if on the current section's list page or on a page in that section.
The above is all that's needed. But if you want custom menu items, e.g. changing weight or name, you can define them manually in the site config, i.e. `config.toml`:
```
[[menu.main]]
name = "This is the blog section"
weight = -110
identifier = "blog"
url = "/blog/"
```
**Note** that the `identifier` must match the section name.
## Menu Functions
Suppose you have the menu structure shown below.
```
[menu.main]
├───colour
│ │
│ ├───warm
│ │ ├───orange
│ │ ├───red
│ │ └───yellow
│ │
│ └───cool
│ ├───blue
│ ├───green
│ └───purple
└───tool
├───hammer
├───shovel
└───saw
```
For each menu item, you can determine:
* If the menu item has any children: `.HasChildren()`
* If the menu item is a parent of the page you are currently rendering: `.Page.HasMenuCurrent()`
* If the menu item **is** the page you are currently rendering: `.Page.IsMenuCurrent()`
For example, if you are currently rendering the page `/colour/warm`, the values of `.HasChildren`, `HasMenuCurrent`, and `IsMenuCurrent` would be as shown below:
```
[menu.main] | | | |
│ | | | |
├───colour | HasMenuCurrent | | HasChildren |
│ ├───<< WARM >> | | IsMenuCurrent | HasChildren |
│ │ ├───orange | | | |
│ │ ├───red | | | |
│ │ └───yellow | | | |
│ └───cool | | | HasChildren |
│ ├───blue | | | |
│ ├───green | | | |
│ └───purple | | | |
└───tool | | | HasChildren |
├───hammer | | | |
├───shovel | | | |
└───saw | | | |
```
## Rendering nested menus
Hugo supports nested menus with as many levels as you like.
Nested menus can be rendered using a recursive partial template, such as the example below.
```
<!-- layouts/index.html, layouts/_default/single.html, ... -->
<h1>{{ .Title }}</h1>
<!-- Put this line in your main template, at the place where you want to
render the menu. -->
{{ partial "menu_include.html" . }}
```
```
<!-- layouts/partials/menu_include.html -->
{{ partial "menu_recursive.html" (dict "menu" .Site.Menus.main "page" . "site" .Site) }}
```
```
<!-- layouts/partials/menu_recursive.html -->
{{ $page := .page }}
{{ $site := .site }}
<ul>
{{ range .menu }}
{{ $is := $page.IsMenuCurrent "main" . }}
{{ $has := $page.HasMenuCurrent "main" . }}
{{ if .HasChildren }}
<li>
<a href="{{ .URL }}">
{{ .Name }}
{{ if $is }}[Is]{{ end }}
{{ if $has }}[Has]{{ end }}
{{ if .HasChildren }}[Children]{{ end }}
</a>
<!-- If the menu item has children, include this partial template again (recursively) -->
{{ partial "menu_recursive.html" (dict "menu" .Children "page" $page "site" $site) }}
</li>
{{ else }}
<li>
<a href="{{ .URL }}">
{{ .Name }}
{{ if $is }}[Is]{{ end }}
{{ if $has }}[Has]{{ end }}
{{ if .HasChildren }}[Children]{{ end }}
</a>
</li>
{{ end }}
{{ end }}
</ul>
```
This example code renders the words `[Is]`, `[Has]`, and `[Children]` to demonstrate how the `IsMenuCurrent()`, `HasMenuCurrent()`, and `HasChildren()` functions work.
You can customise this example to implement features such as:
* Highlight the current item, by applying a CSS style:
<a href="{{ .URL }}"{{ if $is }} class="active"{{ end }}>
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
* Highlight parents of the current item, by applying a CSS style:
<a href="{{ .URL }}"{{ if $has }} class="parent-active"{{ end }}>
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
* Only render sub-menus for parents of the current menu item, and the current menu item itself:
{{ if or $is $has }}
{{ partial "menu_recursive.html" (dict "menu" .Children "page" $page "site" $site) }}
{{ end }}
A working example, implementing these features, is shown below.
```
<!-- layouts/partials/menu_recursive.html -->
{{ $page := .page }}
{{ $site := .site }}
<ul>
<!-- Menu items sorted alphabetically by name -->
{{ range .menu.ByName }}
{{ $is := $page.IsMenuCurrent "main" . }}
{{ $has := $page.HasMenuCurrent "main" . }}
{{ if .HasChildren }}
<li>
<a href="{{ .URL }}" class="{{ if $is }} active{{ end }}{{ if $has }} parent-active{{ end }}">
{{ .Name }}
<!-- Show a » symbol if there is a sub-menu we haven't rendered -->
{{ if not (or $is $has) }}»{{ end }}
</a>
<!-- Only render sub-menu for parent items and the current item -->
{{ if or $is $has }}
{{ partial "menu_recursive.html" (dict "menu" .Children "page" $page "site" $site) }}
{{ end }}
</li>
{{ else }}
<li>
<a href="{{ .URL }}" class="{{ if $is }}active{{end}}">{{ .Name }}</a>
</li>
{{ end }}
{{ end }}
</ul>
```
-184
View File
@@ -1,184 +0,0 @@
---
aliases:
- /doc/output-formats/
- /doc/custom-output/
date: 2017-03-22T08:20:13+01:00
menu:
main:
parent: extras
title: Output Formats
weight: 5
toc: true
---
Hugo `0.20` introduced the powerful feature **Custom Output Formats**; Hugo isn't just that "static HTML with an added RSS feed" anymore. _Say hello_ to calendars, e-book formats, Google AMP, and JSON search indexes, to name a few.
This page describes how to properly configure your site with the media types and output formats you need.
## Media Types
A [media type](https://en.wikipedia.org/wiki/Media_type) (also known as MIME type and content type) is a two-part identifier for file formats and format contents transmitted on the Internet.
This is the full set of built-in media types in Hugo:
{{< datatable "media" "types" "Type" "Suffix" >}}
**Note:**
* It is possible to add custom media types or change the defaults (if you, say, want to change the suffix to `asp` for `text/html`).
* The `Suffix` is the value that will be used for URLs and filenames for that media type in Hugo.
* The `Type` is the identifier that must be used when defining new `Output Formats` (see below).
* The full set of media types will be registered in Hugo's built-in development server to make sure they are recognized by the browser.
To add or modify a media type, define it in a `mediaTypes` section in your site config (either for all sites or for a given language).
Example in `config.toml`:
```toml
[mediaTypes]
[mediaTypes."text/enriched"]
suffix = "enr"
[mediaTypes."text/html"]
suffix = "asp"
```
The above example adds one new media type, `text/enriched`, and changes the suffix for the built-in `text/html` media type.
## Output Formats
Given a media type and some additional configuration, you get an `Output Format`.
This is the full set of built-in output formats in Hugo:
{{< datatable "output" "formats" "Name" "MediaType" "Path" "BaseName" "Rel" "Protocol" "IsPlainText" "IsHTML" "NoUgly" "NotAlternative">}}
**Note:**
* A page can be output in as many output formats as you want, and you can have an infinite amount of output formats defined, as long as _they resolve to a unique path on the file system_. In the table above, the best example of this is `AMP` vs. `HTML`: We have given `AMP` a value for `Path` so it doesn't overwrite the `HTML` version, i.e. we can now have both `/index.html` and `/amp/index.html`.
* The `MediaType` must match the `Type` of an already defined media type (see above).
* You can define new or redefine built-in output formats (if you, as an example, want to put `AMP` pages in a different path).
To add or modify a media type, define it in a `outputFormats` section in your site config (either for all sites or for a given language).
Example in `config.toml`:
```toml
[outputFormats.MyEnrichedFormat]
mediaType = "text/enriched"
baseName = "myindex"
isPlainText = true
protocol = "bep://"
```
The above example is fictional, but if used for the home page on a site with `baseURL` `http://example.org`, it will produce a plain text home page with the URL `bep://example.org/myindex.enr`.
All the available configuration options for output formats and their default values:
Field | Description
--- | ---
**Name** | The output format identifier. This is used to define what output format(s) you want for your pages.
**MediaType**|This must match the `Type` of a defined media type. |
**Path** | Sub path to save the output files.
**BaseName** | The base filename for the list filenames (home page etc.). **Default:** _index_.
**Rel** | Can be used to create `rel` values in `link` tags. **Default:** _alternate_.
**Protocol** | Will replace the "http://" or "https://" in your `baseURL` for this output format.
**IsPlainText** | Use Go's plain text templates parser for the templates. **Default:** _false_.
**IsHTML** | Used in situations only relevant for `HTML` type of formats, page aliases being one example.|
**NoUgly** | If `uglyURLs` is enabled globally, this can be used to turn it off for a given output format. **Default:** _false_.
**NotAlternative** | Enable if it doesn't make sense to include this format in an the `.AlternativeOutputFormats` format listing on `Page`, `CSS` being one good example. Note that we use the term "alternative" and not "alternate" here, as it does not necessarily replace the other format, it is an alternative representation. **Default:** _false_.
## Output Formats for your pages
A `Page` in Hugo can be rendered to multiple representations on the file system: In its default configuration all will get an `HTML` page and some of them will get an `RSS` page (home page, sections etc.).
This can be changed by defining an `outputs` list of output formats in either the `Page` front matter or in the site configuration (either for all sites or per language).
Example from site config in `config.toml`:
```toml
[outputs]
home = [ "HTML", "AMP", "RSS"]
page = [ "HTML"]
```
Note:
* The output definition is per `Page` `Kind`(`page`, `home`, `section`, `taxonomy`, `taxonomyTerm`).
* The names used must match the `Name` of a defined `Output Format`.
* Any `Kind` without a definition will get `HTML`.
* These can be overriden per `Page` in front matter (see below).
* When `outputs` is specified, only the formats defined in outputs will be rendered
A `Page` with `YAML` front matter defining some output formats for that `Page`:
```yaml
---
date: "2016-03-19"
outputs:
- html
- amp
- json
---
```
Note:
* The names used for the output formats are case insensitive.
* The first output format in the list will act as the default.
* The default output format is used when generating links to other pages in menus, etc.
## Link to Output Formats
`Page` has both `.OutputFormats` (all formats including the current) and `.AlternativeOutputFormats`, the latter useful for creating a `link rel` list in your `head` section:
```
{{ range .AlternativeOutputFormats -}}
<link rel="{{ .Rel }}" type="{{ .MediaType.Type }}" href="{{ .Permalink | safeURL }}">
{{ end -}}
```
Note that `.Permalink` on `RelPermalink` on `Page` will return the first output format defined for that page (usually `HTML` if nothing else is defined).
This is how you link to a given output format:
```
{{ with .OutputFormats.Get "json" -}}
<a href="{{ .Permalink }}">{{ .Name }}</a>
{{- end }}
```
From content files, you can use the `ref` or `relref` shortcodes:
```
[Neat]({{</* ref "blog/neat.md" "amp" */>}})
[Who]({{</* relref "about.md#who" "amp" */>}})
```
## Templates for your Output Formats
Of course, for a new Output Format to render anything useful, we need a template for it.
**The fundamental thing to understand about this is that we in `Hugo 0.20` now also look at Output Format´s `Name` and MediaType´s `Suffix` when we choose the templates to use to render a given `Page`.**
And with so many possible variations, this is best explained with some examples:
{{< datatable "output" "layouts" "Example" "OutputFormat" "Suffix" "Template Lookup Order" >}}
**Note:**
* All of the above examples can use a base template, see [Blocks]({{< relref "templates/blocks.md" >}}).
* All of the above examples can also include partials.
Hugo will now also detect the media type and output format of partials, if possible, and use that information to decide if the partial should be parsed as a plain text template or not.
Hugo will look for the name given, so you can name it whatever you want. But if you want it treated as plain text, you should use the file suffix and, if needed, the name of the Output Format (`[partial name].[OutputFormat].[suffix])`.
The partial below is a plain text template (Outpuf Format is `CSV`, and since this is the only output format with the suffix `csv`, we don't need to include the Output Format's `Name`):
```
{{ partial "mytextpartial.csv" . }}
```
Also note that plain text partials can currently only be included in plain text templates, and vice versa. See [this issue](https://github.com/spf13/hugo/issues/3273) for some background.
-106
View File
@@ -1,106 +0,0 @@
---
aliases:
- /doc/pagination/
lastmod: 2015-07-16
date: 2014-01-01
menu:
main:
parent: extras
next: /extras/permalinks
prev: /extras/menus
title: Pagination
---
Hugo supports pagination for the home page, sections and taxonomies. It's built to be easy use, but with loads of flexibility when needed. The real power shines when you combine it with [`where`](/templates/functions/), with its SQL-like operators, `first` and others --- you can even [order the content](/templates/list/) the way you've become used to with Hugo.
## Configuration
Pagination can be configured in the site configuration (e.g. `config.toml`):
* `Paginate` (default `10`) (this setting can be overridden in the template)
* `PaginatePath` (default `page`)
Setting `Paginate` to a positive value will split the list pages for the home page, sections and taxonomies into chunks of that size. But note that the generation of the pagination pages for sections, taxonomies and home page is *lazy* --- the pages will not be created if not referenced by a `.Paginator` (see below).
`PaginatePath` is used to adapt the `URL` to the pages in the paginator (the default setting will produce URLs on the form `/page/1/`.
## List the pages
**A `.Paginator` is provided to help building a pager menu. This is currently only relevant for the templates for the home page and the list pages (sections and taxonomies).**
There are two ways to configure and use a `.Paginator`:
1. The simplest way is just to call `.Paginator.Pages` from a template. It will contain the pages for *that page* .
2. Select a sub-set of the pages with the available template functions and ordering options, and pass the slice to `.Paginate`, e.g. `{{ range (.Paginate ( first 50 .Data.Pages.ByTitle )).Pages }}`.
For a given **Page**, it's one of the options above. The `.Paginator` is static and cannot change once created.
The global page size setting (`Paginate`) can be overridden by providing a positive integer as the last argument. The examples below will give five items per page:
* `{{ range (.Paginator 5).Pages }}`
* `{{ $paginator := .Paginate (where .Data.Pages "Type" "post") 5 }}`
It is also possible to use the `GroupBy` functions in combination with pagination:
```
{{ range (.Paginate (.Data.Pages.GroupByDate "2006")).PageGroups }}
```
## Build the navigation
The `.Paginator` contains enough information to build a paginator interface.
The easiest way to add this to your pages is to include the built-in template (with `Bootstrap`-compatible styles):
```
{{ template "_internal/pagination.html" . }}
```
**Note:** If you use any filters or ordering functions to create your `.Paginator` **and** you want the navigation buttons to be shown before the page listing, you must create the `.Paginator` before it's used:
```
{{ $paginator := .Paginate (where .Data.Pages "Type" "post") }}
{{ template "_internal/pagination.html" . }}
{{ range $paginator.Pages }}
{{ .Title }}
{{ end }}
```
Without the where-filter, the above is simpler:
```
{{ template "_internal/pagination.html" . }}
{{ range .Paginator.Pages }}
{{ .Title }}
{{ end }}
```
If you want to build custom navigation, you can do so using the `.Paginator` object:
* `PageNumber`: The current page's number in the pager sequence
* `URL`: The relative URL to the current pager
* `Pages`: The pages in the current pager
* `NumberOfElements`: The number of elements on this page
* `HasPrev`: Whether there are page(s) before the current
* `Prev`: The pager for the previous page
* `HasNext`: Whether there are page(s) after the current
* `Next`: The pager for the next page
* `First`: The pager for the first page
* `Last`: The pager for the last page
* `Pagers`: A list of pagers that can be used to build a pagination menu
* `PageSize`: Size of each pager
* `TotalPages`: The number of pages in the paginator
* `TotalNumberOfElements`: The number of elements on all pages in this paginator
## Additional information
The pages are built on the following form (`BLANK` means no value):
```
[SECTION/TAXONOMY/BLANK]/index.html
[SECTION/TAXONOMY/BLANK]/page/1/index.html => redirect to [SECTION/TAXONOMY/BLANK]/index.html
[SECTION/TAXONOMY/BLANK]/page/2/index.html
....
```
-53
View File
@@ -1,53 +0,0 @@
---
aliases:
- /doc/permalinks/
lastmod: 2015-01-19
date: 2013-11-18
menu:
main:
parent: extras
next: /extras/scratch
notoc: true
prev: /extras/pagination
title: Permalinks
---
By default, content is laid out into the target `publishdir` (public)
namespace matching its layout within the `contentdir` hierarchy.
The `permalinks` site configuration option allows you to adjust this on a
per-section basis.
This will change where the files are written to and will change the page's
internal "canonical" location, such that template references to
`.RelPermalink` will honour the adjustments made as a result of the mappings
in this option.
For instance, if one of your sections is called `post`, and you want to adjust
the canonical path to be hierarchical based on the year and month, then you
might use:
```yaml
permalinks:
post: /:year/:month/:title/
```
Only the content under `post/` will be so rewritten.
A file named `content/post/sample-entry` which contains a line
`date: 2013-11-18T19:20:00-05:00` might end up with the rendered page
appearing at `public/2013/11/sample-entry/index.html` and be reachable via
the URL <http://yoursite.example.com/2013/11/sample-entry/>.
The following is a list of values that can be used in a permalink definition.
All references to time are dependent on the content's date.
* **:year** the 4-digit year
* **:month** the 2-digit month
* **:monthname** the name of the month
* **:day** the 2-digit day
* **:weekday** the 1-digit day of the week (Sunday = 0)
* **:weekdayname** the name of the day of the week
* **:yearday** the 1- to 3-digit day of the year
* **:section** the content's section
* **:title** the content's title
* **:slug** the content's slug (or title if no slug)
* **:filename** the content's filename (without extension)
-36
View File
@@ -1,36 +0,0 @@
---
lastmod: 2016-01-06
date: 2015-12-08
menu:
main:
parent: extras
next: /extras/datafiles
prev: /extras/crossreferences
title: Custom robots.txt
---
Hugo can generated a customized [robots.txt](http://www.robotstxt.org/) in the
[same way as any other templates]({{< ref "templates/go-templates.md" >}}).
To enable it, just set `enableRobotsTXT` option to `true` in the [configuration file]({{< ref "overview/configuration.md" >}}). By default, it generates a robots.txt, which allows everything, with the following content:
```http
User-agent: *
```
Hugo will use the template `robots.txt` according to the following list in descending precedence:
* /layouts/robots.txt
* /themes/`THEME`/layout/robots.txt
An example of a robots.txt layout is:
```http
User-agent: *
{{range .Data.Pages}}
Disallow: {{.RelPermalink}}{{end}}
```
This template disallows and all the pages of the site creating one `Disallow` entry for each one.
-63
View File
@@ -1,63 +0,0 @@
---
aliases:
- /doc/scratch/
lastmod: 2015-08-02
date: 2015-01-22
menu:
main:
parent: extras
next: /extras/shortcodes
prev: /extras/permalinks
title: Scratch
---
`Scratch` -- a "scratchpad" for your page-scoped variables. In most cases you can do well without `Scratch`, but there are some use cases that aren't solvable with Go's templates without `Scratch`'s help, due to scoping issues.
`Scratch` is added to both `Page` and `Shortcode` -- with following methods:
* `Set` and `Add` takes a `key` and the `value` to add.
* `Get` returns the `value` for the `key` given.
* `SetInMap` takes a `key`, `mapKey` and `value`
* `GetSortedMapValues` returns array of values from `key` sorted by `mapKey`
`Set` and `SetInMap` can store values of any type.
For single values, `Add` accepts values that support Go's `+` operator. If the first `Add` for a key is an array or slice, the following adds will be appended to that list.
The scope of the backing data is global for the given `Page` or `Shortcode`, and spans partial and shortcode includes.
Note that `.Scratch` from a shortcode will return the shortcode's `Scratch`, which in most cases is what you want. If you want to store it in the page scroped Scratch, then use `.Page.Scratch`.
## Sample usage
The usage is best illustrated with some samples:
```
{{ $.Scratch.Add "a1" 12 }}
{{ $.Scratch.Get "a1" }} {{/* => 12 */}}
{{ $.Scratch.Add "a1" 1 }}
{{ $.Scratch.Get "a1" }} // {{/* => 13 */}}
{{ $.Scratch.Add "a2" "AB" }}
{{ $.Scratch.Get "a2" }} {{/* => AB */}}
{{ $.Scratch.Add "a2" "CD" }}
{{ $.Scratch.Get "a2" }} {{/* => ABCD */}}
{{ $.Scratch.Add "l1" (slice "A" "B") }}
{{ $.Scratch.Get "l1" }} {{/* => [A B] */}}
{{ $.Scratch.Add "l1" (slice "C" "D") }}
{{ $.Scratch.Get "l1" }} {{/* => [A B C D] */}}
{{ $.Scratch.Set "v1" 123 }}
{{ $.Scratch.Get "v1" }} {{/* => 123 */}}
{{ $.Scratch.SetInMap "a3" "b" "XX" }}
{{ $.Scratch.SetInMap "a3" "a" "AA" }}
{{ $.Scratch.SetInMap "a3" "c" "CC" }}
{{ $.Scratch.SetInMap "a3" "b" "BB" }}
{{ $.Scratch.GetSortedMapValues "a3" }} {{/* => []interface {}{"AA", "BB", "CC"} */}}
```
**Note:** The examples above uses the special `$` variable, which refers to the top-level node. This is the behavior you most likely want, and will help remove some confusion when using `Scratch` inside page range loops -- and you start inadvertently calling the wrong `Scratch`. But there may be use cases for `{{ .Scratch.Add "key" "some value" }}`.
-413
View File
@@ -1,413 +0,0 @@
---
aliases:
- /doc/shortcodes/
lastmod: 2016-02-03
date: 2013-07-01
menu:
main:
parent: extras
next: /extras/highlighting
prev: /extras/scratch
title: Shortcodes
toc: true
---
Hugo uses Markdown for its simple content format. However, there are a lot
of things that Markdown doesnt support well.
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 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.
To avoid both of these limitations, Hugo created shortcodes.
A shortcode is a simple snippet inside a content file that Hugo will render
using a predefined template. Note that shortcodes will not work in template
files---if you need a functionality like that in a template, you most likely
want a [partial template](/templates/partials/) instead.
Another benefit is, you can update your shortcode with any related new classes or
techniques, and upon generation, Hugo will easily merge in your changes. You
avoid a possibly complicated search and replace operation.
## Using a shortcode
In your content files, a shortcode can be called by using the `{{%/* name parameters
*/%}}` form. Shortcode parameters are space delimited. Parameters with spaces
can be quoted.
The first word is always the name of the shortcode. Parameters follow the name.
Depending upon how the shortcode is defined, the parameters may be named,
positional or both (although you can't mix parameter types in a single call).
The format for named parameters models that of HTML with the format
`name="value"`.
Some shortcodes use or require closing shortcodes. Like HTML, the opening and closing
shortcodes match (name only), the closing being prepended with a slash.
Example of a paired shortcode:
{{</* highlight go */>}} A bunch of code here {{</* /highlight */>}}
The examples above use two different delimiters, the difference being the `%` and the `<` character:
### Shortcodes with Markdown
The `%` characters indicates that the shortcode's inner content needs further processing by the page's rendering processor (i.e. Markdown), needed to get the **bold** text in the example below:
{{%/* myshortcode */%}}Hello **World!**{{%/* /myshortcode */%}}
### Shortcodes without Markdown
The `<` character indicates that the shortcode's inner content doesn't need any further rendering, this will typically be pure HTML:
{{</* myshortcode */>}}<p>Hello <strong>World!</strong></p>{{</* /myshortcode */>}}
## Built-in Shortcodes
Hugo ships with a set of predefined shortcodes.
### highlight
This shortcode will convert the source code provided into syntax highlighted
HTML. Read more on [highlighting](/extras/highlighting/).
#### Usage
`highlight` takes exactly one required parameter of _language_ and requires a
closing shortcode.
#### Example
{{</* highlight html */>}}
<section id="main">
<div>
<h1 id="title">{{ .Title }}</h1>
{{ range .Data.Pages }}
{{ .Render "summary"}}
{{ end }}
</div>
</section>
{{</* /highlight */>}}
#### Example Output
<span style="color: #f92672">&lt;section</span> <span style="color: #a6e22e">id=</span><span style="color: #e6db74">&quot;main&quot;</span><span style="color: #f92672">&gt;</span>
<span style="color: #f92672">&lt;div&gt;</span>
<span style="color: #f92672">&lt;h1</span> <span style="color: #a6e22e">id=</span><span style="color: #e6db74">&quot;title&quot;</span><span style="color: #f92672">&gt;</span>{{ .Title }}<span style="color: #f92672">&lt;/h1&gt;</span>
{{ range .Data.Pages }}
{{ .Render &quot;summary&quot;}}
{{ end }}
<span style="color: #f92672">&lt;/div&gt;</span>
<span style="color: #f92672">&lt;/section&gt;</span>
### figure
`figure` is simply an extension of the image capabilities present with Markdown.
`figure` provides the ability to add captions, CSS classes, alt text, links etc.
#### Usage
`figure` can use the following named parameters:
* src
* link
* title
* caption
* class
* attr (attribution)
* attrlink
* alt
#### Example
{{</* figure src="/media/spf13.jpg" title="Steve Francia" */>}}
#### Example output
<figure>
<img src="/media/spf13.jpg" />
<figcaption>
<h4>Steve Francia</h4>
</figcaption>
</figure>
### ref, relref
These shortcodes will look up the pages by their relative path (e.g.,
`blog/post.md`) or their logical name (`post.md`) and return the permalink
(`ref`) or relative permalink (`relref`) for the found page.
`ref` and `relref` also make it possible to make fragmentary links that work
for the header links generated by Hugo.
Read more on [cross-references]({{% ref "extras/crossreferences.md" %}}).
#### Usage
`ref` and `relref` take exactly one required parameter of _reference_.
#### Example
[Neat]({{</* ref "blog/neat.md" */>}})
[Who]({{</* relref "about.md#who" */>}})
If the page exists in multiple [output formats]({{< relref "extras/output-formats.md" >}}), `ref` or `relref` can be used with a output format name:
[Neat]({{</* ref "blog/neat.md" "amp" */>}})
#### Example Output
Assuming that standard Hugo pretty URLs are turned on.
<a href="/blog/neat">Neat</a>
<a href="/about/#who:c28654c202e73453784cfd2c5ab356c0">Who</a>
### Twitter
You want to include a single tweet into your blog post? Everything you need is the URL of the tweet, e.g.:
* https://twitter.com/spf13/status/666616452582129664
Pass the tweet's ID from the URL as parameter to the shortcode as shown below:
{{</* tweet 666616452582129664 */>}}
### YouTube
This shortcode embeds a responsive video player for [YouTube](https://www.youtube.com/) videos. Only the ID of the video is required, e.g.:
* https://www.youtube.com/watch?v=w7Ft2ymGmfc
Copy the ID from behind `v=` and pass it to the shortcode:
{{</* youtube w7Ft2ymGmfc */>}}
Furthermore, you can autoplay the embedded video by setting the `autoplay` parameter to true. Remember that you can't mix named an unamed parameters. Assign the yet unamed video id to the parameter `id` like below too.
{{</* youtube id="w7Ft2ymGmfc" autoplay="true" */>}}
### Vimeo
Adding a video from [Vimeo](https://vimeo.com/) is equivalent to the YouTube shortcode above. Extract the ID from the URL, e.g.:
* https://vimeo.com/channels/staffpicks/146022717
and pass it to the shortcode:
{{</* vimeo 146022717 */>}}
### GitHub gists
Including code snippets with GitHub gists while writing a tutorial is common situation bloggers face. With a given URL of the gist, e.g.:
* https://gist.github.com/spf13/7896402
pass the owner and the ID of the gist to the shortcode:
{{</* gist spf13 7896402 */>}}
If the gist contains several files and you want to quote just one of them, you can pass the filename (quoted) as an optional third argument:
{{</* gist spf13 7896402 "img.html" */>}}
### Speaker Deck
To embed slides from [Speaker Deck](https://speakerdeck.com/), click on "&lt;&#8239;/&gt;&nbsp;Embed" (under Share right next to the template on Speaker Deck) and copy the URL, e.g.:
<script async class="speakerdeck-embed" data-id="4e8126e72d853c0060001f97" data-ratio="1.33333333333333" src="//speakerdeck.com/assets/embed.js"></script>
Extract the value from the field `data-id` and pass it to the shortcode:
{{</* speakerdeck 4e8126e72d853c0060001f97 */>}}
### Instagram
If you'd like to embed photo from [Instagram](https://www.instagram.com/), all you need is photo ID from the URL, e. g.:
* https://www.instagram.com/p/BMokmydjG-M/
Pass it to the shortcode:
{{</* instagram BMokmydjG-M */>}}
Optionally, hide caption:
{{</* instagram BMokmydjG-M hidecaption */>}}
## Creating your own shortcodes
To create a shortcode, place a template in the layouts/shortcodes directory. The
template name will be the name of the shortcode.
In creating a shortcode, you can choose if the shortcode will use _positional
parameters_, or _named parameters_, or _both_. A good rule of thumb is that if a
shortcode 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. Allowing both types of parameters is
useful for complex layouts where you want to set default values that can be
overridden.
**Inside the template**
To access a parameter by position, the `.Get` method can be used:
{{ .Get 0 }}
To access a parameter by name, the `.Get` method should be utilized:
{{ .Get "class" }}
`with` is great when the output depends on a parameter being set:
{{ with .Get "class"}} class="{{.}}"{{ end }}
`.Get` can also be used to check if a parameter has been provided. This is
most helpful when the condition depends on either one value or another...
or both:
{{ or .Get "title" | .Get "alt" | if }} alt="{{ with .Get "alt"}}{{.}}{{else}}{{.Get "title"}}{{end}}"{{ end }}
If a closing shortcode is used, the variable `.Inner` will be populated with all
of the content between the opening and closing shortcodes. If a closing
shortcode is required, you can check the length of `.Inner` and provide a warning
to the user.
A shortcode with `.Inner` content can be used without the inline content, and without the closing shortcode, by using the self-closing syntax:
{{</* innershortcode /*/>}}
The variable `.Params` contains the list of parameters in case you need to do
more complicated things than `.Get`. It is sometimes useful to provide a
flexible shortcode that can take named or positional parameters. To meet this
need, Hugo shortcodes have a `.IsNamedParams` boolean available that can be used
such as `{{ if .IsNamedParams }}...{{ else }}...{{ end }}`. See the
`Single Flexible Example` below for an example.
You can also use the variable `.Page` to access all the normal [Page Variables](/templates/variables/).
A shortcodes can be nested. In a nested shortcode you can access the parent shortcode context with `.Parent`. This can be very useful for inheritance of common shortcode parameters from the root.
## Single Positional Example: youtube
{{</* youtube 09jf3ow9jfw */>}}
Would load the template /layouts/shortcodes/youtube.html
<div class="embed video-player">
<iframe class="youtube-player" type="text/html" width="640" height="385" src="http://www.youtube.com/embed/{{ index .Params 0 }}" allowfullscreen frameborder="0">
</iframe>
</div>
This would be rendered as:
<div class="embed video-player">
<iframe class="youtube-player" type="text/html"
width="640" height="385"
src="http://www.youtube.com/embed/09jf3ow9jfw"
allowfullscreen frameborder="0">
</iframe>
</div>
## Single Named Example: image with caption
{{</* img src="/media/spf13.jpg" title="Steve Francia" */>}}
Would load the template /layouts/shortcodes/img.html
<!-- image -->
<figure {{ with .Get "class" }}class="{{.}}"{{ end }}>
{{ with .Get "link"}}<a href="{{.}}">{{ end }}
<img src="{{ .Get "src" }}" {{ if or (.Get "alt") (.Get "caption") }}alt="{{ with .Get "alt"}}{{.}}{{else}}{{ .Get "caption" }}{{ end }}"{{ end }} />
{{ if .Get "link"}}</a>{{ end }}
{{ if or (or (.Get "title") (.Get "caption")) (.Get "attr")}}
<figcaption>{{ if isset .Params "title" }}
<h4>{{ .Get "title" }}</h4>{{ end }}
{{ if or (.Get "caption") (.Get "attr")}}<p>
{{ .Get "caption" }}
{{ with .Get "attrlink"}}<a href="{{.}}"> {{ end }}
{{ .Get "attr" }}
{{ if .Get "attrlink"}}</a> {{ end }}
</p> {{ end }}
</figcaption>
{{ end }}
</figure>
<!-- image -->
Would be rendered as:
<figure >
<img src="/media/spf13.jpg" />
<figcaption>
<h4>Steve Francia</h4>
</figcaption>
</figure>
## Single Flexible Example: vimeo with defaults
{{</* vimeo 49718712 */>}}
{{</* vimeo id="49718712" class="flex-video" */>}}
Would load the template /layouts/shortcodes/vimeo.html
{{ if .IsNamedParams }}
<div class="{{ if .Get "class" }}{{ .Get "class" }}{{ else }}vimeo-container{{ end }}">
<iframe src="//player.vimeo.com/video/{{ .Get "id" }}" allowfullscreen></iframe>
</div>
{{ else }}
<div class="{{ if len .Params | eq 2 }}{{ .Get 1 }}{{ else }}vimeo-container{{ end }}">
<iframe src="//player.vimeo.com/video/{{ .Get 0 }}" allowfullscreen></iframe>
</div>
{{ end }}
Would be rendered as:
<div class="vimeo-container">
<iframe src="//player.vimeo.com/video/49718712" allowfullscreen></iframe>
</div>
<div class="flex-video">
<iframe src="//player.vimeo.com/video/49718712" allowfullscreen></iframe>
</div>
## Paired Example: Highlight
*Hugo already ships with the `highlight` shortcode*
{{</* highlight html */>}}
<html>
<body> This HTML </body>
</html>
{{</* /highlight */>}}
The template for this utilizes the following code (already included in Hugo)
{{ .Get 0 | highlight .Inner }}
And will be rendered as:
<div class="highlight" style="background: #272822"><pre style="line-height: 125%"><span style="color: #f92672">&lt;html&gt;</span>
<span style="color: #f92672">&lt;body&gt;</span> This HTML <span style="color: #f92672">&lt;/body&gt;</span>
<span style="color: #f92672">&lt;/html&gt;</span>
</pre></div>
Please notice that this template makes use of a Hugo-specific template function
called `highlight` which uses Pygments to add the highlighting code.
## Simple Single-word Example: Year
Let's assume you would like to have a shortcode to be replaced by the current year in your Markdown content files, for a license or copyright statement. Calling a shortcode like this:
{{</* year */>}}
... would load your one-line template ``/layouts/shortcodes/year.html``, which contains:
{{ .Page.Now.Year }}
More shortcode examples can be found at [spf13.com](https://github.com/spf13/spf13.com/tree/master/layouts/shortcodes).
-37
View File
@@ -1,37 +0,0 @@
---
lastmod: 2015-01-27
date: 2013-07-09
menu:
main:
parent: extras
next: /extras/localfiles
prev: /extras/highlighting
title: Table of Contents
---
Hugo will automatically parse the Markdown for your content and create
a Table of Contents you can use to guide readers to the sections within
your content.
## Usage
Simply create content like you normally would with the appropriate
headers.
Hugo will take this Markdown and create a table of contents stored in the
[content variable](/layout/variables/) `.TableOfContents`
## Template Example
This is example code of a [single.html template](/layout/content/).
{{ partial "header.html" . }}
<div id="toc" class="well col-md-4 col-sm-6">
{{ .TableOfContents }}
</div>
<h1>{{ .Title }}</h1>
{{ .Content }}
{{ partial "footer.html" . }}
-70
View File
@@ -1,70 +0,0 @@
---
aliases:
- /doc/urls/
lastmod: 2016-05-07
date: 2014-01-03
menu:
main:
parent: extras
next: /community/mailing-list
notoc: true
prev: /extras/localfiles
title: URLs
---
## Pretty URLs
By default, Hugo creates content with 'pretty' URLs. For example,
content created at `/content/extras/urls.md` will be rendered at
`/public/extras/urls/index.html`, thus accessible from the browser
at http://example.com/extras/urls/. No non-standard server-side
configuration is required for these pretty URLs to work.
If you would like to have what we call "ugly URLs",
e.g.&nbsp;http://example.com/extras/urls.html, you are in luck.
Hugo supports the ability to create your entire site with ugly URLs.
Simply add `uglyurls = true` to your site-wide `config.toml`,
or use the `--uglyURLs=true` flag on the command line.
If you want a specific piece of content to have an exact URL, you can
specify this in the front matter under the `url` key. See [Content
Organization](/content/organization/) for more details.
## Canonicalization
By default, all relative URLs encountered in the input are left unmodified,
e.g. `/css/foo.css` would stay as `/css/foo.css`,
i.e. `canonifyURLs` defaults to `false`.
By setting `canonifyURLs` to `true`, all relative URLs would instead
be *canonicalized* using `baseURL`. For example, assuming you have
`baseURL = http://yoursite.example.com/` defined in the site-wide
`config.toml`, the relative URL `/css/foo.css` would be turned into
the absolute URL `http://yoursite.example.com/css/foo.css`.
Benefits of canonicalization include fixing all URLs to be absolute, which may
aid with some parsing tasks. Note though that all real browsers handle this
client-side without issues.
Benefits of non-canonicalization include being able to have resource inclusion
be scheme-relative, so that http vs https can be decided based on how this
page was retrieved.
> Note: In the May 2014 release of Hugo v0.11, the default value of `canonifyURLs` was switched from `true` to `false`, which we think is the better default and should continue to be the case going forward. So, please verify and adjust your website accordingly if you are upgrading from v0.10 or older versions.
To find out the current value of `canonifyURLs` for your website, you may use the handy `hugo config` command added in v0.13:
hugo config | grep -i canon
Or, if you are on Windows and do not have `grep` installed:
hugo config | FINDSTR /I canon
## Relative URLs
By default, all relative URLs are left unchanged by Hugo,
which can be problematic when you want to make your site browsable from a local file system.
Setting `relativeURLs` to `true` in the site configuration will cause Hugo to rewrite all relative URLs to be relative to the current content.
For example, if the `/post/first/` page contained a link with a relative URL of `/about/`, Hugo would rewrite that URL to `../../about/`.
-211
View File
@@ -1,211 +0,0 @@
---
aliases:
- /doc/license/
- /license/
- /meta/license/
lastmod: 2015-11-25
date: 2013-07-01
menu:
main:
parent: about
title: License
weight: 50
---
Hugo v0.15 and later are released under the Apache 2.0 license.
Earlier releases were under the Simple Public License.
Apache License
==============
_Version 2.0, January 2004_
_&lt;<http://www.apache.org/licenses/>&gt;_
### Terms and Conditions for use, reproduction, and distribution
#### 1. Definitions
“License” shall mean the terms and conditions for use, reproduction, and
distribution as defined by Sections 1 through 9 of this document.
“Licensor” shall mean the copyright owner or entity authorized by the copyright
owner that is granting the License.
“Legal Entity” shall mean the union of the acting entity and all other entities
that control, are controlled by, or are under common control with that entity.
For the purposes of this definition, “control” means **(i)** the power, direct or
indirect, to cause the direction or management of such entity, whether by
contract or otherwise, or **(ii)** ownership of fifty percent (50%) or more of the
outstanding shares, or **(iii)** beneficial ownership of such entity.
“You” (or “Your”) shall mean an individual or Legal Entity exercising
permissions granted by this License.
“Source” form shall mean the preferred form for making modifications, including
but not limited to software source code, documentation source, and configuration
files.
“Object” form shall mean any form resulting from mechanical transformation or
translation of a Source form, including but not limited to compiled object code,
generated documentation, and conversions to other media types.
“Work” shall mean the work of authorship, whether in Source or Object form, made
available under the License, as indicated by a copyright notice that is included
in or attached to the work (an example is provided in the Appendix below).
“Derivative Works” shall mean any work, whether in Source or Object form, that
is based on (or derived from) the Work and for which the editorial revisions,
annotations, elaborations, or other modifications represent, as a whole, an
original work of authorship. For the purposes of this License, Derivative Works
shall not include works that remain separable from, or merely link (or bind by
name) to the interfaces of, the Work and Derivative Works thereof.
“Contribution” shall mean any work of authorship, including the original version
of the Work and any modifications or additions to that Work or Derivative Works
thereof, that is intentionally submitted to Licensor for inclusion in the Work
by the copyright owner or by an individual or Legal Entity authorized to submit
on behalf of the copyright owner. For the purposes of this definition,
“submitted” means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems, and
issue tracking systems that are managed by, or on behalf of, the Licensor for
the purpose of discussing and improving the Work, but excluding communication
that is conspicuously marked or otherwise designated in writing by the copyright
owner as “Not a Contribution.”
“Contributor” shall mean Licensor and any individual or Legal Entity on behalf
of whom a Contribution has been received by Licensor and subsequently
incorporated within the Work.
#### 2. Grant of Copyright License
Subject to the terms and conditions of this License, each Contributor hereby
grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
irrevocable copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the Work and such
Derivative Works in Source or Object form.
#### 3. Grant of Patent License
Subject to the terms and conditions of this License, each Contributor hereby
grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
irrevocable (except as stated in this section) patent license to make, have
made, use, offer to sell, sell, import, and otherwise transfer the Work, where
such license applies only to those patent claims licensable by such Contributor
that are necessarily infringed by their Contribution(s) alone or by combination
of their Contribution(s) with the Work to which such Contribution(s) was
submitted. If You institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work or a
Contribution incorporated within the Work constitutes direct or contributory
patent infringement, then any patent licenses granted to You under this License
for that Work shall terminate as of the date such litigation is filed.
#### 4. Redistribution
You may reproduce and distribute copies of the Work or Derivative Works thereof
in any medium, with or without modifications, and in Source or Object form,
provided that You meet the following conditions:
* **(a)** You must give any other recipients of the Work or Derivative Works a copy of
this License; and
* **(b)** You must cause any modified files to carry prominent notices stating that You
changed the files; and
* **(c)** You must retain, in the Source form of any Derivative Works that You distribute,
all copyright, patent, trademark, and attribution notices from the Source form
of the Work, excluding those notices that do not pertain to any part of the
Derivative Works; and
* **(d)** If the Work includes a “NOTICE” text file as part of its distribution, then any
Derivative Works that You distribute must include a readable copy of the
attribution notices contained within such NOTICE file, excluding those notices
that do not pertain to any part of the Derivative Works, in at least one of the
following places: within a NOTICE text file distributed as part of the
Derivative Works; within the Source form or documentation, if provided along
with the Derivative Works; or, within a display generated by the Derivative
Works, if and wherever such third-party notices normally appear. The contents of
the NOTICE file are for informational purposes only and do not modify the
License. You may add Your own attribution notices within Derivative Works that
You distribute, alongside or as an addendum to the NOTICE text from the Work,
provided that such additional attribution notices cannot be construed as
modifying the License.
You may add Your own copyright statement to Your modifications and may provide
additional or different license terms and conditions for use, reproduction, or
distribution of Your modifications, or for any such Derivative Works as a whole,
provided Your use, reproduction, and distribution of the Work otherwise complies
with the conditions stated in this License.
#### 5. Submission of Contributions
Unless You explicitly state otherwise, any Contribution intentionally submitted
for inclusion in the Work by You to the Licensor shall be under the terms and
conditions of this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify the terms of
any separate license agreement you may have executed with Licensor regarding
such Contributions.
#### 6. Trademarks
This License does not grant permission to use the trade names, trademarks,
service marks, or product names of the Licensor, except as required for
reasonable and customary use in describing the origin of the Work and
reproducing the content of the NOTICE file.
#### 7. Disclaimer of Warranty
Unless required by applicable law or agreed to in writing, Licensor provides the
Work (and each Contributor provides its Contributions) on an “AS IS” BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
including, without limitation, any warranties or conditions of TITLE,
NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are
solely responsible for determining the appropriateness of using or
redistributing the Work and assume any risks associated with Your exercise of
permissions under this License.
#### 8. Limitation of Liability
In no event and under no legal theory, whether in tort (including negligence),
contract, or otherwise, unless required by applicable law (such as deliberate
and grossly negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special, incidental,
or consequential damages of any character arising as a result of this License or
out of the use or inability to use the Work (including but not limited to
damages for loss of goodwill, work stoppage, computer failure or malfunction, or
any and all other commercial damages or losses), even if such Contributor has
been advised of the possibility of such damages.
#### 9. Accepting Warranty or Additional Liability
While redistributing the Work or Derivative Works thereof, You may choose to
offer, and charge a fee for, acceptance of support, warranty, indemnity, or
other liability obligations and/or rights consistent with this License. However,
in accepting such obligations, You may act only on Your own behalf and on Your
sole responsibility, not on behalf of any other Contributor, and only if You
agree to indemnify, defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason of your
accepting any such warranty or additional liability.
_END OF TERMS AND CONDITIONS_
### APPENDIX: How to apply the Apache License to your work
To apply the Apache License to your work, attach the following boilerplate
notice, with the fields enclosed by brackets `[]` replaced with your own
identifying information. (Don't include the brackets!) The text should be
enclosed in the appropriate comment syntax for the file format. We also
recommend that a file or class name and description of purpose be included on
the same “printed page” as the copyright notice for easier identification within
third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-33
View File
@@ -1,33 +0,0 @@
---
aliases:
- /doc/roadmap/
- /meta/roadmap/
lastmod: 2015-02-16
date: 2013-07-01
menu:
main:
parent: about
notoc: true
title: Hugo Roadmap
weight: 20
---
In no particular order, here is what we are working on:
* Intelligently related posts ([#98][])
* Even easier deployment to S3, SSH, GitHub, rsync. Give the [tools section](https://gohugo.io/tools/#deployment) a shot or read one of the related tutorials.
* Import from other website systems. There are already existing [migration tools](https://gohugo.io/tools/#migration) but they don't cover all major platforms.
* An interactive web based editor (See https://discuss.gohugo.io/t/web-based-editor/155)
* Additional [themes](https://github.com/spf13/hugoThemes) (always on-going, contributions welcome!)
* Dynamic image resizing via shortcodes ([#1014][])
* Native support for additional content formats (AsciiDoc [#1435][], reST [#1436][])
* And, last but not least, ***Your best ideas***!
[#100]: https://github.com/spf13/hugo/issues/100 "hugo import from wordpress · Issue #100 · spf13/hugo"
[#101]: https://github.com/spf13/hugo/issues/101 "hugo import from jekyll · Issue #101 · spf13/hugo"
[#1435]: https://github.com/spf13/hugo/issues/1435 "Add support for native Go implementation of AsciiDoc · Issue #1435 · spf13/hugo"
[#1436]: https://github.com/spf13/hugo/issues/1436 "Add support for native Go implementation of reStructuredText (reST) · Issue #1436 · spf13/hugo"
[#1014]: https://github.com/spf13/hugo/issues/1014 "Image Resizing and Cropping · Issue #1014 · spf13/hugo"
[#98]: https://github.com/spf13/hugo/issues/98 "Add support for related content · Issue #98 · spf13/hugo"
> Feel free to [contribute]({{< relref "tutorials/how-to-contribute-to-hugo.md" >}}) or open a [new issue](https://github.com/spf13/hugo/issues/new) if you have an idea for a new feature.)
-458
View File
@@ -1,458 +0,0 @@
---
aliases:
- /doc/configuration/
lastmod: 2016-09-17
date: 2013-07-01
linktitle: Configuration
menu:
main:
parent: getting started
next: /overview/source-directory
toc: true
prev: /overview/usage
title: Configuring Hugo
weight: 40
---
The directory structure of a Hugo web site&mdash;or more precisely,
of the source files containing its content and templates&mdash;provide
most of the configuration information that Hugo needs.
Therefore, in essence,
many web sites wouldn't actually need a configuration file.
This is because Hugo is designed to recognize certain typical usage patterns
(and it expects them, by default).
Nevertheless, Hugo does search for a configuration file bearing
a particular name in the root of your web site's source directory.
First, it looks for a `./config.toml` file.
If that's not present, it will seek a `./config.yaml` file,
followed by a `./config.json` file.
In this `config` file for your web site,
you can include precise directions to Hugo regarding
how it should render your site, as well as define its menus,
and set various other site-wide parameters.
Another way that web site configuration can be accomplished is through
operating system environment variables.
For instance, the following command will work on Unix-like systems&mdash;it
sets a web site's title:
```bash
$ env HUGO_TITLE="Some Title" hugo
```
(**Note:** all such environment variable names must be prefixed with
<code>HUGO_</code>.)
## Examples
Following is a typical example of a YAML configuration file.
Three periods end the document:
```yaml
---
baseURL: "http://yoursite.example.com/"
...
```
Following is an example TOML configuration file with some default values.
The values under `[params]` will populate the `.Site.Params` variable
for use in templates:
```toml
contentDir = "content"
layoutDir = "layouts"
publishDir = "public"
buildDrafts = false
baseURL = "http://yoursite.example.com/"
canonifyURLs = true
[taxonomies]
category = "categories"
tag = "tags"
[params]
description = "Tesla's Awesome Hugo Site"
author = "Nikola Tesla"
```
Here is a YAML configuration file which sets a few more options:
```yaml
---
baseURL: "http://yoursite.example.com/"
title: "Yoyodyne Widget Blogging"
footnoteReturnLinkContents: "↩"
permalinks:
post: /:year/:month/:title/
params:
Subtitle: "Spinning the cogs in the widgets"
AuthorName: "John Doe"
GitHubUser: "spf13"
ListOfFoo:
- "foo1"
- "foo2"
SidebarRecentLimit: 5
...
```
## Configuration variables
Following is a list of Hugo-defined variables you can configure,
along with their current, default values:
---
archetypeDir: "archetypes"
# hostname (and path) to the root, e.g. http://spf13.com/
baseURL: ""
# include content marked as draft
buildDrafts: false
# include content with publishdate in the future
buildFuture: false
# include content already expired
buildExpired: false
# enable this to make all relative URLs relative to content root. Note that this does not affect absolute URLs.
relativeURLs: false
canonifyURLs: false
# config file (default is path/config.yaml|json|toml)
config: "config.toml"
contentDir: "content"
dataDir: "data"
defaultExtension: "html"
defaultLayout: "post"
# Missing translations will default to this content language
defaultContentLanguage: "en"
# Renders the default content language in subdir, e.g. /en/. The root directory / will redirect to /en/
defaultContentLanguageInSubdir: false
# The below example will disable all page types and will render nothing.
disableKinds = ["page", "home", "section", "taxonomy", "taxonomyTerm", "RSS", "sitemap", "robotsTXT", "404"]
disableLiveReload: false
# Do not build RSS files
disableRSS: false
# Do not build Sitemap file
disableSitemap: false
# Enable GitInfo feature
enableGitInfo: false
# Build robots.txt file
enableRobotsTXT: false
# Do not render 404 page
disable404: false
# Do not inject generator meta tag on homepage
disableHugoGeneratorInject: false
# Enable Emoji emoticons support for page content.
# See www.emoji-cheat-sheet.com
enableEmoji: false
# Show a placeholder instead of the default value or an empty string if a translation is missing
enableMissingTranslationPlaceholders: false
footnoteAnchorPrefix: ""
footnoteReturnLinkContents: ""
# google analytics tracking id
googleAnalytics: ""
languageCode: ""
layoutDir: "layouts"
# Enable Logging
log: false
# Log File path (if set, logging enabled automatically)
logFile: ""
# "yaml", "toml", "json"
metaDataFormat: "toml"
# Edit new content with this editor, if provided
newContentEditor: ""
# Don't sync permission mode of files
noChmod: false
# Don't sync modification time of files
noTimes: false
paginate: 10
paginatePath: "page"
permalinks:
# Pluralize titles in lists using inflect
pluralizeListTitles: true
# Preserve special characters in taxonomy names ("Gérard Depardieu" vs "Gerard Depardieu")
preserveTaxonomyNames: false
# filesystem path to write files to
publishDir: "public"
# enables syntax guessing for code fences without specified language
pygmentsCodeFencesGuessSyntax: false
# color-codes for highlighting derived from this style
pygmentsStyle: "monokai"
# true: use pygments-css or false: color-codes directly
pygmentsUseClasses: false
# maximum number of items in the RSS feed
rssLimit: 15
# default sitemap configuration map
sitemap:
# filesystem path to read files relative from
source: ""
staticDir: "static"
# display memory and timing of different steps of the program
stepAnalysis: false
# theme to use (located by default in /themes/THEMENAME/)
themesDir: "themes"
theme: ""
title: ""
# if true, use /filename.html instead of /filename/
uglyURLs: false
# Do not make the url/path to lowercase
disablePathToLower: false
# if true, auto-detect Chinese/Japanese/Korean Languages in the content. (.Summary and .WordCount can work properly in CJKLanguage)
hasCJKLanguage: false
# verbose output
verbose: false
# verbose logging
verboseLog: false
# watch filesystem for changes and recreate as needed
watch: true
---
## Ignore various files when rendering
The following statement inside `./config.toml` will cause Hugo to ignore files
ending with `.foo` and `.boo` when rendering:
```toml
ignoreFiles = [ "\\.foo$", "\\.boo$" ]
```
The above is a list of regular expressions.
Note that the backslash (`\`) character is escaped, to keep TOML happy.
## Configure Blackfriday rendering
[Blackfriday](https://github.com/russross/blackfriday) is Hugo's
[Markdown](http://daringfireball.net/projects/markdown/)
rendering engine.
In the main, Hugo typically configures Blackfriday with a sane set of defaults.
These defaults should fit most use cases, reasonably well.
However, if you have unusual needs with respect to Markdown,
Hugo exposes some of its Blackfriday behavior options for you to alter.
The following table lists these Hugo options,
paired with the corresponding flags from Blackfriday's source code (for the latter, see
[html.go](https://github.com/russross/blackfriday/blob/master/html.go) and
[markdown.go](https://github.com/russross/blackfriday/blob/master/markdown.go)):
<table class="table table-bordered-configuration">
<thead>
<tr>
<th>Flag</th>
<th>Default</th>
<th>Blackfriday flag</th>
</tr>
</thead>
<tbody>
<tr>
<td><code><strong>taskLists</strong></code></td>
<td><code>true</code></td>
<td><code></code></td>
</tr>
<tr>
<td class="purpose-description" colspan="3">
<span class="purpose-title">Purpose:</span>
<code>false</code> turns off GitHub-style automatic task/TODO
list generation.
</td>
</tr>
<tr>
<td><code><strong>smartypants</strong></code></td>
<td><code>true</code></td>
<td><code>HTML_USE_SMARTYPANTS</code></td>
</tr>
<tr>
<td class="purpose-description" colspan="3">
<span class="purpose-title">Purpose:</span>
<code>false</code> disables smart punctuation substitutions
including smart quotes, smart dashes, smart fractions, etc.
If <code>true</code>, it may be fine-tuned with the
<code>angledQuotes</code>,
<code>fractions</code>,
<code>smartDashes</code> and
<code>latexDashes</code> flags (see below).
</td>
</tr>
<tr>
<td><code><strong>angledQuotes</strong></code></td>
<td><code>false</code></td>
<td><code>HTML_SMARTYPANTS_ANGLED_QUOTES</code></td>
</tr>
<tr>
<td class="purpose-description" colspan="3">
<span class="purpose-title">Purpose:</span>
<code>true</code> enables smart, angled double quotes.<br>
<small>
<strong>Example:</strong>
<code>"Hugo"</code> renders to
«Hugo» instead of “Hugo”.
</small>
</td>
</tr>
<tr>
<td><code><strong>fractions</strong></code></td>
<td><code>true</code></td>
<td><code>HTML_SMARTYPANTS_FRACTIONS</code></td>
</tr>
<tr>
<td class="purpose-description" colspan="3">
<span class="purpose-title">Purpose:</span>
<code>false</code> disables smart fractions.<br>
<small>
<strong>Example:</strong>
<code>5/12</code> renders to
<sup>5</sup>&frasl;<sub>12</sub>
(<code>&lt;sup&gt;5&lt;/sup&gt;&amp;frasl;&lt;sub&gt;12&lt;/sub&gt;</code>).<br>
<strong>Caveat:</strong>
Even with <code>fractions = false</code>,
Blackfriday still converts
1/2, 1/4 and 3/4 respectively to
½ (<code>&amp;frac12;</code>),
¼ (<code>&amp;frac14;</code>) and
¾ (<code>&amp;frac34;</code>),
but only these three.</small>
</td>
</tr>
<tr>
<td><code><strong>smartDashes</strong></code></td>
<td><code>true</code></td>
<td><code>HTML_SMARTYPANTS_DASHES</code></td>
</tr>
<tr>
<td class="purpose-description" colspan="3">
<span class="purpose-title">Purpose:</span>
<code>false</code> disables smart dashes; i.e., the conversion
of multiple hyphens into en&nbsp;dash or em&nbsp;dash.
If <code>true</code>, its behavior can be modified with the
<code>latexDashes</code> flag below.
</td>
</tr>
<tr>
<td><code><strong>latexDashes</strong></code></td>
<td><code>true</code></td>
<td><code>HTML_SMARTYPANTS_LATEX_DASHES</code></td>
</tr>
<tr>
<td class="purpose-description" colspan="3">
<span class="purpose-title">Purpose:</span>
<code>false</code> disables LaTeX-style smart dashes and
selects conventional smart dashes. Assuming
<code>smartDashes</code> (above), if this is:
<ul>
<li>
<strong><code>true</code>,</strong> then
<code>--</code> is translated into “&ndash;”
(<code>&amp;ndash;</code>), whereas
<code>---</code> is translated into “&mdash;”
(<code>&amp;mdash;</code>).
</li>
<li>
<strong><code>false</code>,</strong> then
<code>--</code> is translated into “&mdash;”
(<code>&amp;mdash;</code>), whereas a
<em>spaced</em> single hyphen between two words
is translated into an en&nbsp;dash&mdash;e.g.,
<code>12 June - 3 July</code> becomes
<code>12 June &amp;ndash; 3 July</code>.
</li>
</ul>
</td>
</tr>
<tr>
<td><code><strong>hrefTargetBlank</strong></code></td>
<td><code>false</code></td>
<td><code>HTML_HREF_TARGET_BLANK</code></td>
</tr>
<tr>
<td class="purpose-description" colspan="3">
<span class="purpose-title">Purpose:</span>
<code>true</code> opens external links in a new window or tab.
</td>
</tr>
<tr>
<td><code><strong>plainIDAnchors</strong></code></td>
<td><code>true</code></td>
<td>
<code>FootnoteAnchorPrefix</code> and
<code>HeaderIDSuffix</code>
</td>
</tr>
<tr>
<td class="purpose-description" colspan="3">
<span class="purpose-title">Purpose:</span>
<code>true</code> renders any header and footnote IDs
without the document ID.<br>
<small>
<strong>Example:</strong>
renders <code>#my-header</code> instead of
<code>#my-header:bec3ed8ba720b9073ab75abcf3ba5d97</code>.
</small>
</td>
</tr>
<tr>
<td><code><strong>extensions</strong></code></td>
<td><code>[]</code></td>
<td><code>EXTENSION_*</code></td>
</tr>
<tr>
<td class="purpose-description" colspan="3">
<span class="purpose-title">Purpose:</span>
Enable one or more of Blackfriday's Markdown extensions
(if they aren't Hugo defaults).<br>
<small>
<strong>Example:</strong> &nbsp;
Include <code>"hardLineBreak"</code>
in the list to enable Blackfriday's
<code>EXTENSION_HARD_LINE_BREAK</code>.
</small>
</td>
</tr>
<tr>
<td><code><strong>extensionsmask</strong></code></td>
<td><code>[]</code></td>
<td><code>EXTENSION_*</code></td>
</tr>
<tr>
<td class="purpose-description" colspan="3">
<span class="purpose-title">Purpose:</span>
Disable one or more of Blackfriday's Markdown extensions
(if they are Hugo defaults).<br>
<small>
<strong>Example:</strong> &nbsp;
Include <code>"autoHeaderIds"</code>
in the list to disable Blackfriday's
<code>EXTENSION_AUTO_HEADER_IDS</code>.
</small>
</td>
</tr>
</tbody>
</table>
**Notes**
* These flags are **case sensitive** (as of Hugo v0.15)!
* These flags must be grouped under the `blackfriday` key
and can be set on **both the site level and the page level**.
Any setting on a page will override the site setting
there. For example:
<table class="table">
<thead>
<tr>
<th>TOML</th>
<th>YAML</th>
</tr>
</thead>
<tbody>
<tr style="vertical-align: top;">
<td style="width: 50%;">
<pre><code>[blackfriday]
angledQuotes = true
fractions = false
plainIDAnchors = true
extensions = ["hardLineBreak"]
</code></pre>
</td>
<td>
<pre><code>blackfriday:
angledQuotes: true
fractions: false
plainIDAnchors: true
extensions:
- hardLineBreak
</code></pre>
</td>
</tr>
</tbody>
</table>
-138
View File
@@ -1,138 +0,0 @@
---
aliases:
- /doc/installing/
lastmod: 2016-01-04
date: 2013-07-01
menu:
main:
parent: getting started
next: /overview/usage
prev: /overview/quickstart
title: Installing Hugo
weight: 20
---
Hugo is written in [Go][] with support for multiple platforms.
The latest release can be found at [Hugo Releases](https://github.com/spf13/hugo/releases).
We currently provide pre-built binaries for
<i class="fa fa-windows"></i>&nbsp;Windows,
<i class="fa fa-linux"></i>&nbsp;Linux,
<i class="fa freebsd-19px"></i>&nbsp;FreeBSD
and <i class="fa fa-apple"></i>&nbsp;OS&nbsp;X (Darwin)
for x64, i386 and ARM architectures.
Hugo may also be compiled from source wherever the Go compiler tool chain can run, e.g. for other operating systems including DragonFly BSD, OpenBSD, Plan&nbsp;9 and Solaris. See http://golang.org/doc/install/source for the full set of supported combinations of target operating systems and compilation architectures.
## Installing Hugo (binary)
Installation is very easy. Simply download the appropriate version for your
platform from [Hugo Releases](https://github.com/spf13/hugo/releases).
Once downloaded it can be run from anywhere. You don't need to install
it into a global location. This works well for shared hosts and other systems
where you don't have a privileged account.
Ideally, you should install it somewhere in your `PATH` for easy use.
`/usr/local/bin` is the most probable location.
On macOS, if you have [Homebrew](http://brew.sh/), installation is even
easier: just run `brew install hugo`.
For a more detailed explanation follow the corresponding installation guides:
- [Installation on macOS]({{< relref "tutorials/installing-on-mac.md" >}})
- [Installation on Windows]({{< relref "tutorials/installing-on-windows.md" >}})
### Installing Pygments (optional)
The Hugo executable has one *optional* external dependency for source code highlighting (Pygments).
If you want to have source code highlighting using the [highlight shortcode](/extras/highlighting/),
you need to install the Python-based Pygments program. The procedure is outlined on the [Pygments home page](http://pygments.org/).
## Upgrading Hugo
Upgrading Hugo is as easy as downloading and replacing the executable youve
placed in your `PATH`.
## Installing Hugo on Linux from native packages
### Arch Linux
You can install Hugo from the [Arch user repository](https://aur.archlinux.org/) on Arch Linux or derivatives such as Manjaro.
sudo pacman -S yaourt
yaourt -S hugo
Be aware that Hugo is built from source. This means that additional tools like [Git](https://git-scm.com/) and [Go](https://golang.org/doc/install) will be installed as well.
### Debian and Ubuntu
Hugo has been included in Debian and Ubuntu since 2016, and thus installing Hugo is as simple as:
sudo apt install hugo
Pros:
* Native Debian/Ubuntu package maintained by Debian Developers
* Pre-installed bash completion script and man pages for best interactive experience
Cons:
* Might not be the latest version, especially if you are using an older stable version (e.g., Ubuntu 16.04&nbsp;LTS).
Until backports and PPA are available, you may consider installing the Hugo snap package to get the latest version of Hugo, as described below.
### Fedora and Red Hat
* https://copr.fedorainfracloud.org/coprs/spf13/Hugo/ (updated to Hugo v0.16)
* https://copr.fedorainfracloud.org/coprs/daftaupe/hugo/ (updated to Hugo v0.19)
See also [this discussion](https://discuss.gohugo.io/t/solved-fedora-copr-repository-out-of-service/2491).
### Snap package for Hugo
In any of the [Linux distributions that support snaps](http://snapcraft.io/docs/core/install):
snap install hugo
> Note: Hugo-as-a-snap can write only inside the users `$HOME` directory—and gvfs-mounted directories owned by the user—because of Snaps confinement and security model.
> More information is also available [in this related GitHub issue](https://github.com/spf13/hugo/issues/3143).
## Installing from source
### Prerequisite tools for downloading and building source code
* [Git](http://git-scm.com/)
* [Go][] 1.8+
* [govendor][]
### Vendored Dependencies
Hugo uses [govendor][] to vendor dependencies, but we don't commit the vendored packages themselves to the Hugo git repository.
Therefore, a simple `go get` is not supported since `go get` is not vendor-aware.
You **must use govendor** to fetch Hugo's dependencies.
### Fetch from GitHub
go get github.com/kardianos/govendor
govendor get github.com/spf13/hugo
`govendor get` will fetch Hugo and all its dependent libraries to
`$HOME/go/src/github.com/spf13/hugo`, and compile everything into a final `hugo`
(or `hugo.exe`) executable, which you will find sitting inside
`$HOME/go/bin/`, all ready to go!
*Windows users: where you see the `$HOME` environment variable above, replace it with `%USERPROFILE%`.*
*Note: For syntax highlighting using the [highlight shortcode](/extras/highlighting/),
you need to install the Python-based [Pygments](http://pygments.org/) program.*
## Contributing
Please see the [contributing guide](/doc/contributing/) if you are interested in
working with the Hugo source or contributing to the project in any way.
[Go]: http://golang.org/
[govendor]: https://github.com/kardianos/govendor
-197
View File
@@ -1,197 +0,0 @@
---
lastmod: 2016-08-14
date: 2013-07-01
linktitle: Introduction
menu:
main:
parent: getting started
next: /overview/quickstart
title: Introduction to Hugo
weight: 5
---
## What is Hugo?
Hugo is a general-purpose website framework. Technically speaking, Hugo is
a static site generator. Unlike other systems which dynamically build a page
every time a visitor requests one, Hugo does the building when you create
your content. Since websites are viewed far more often than they are
edited, Hugo is optimized for website viewing while providing a great
writing experience.
Sites built with Hugo are extremely fast and very secure. Hugo sites can
be hosted anywhere, including [Heroku][], [GoDaddy][], [DreamHost][],
[GitHub Pages][], [Netlify][], [Surge][], [Aerobatic][], [Firebase Hosting][],
[Google Cloud Storage][], [Amazon S3][] and [CloudFront][], and work well
with CDNs. Hugo sites run without dependencies on expensive runtimes
like Ruby, Python or PHP and without dependencies on any databases.
[Heroku]: https://www.heroku.com/
[GoDaddy]: https://www.godaddy.com/
[DreamHost]: http://www.dreamhost.com/
[GitLab]: https://about.gitlab.com
[GitHub Pages]: https://pages.github.com/
[Aerobatic]: https://www.aerobatic.com/
[Firebase Hosting]: https://firebase.google.com/docs/hosting/
[Google Cloud Storage]: http://cloud.google.com/storage/
[Amazon S3]: http://aws.amazon.com/s3/
[CloudFront]: http://aws.amazon.com/cloudfront/ "Amazon CloudFront"
[Surge]: https://surge.sh
[Netlify]: https://www.netlify.com
We think of Hugo as the ideal website creation tool. With nearly instant
build times and the ability to rebuild whenever a change is made, Hugo
provides a very fast feedback loop. This is essential when you are
designing websites, but also very useful when creating content.
## What makes Hugo different?
Web site generators render content into HTML files. Most are "dynamic
site generators." That means the HTTP
server (which is the program running on your website that the user's
browser talks to) runs the generator to create a new HTML file
each and every time a user wants to view a page.
Creating the page dynamically means that the computer hosting
the HTTP server has to have enough memory and CPU to effectively run
the generator around the clock. If not, then the user has to wait
in a queue for the page to be generated.
Nobody wants users to wait longer than needed, so the dynamic site
generators programmed their systems to cache the HTML files. When
a file is cached, a copy of it is temporarily stored on the computer.
It is much faster for the HTTP server to send that copy the next time
the page is requested than it is to generate it from scratch.
Hugo takes caching a step further. All HTML files are rendered on your
computer. You can review the files before you copy them to the computer
hosting the HTTP server. Since the HTML files aren't generated dynamically,
we say that Hugo is a "static site generator."
Not running a web site generator on your HTTP server has many benefits.
The most noticeable is performance - HTTP servers are very good at
sending files. So good that you can effectively serve the same number
of pages with a fraction of the memory and CPU needed for a dynamic site.
Hugo has two components to help you build and test your web site. The
one that you'll probably use most often is the built-in HTTP server.
When you run `hugo server`, Hugo renders all of your content into
HTML files and then runs an HTTP server on your computer so that you
can see what the pages look like.
The second component is used when you're ready to publish your web
site to the computer running your website. Running Hugo without any
actions will rebuild your entire web site using the `baseURL` setting
from your site's configuration file. That's required to have your page
links work properly with most hosting companies.
## How fast is Hugo?
{{% youtube CdiDYZ51a2o %}}
## What does Hugo do?
In technical terms, Hugo takes a source directory of files and
templates and uses these as input to create a complete website.
Hugo boasts the following features:
### General
* Extremely fast build times (~1 ms per page)
* Completely cross platform: Runs on <i class="fa fa-apple"></i>&nbsp;macOS, <i class="fa fa-linux"></i>&nbsp;Linux, <i class="fa fa-windows"></i>&nbsp;Windows, and more!
* Easy [installation](/overview/installing/)
* Render changes [on the fly](/overview/usage/) with [LiveReload](/extras/livereload/) as you develop
* Complete theme support
* Host your site anywhere
### Organization
* Straightforward [organization](/content/organization/)
* Support for [website sections](/content/sections/)
* Completely customizable [URLs](/extras/urls/)
* Support for configurable [taxonomies](/taxonomies/overview/) which includes categories and tags. Create your own custom organization of content
* Ability to [sort content](/content/ordering/) as you desire
* Automatic [table of contents](/extras/toc/) generation
* Dynamic menu creation
* [Pretty URLs](/extras/urls/) support
* [Permalink](/extras/permalinks/) pattern support
* [Aliases](/extras/aliases/) (redirects)
### Content
* Native support for content written in [Markdown](/content/example/)
* Support for other languages through _external helpers_, see [supported formats](/content/supported-formats)
* Support for TOML, YAML and JSON metadata in [frontmatter](/content/front-matter/)
* Completely [customizable homepage](/layout/homepage/)
* Support for multiple [content types](/content/types/)
* Automatic and user defined [summaries](/content/summaries/)
* [Shortcodes](/extras/shortcodes/) to enable rich content inside of Markdown
* ["Minutes to Read"](/layout/variables/) functionality
* ["Wordcount"](/layout/variables/) functionality
### Additional Features
* Integrated [Disqus](https://disqus.com/) comment support
* Integrated [Google Analytics](https://google-analytics.com/) support
* Automatic [RSS](/layout/rss/) creation
* Support for [Go](http://golang.org/pkg/html/template/), [Amber](https://github.com/eknkc/amber) and [Ace](https://github.com/yosssi/ace) HTML templates
* Syntax [highlighting](/extras/highlighting/) powered by [Pygments](http://pygments.org/)
See what's coming next in the [roadmap](/meta/roadmap/).
## Who should use Hugo?
Hugo is for people that prefer writing in a text editor over
a browser.
Hugo is for people who want to hand code their own website without
worrying about setting up complicated runtimes, dependencies and
databases.
Hugo is for people building a blog, company site, portfolio, tumblog,
documentation, single page site or a site with thousands of
pages.
## Why did you write Hugo?
I wrote Hugo ultimately for a few reasons. First, I was disappointed with
WordPress, my then website solution. With it, I couldn't create
content as efficiently as I wanted to.
It rendered slowly. It required me to be online to write
posts: plus its constant security updates and the horror stories of people's
hacked blogs! I hated how content for it was written only in HTML, instead of the much
simpler Markdown. Overall, I felt like WordPress got in my way
much more than it helped me. It kept
me from writing great content.
I looked at the existing static site generators
like [Jekyll][], [Middleman][] and [Nanoc][].
All had complicated installation dependencies and took far longer to render
my blog with its hundreds of posts than I felt was acceptable. I wanted
a framework to be able to give me rapid feedback while making changes to the
templates, and the 5+-minute render times were just too slow. In general,
they were also very blog minded and didn't have the ability to provide
other content types and flexible URLs.
[Jekyll]: http://jekyllrb.com/
[Middleman]: https://middlemanapp.com/
[Nanoc]: http://nanoc.ws/
I wanted to develop a fast and full-featured website framework without any
dependencies. The [Go language][] seemed to have all the features I needed
in a language. I began developing Hugo in Go and fell in love with the
language. I hope you will enjoy using Hugo (and contributing to it) as much
as I have writing it.
&mdash;Steve Francia (@spf13)
[Go language]: http://golang.org/ "The Go Programming Language"
## Next Steps
* [Install Hugo](/overview/installing/)
* [Quick start](/overview/quickstart/)
* [Join the Mailing List](/community/mailing-list/)
* [Star us on GitHub](https://github.com/spf13/hugo)
* [Discussion Forum](http://discuss.gohugo.io/)
-573
View File
@@ -1,573 +0,0 @@
---
lastmod: 2016-10-20
date: 2013-07-01
linktitle: Quickstart
menu:
main:
parent: getting started
next: /overview/installing
prev: /overview/introduction
title: Hugo Quickstart Guide
weight: 10
---
Building a bookshelf
---
In this quickstart, we will build an online bookshelf that will list books and their reviews.
> _Note: This quickstart depends on features introduced in Hugo v0.15. If you have an earlier version of Hugo, you will need to [upgrade](/overview/installing/) before proceeding._
{{% youtube w7Ft2ymGmfc %}}
## Step 1. Install Hugo
Go to [Hugo Releases](https://github.com/spf13/hugo/releases) and download the
appropriate version for your OS and architecture.
Save the main executable as `hugo` (or `hugo.exe` on Windows) somewhere in your `PATH` as we will be using it in the next step.
More complete instructions are available
at [Installing Hugo]({{< relref "overview/installing.md" >}}).
If you're on Windows, this quickstart will assume
you're using [Git Bash](https://git-for-windows.github.io/)
(also known as Git for Windows).
Thus all commands will begin with the Bash prompt character (which is `$`).
Once `hugo` is installed, make sure to run the `help` command to verify `hugo` installation. Below you can see part of the `help` command output for brevity.
```bash
$ hugo help
```
```
hugo is the main command, used to build your Hugo site.
Hugo is a Fast and Flexible Static Site Generator
built with love by spf13 and friends in Go.
Complete documentation is available at http://gohugo.io/.
```
You can check `hugo` version using the command shown below.
```bash
$ hugo version
```
```
Hugo Static Site Generator v0.15 BuildDate: 2015-11-26T11:59:00+05:30
```
## Step 2. Scaffold bookshelf hugo site
Hugo has commands that allows us to quickly scaffold a Hugo managed website. Navigate to a convenient location on your filesystem and create a new Hugo site `bookshelf` by executing the following command.
```bash
$ hugo new site bookshelf
```
Change directory to `bookshelf` and you will see the following directory layout.
```bash
$ tree -a
```
```
.
|-- archetypes
|-- config.toml
|-- content
|-- data
|-- layouts
|-- static
`-- themes
6 directories, 1 file
```
As mentioned in the command output, `bookshelf` directory has 6 sub-directories and 1 file. Let's look at each of them one by one.
* **archetypes**: You can create new content files in Hugo using the `hugo new` command. When you run that command, it adds few configuration properties to the post like date and title. [Archetype]({{< relref "content/archetypes.md" >}}) allows you to define your own configuration properties that will be added to the post front matter whenever `hugo new` command is used.
* **config.toml**: Every website should have a configuration file at the root. By default, the configuration file uses `TOML` format but you can also use `YAML` or `JSON` formats as well. [TOML](https://github.com/toml-lang/toml) is minimal configuration file format that's easy to read due to obvious semantics. The configuration settings mentioned in the `config.toml` are applied to the full site. These configuration settings include `baseURL` and `title` of the website.
* **content**: This is where you will store content of the website. Inside content, you will create sub-directories for different sections. Let's suppose your website has three sections -- `blog`, `article`, and `tutorial` then you will have three different directories for each of them inside the `content` directory. The name of the section i.e. `blog`, `article`, or `tutorial` will be used by Hugo to apply a specific layout applicable to that section.
* **data**: This directory is used to store configuration files that can be
used by Hugo when generating your website.
You can write these files in YAML, JSON, or TOML format.
* **layouts**: The content inside this directory is used to specify how your content will be converted into the static website.
* **static**: This directory is used to store all the static content that your website will need like images, CSS, JavaScript or other static content.
* **themes**: This is where you will create a theme for your site to use. Themes provide the layout and templates that renders content. There's a wide variety of open-source themes available to download and use but you can also create your own if you prefer.
## Step 3. Add content
Let's now add a post to our `bookshelf`. We will use the `hugo new` command to add a post. In January, I read [Good To Great](http://www.amazon.com/Good-Great-Some-Companies-Others/dp/0066620996/) book so we will start with creating a post for it. **Make sure you are inside the `bookshelf` directory.**
```bash
$ hugo new post/good-to-great.md
```
```
/Users/shekhargulati/bookshelf/content/post/good-to-great.md created
```
The above command will create a new directory `post`
inside the `bookshelf/content` directory
and create `good-to-great.md` file inside it.
```bash
$ tree -a content
```
```
content
`-- post
`-- good-to-great.md
1 directory, 1 file
```
The content inside the `good-to-great.md` file looks as shown below.
```
+++
date = "2016-02-14T16:11:58+05:30"
draft = true
title = "good to great"
+++
```
The content inside `+++` is the TOML configuration for the post.
This configuration is called **front matter**.
It enables you to define post configuration along with its content.
By default, each post will have the three configuration properties shown above.
* **date** specifies the date and time at which post was created.
* **draft** specifies that post is not ready for publication yet so it will not be in the generated site.
* **title** specifies title for the post.
Let's add a small review for **Good to Great** book.
```
+++
date = "2016-02-14T16:11:58+05:30"
draft = true
title = "Good to Great Book Review"
+++
I read **Good to Great in January 2016**. An awesome read sharing detailed analysis on how good companies became great.
```
## Step 4. Serve content
Hugo has an inbuilt server that can serve your website content so that you can preview it. You can also use the inbuilt Hugo server in production. To serve content, execute the following command inside the `bookshelf` directory.
```bash
$ hugo server
```
```
0 of 1 draft rendered
0 future content
0 pages created
0 paginator pages created
0 tags created
0 categories created
in 9 ms
Watching for changes in /Users/shekhargulati/bookshelf/{data,content,layouts,static}
Serving pages from memory
Web Server is available at http://localhost:1313/ (bind address 127.0.0.1)
Press Ctrl+C to stop
```
This will start the server on port `1313`.
You can view your blog at http://localhost:1313/.
When you go to the link, you will see nothing.
There are couple of reasons for that:
1. As you can see in the `hugo server` command output, Hugo didn't render the draft. Hugo will only render drafts if you pass the `buildDrafts` flag to the `hugo server` command.
2. We have not specified how Markdown content should be rendered. We have to specify a theme that Hugo can use. We will do that in the next step.
To render drafts, re-run the server with command shown below.
```bash
$ hugo server --buildDrafts
```
```
1 of 1 draft rendered
0 future content
1 pages created
0 paginator pages created
0 tags created
0 categories created
in 6 ms
Watching for changes in /Users/shekhargulati/bookshelf/{data,content,layouts,static}
Serving pages from memory
Web Server is available at http://localhost:1313/ (bind address 127.0.0.1)
Press Ctrl+C to stop
```
If you go to [http://localhost:1313/](http://localhost:1313/),
you still will not see anything as we have not specified a theme that Hugo should use.
## Step 5. Add theme
Themes provide the layout and templates that will be used by Hugo to render your website. There are a lot of Open-source themes available at [https://themes.gohugo.io/](https://themes.gohugo.io/) that you can use.
> **Hugo currently doesnt ship with a `default` theme, allowing the user to pick whichever theme best suits their project.**
Themes should be added in the `themes` directory inside the repository root.
```bash
$ cd themes
```
Now, you can clone one or more themes inside the `themes` directory.
We will use the `robust` theme,
but at a commit (in its history) that works with this quickstart.
```bash
$ git clone https://github.com/dim0627/hugo_theme_robust.git
$ (cd hugo_theme_robust; git checkout b8ce466)
```
Leave the themes folder.
```bash
$ cd ..
```
Start the server again.
```bash
$ hugo server --theme=hugo_theme_robust --buildDrafts
```
```
1 of 1 draft rendered
0 future content
1 pages created
2 paginator pages created
0 tags created
0 categories created
in 10 ms
Watching for changes in /Users/shekhargulati/bookshelf/{data,content,layouts,static,themes}
Serving pages from memory
Web Server is available at http://localhost:1313/ (bind address 127.0.0.1)
Press Ctrl+C to stop
```
> *Note: If Hugo doesn't find the specified theme in the `themes` directory,
it will throw an exception as shown below.*
```
FATAL: 2016/02/14 Unable to find theme Directory: /Users/shekhargulati/bookshelf/themes/robust
```
To view your website, you can go to http://localhost:1313/. You will see as shown below.
![](/img/quickstart/bookshelf-robust-theme.png)
Let's understand the layout of the theme. A theme consists of the following:
* **theme.toml** is the theme configuration file that gives information
about the theme like name and description of theme,
author details, and theme license.
* **images** directory contains two images -- `screenshot.png` and `tn.png`. `screenshot.png` is the image of the list view and `tn.png` is the single post view.
* **layouts** directory contains different views for different content types.
Every content type should have two files `single.html` and `list.html`.
`single.html` is used for rendering a single piece of content.
`list.html` is used to view a list of content items.
For example, you will use `list.html` to view all the posts
that have the `programming` tag.
* **static** directory stores all the static assets used by the template.
Static assets could be JavaScript libraries like jQuery or CSS styles or images,
or any other static content.
This directory will be copied into the final site when rendered.
## Step 6. Use multiple themes
You can very easily test different layouts by switching between different themes.
Let's suppose we want to try out the `bleak` theme.
We clone the `bleak` theme inside the `bookshelf/themes` directory.
```bash
$ git clone https://github.com/Zenithar/hugo-theme-bleak.git
```
Restart the server using `hugo-theme-bleak` as shown below.
```bash
$ hugo server --theme=hugo-theme-bleak --buildDrafts
```
Now, the website will use the `bleak` theme
and will be rendered differently as shown below.
![](/img/quickstart/bookshelf-bleak-theme.png)
## Step 7. Update config.toml and live reloading in action
Restart the server with the `robust` theme, as we will use it in this quickstart.
```bash
$ hugo server --theme=hugo_theme_robust --buildDrafts
```
The website uses the dummy values specified in `bookshelf/config.toml`.
Let's update the configuration.
```toml
baseURL = "http://example.org/"
languageCode = "en-us"
title = "Shekhar Gulati Book Reviews"
[Params]
Author = "Shekhar Gulati"
```
Hugo has inbuilt support for live reloading.
So, as soon as you save your changes it will apply the change
and reload the web page. You will see the changes shown below.
![](/img/quickstart/bookshelf-updated-config.png)
The same is reflected in the Hugo server logs as well.
As soon as you changed the configuration file,
Hugo applied those changes to the affected pages.
```
Config file changed: /Users/shekhargulati/bookshelf/config.toml
1 of 1 draft rendered
0 future content
1 pages created
2 paginator pages created
0 tags created
0 categories created
in 11 ms
```
## Step 8. Customize robust theme
The `robust` theme is a good start towards our online bookshelf but we want to
customize it a bit to meet the look and feel required for the bookshelf.
Hugo makes it very easy to customize themes.
You can also create your themes but we will not do that today.
If you want to create your own theme, then you should refer to
the [Hugo documentation]({{< relref "themes/creation.md" >}}).
The first change that we have to make is to use a different default image
instead of the one used in the theme.
The theme's default image used in both the list and single view page resides
inside `themes/hugo_theme_robust/static/images/default.jpg`.
We can easily override it by creating a simple directory structure
inside the repository's `static` directory.
Create an images directory inside the `bookshelf/static` directory
and copy an image with name `default.jpg` inside it.
We will use the default image shown below.
![](/img/quickstart/default.jpg)
Hugo will sync the changes and reload the website to use new image as shown below.
![](/img/quickstart/bookshelf-new-default-image.png)
Now, we need to change the layout of the index page so that only images are shown instead of the text. The index.html inside the layouts directory of the theme refer to partial `li` that renders the list view shown below.
```html
<article class="li">
<a href="{{ .Permalink }}" class="clearfix">
<div class="image" style="background-image: url({{ $.Site.BaseURL }}images/{{ with .Params.image }}{{ . }}{{ else }}default.jpg{{ end }});"></div>
<div class="detail">
<time>{{ with .Site.Params.DateForm }}{{ $.Date.Format . }}{{ else }}{{ $.Date.Format "Mon, Jan 2, 2006" }}{{ end }}</time>
<h2 class="title">{{ .Title }}</h2>
<div class="summary">{{ .Summary }}</div>
</div>
</a>
</article>
```
Create a new file li.html inside the `bookshelf/layouts/_default` directory. Copy the content shown below into the li.html. We have removed details of the book so that only image is shown.
```html
<article class="li">
<a href="{{ .Permalink }}" class="clearfix">
<div class="image" style="background-image: url({{ $.Site.BaseURL }}images/{{ with .Params.image }}{{ . }}{{ else }}default.jpg{{ end }});"></div>
</a>
</article>
```
Now, the website will be rendered as shown below.
![](/img/quickstart/bookshelf-only-picture.png)
Next, we want to remove information related to theme from the footer.
So, create a new directory `partials` inside `bookshelf/layouts`.
There, create a new file `default_foot.html` with the content copied
from the theme's `layouts/partials/default_foot.html`.
Replace the footer section with the one shown below.
```html
<footer class="site">
<p>{{ with .Site.Copyright | safeHTML }}{{ . }}{{ else }}&copy; {{ $.Site.LastChange.Year }} {{ if isset $.Site.Params "Author" }}{{ $.Site.Params.Author }}{{ else }}{{ .Site.Title }}{{ end }}{{ end }}</p>
<p>Powered by <a href="http://gohugo.io" target="_blank">Hugo</a>,</p>
</footer>
```
We also have to remove the sidebar on the right.
Copy the `index.html` from the theme's `layouts` directory to
the `bookshelf/layouts` directory.
Remove the section related to the sidebar from the HTML:
```html
<div class="col-sm-3">
{{ partial "sidebar.html" . }}
</div>
```
So far we are using the default image but we would like to use the book image so that we can relate to the book. Every book review will define a configuration setting in its front matter. Update the `good-to-great.md` as shown below.
```
+++
date = "2016-02-14T16:11:58+05:30"
draft = true
title = "Good to Great Book Review"
image = "good-to-great.jpg"
+++
I read **Good to Great in January 2016**. An awesome read sharing detailed analysis on how good companies became great. Although this book is about how companies became great but we could apply a lot of the learnings on ourselves. Concepts like level 5 leader, hedgehog concept, the stockdale paradox are equally applicable to individuals.
```
Grab a (legal) image from somewhere, name it `good-to-great.jpg`,
and place it in the `bookshelf/static/images` directory.
After adding few more books to our shelf, the shelf appears as shown below.
These are a few of the books that I have read within the last year.
![](/img/quickstart/bookshelf.png)
## Step 9. Make posts public
So far all the posts that we have written are in draft status.
To make a draft public, you can either run a command
or manually change the draft status in the post to `false`.
```bash
$ hugo undraft content/post/good-to-great.md
```
Now, you can start the server without the `buildDrafts` option.
```
$ hugo server --theme=hugo_theme_robust
```
## Step 10. Integrate Disqus
Disqus allows you to integrate comments in your static blog. To enable Disqus, you just have to set `disqusShortname` in the config.toml as shown below.
```
[Params]
Author = "Shekhar Gulati"
disqusShortname = <your disqus shortname>
```
Now, commenting will be enabled in your blog.
![](/img/quickstart/bookshelf-disqus.png)
## Step 11. Generate website
To generate Hugo website source you can use
to deploy your website on GitHub pages,
first edit `bookshelf/config.toml`, changing the `baseURL` line to:
```
baseURL = "https://<your GitHub username>.github.io/bookshelf/"
```
Then type the following command.
```bash
$ hugo --theme=hugo_theme_robust
```
```
0 draft content
0 future content
5 pages created
2 paginator pages created
0 tags created
0 categories created
in 17 ms
```
After you run the `hugo` command, a `bookshelf/public` directory
will be created containing the generated website source.
BTW (in case you tried),
the website isn't properly accessible via the `file:///` protocol.
## Step 12. Deploy bookshelf on GitHub pages
Let's version control your bookshelf:
```bash
$ git init
$ echo "/public/" >> .gitignore
$ echo "/themes/" >> .gitignore
$ git add --all
$ git commit -m "Initial commit"
```
Now the Git repositories under `bookshelf/themes`
won't conflict with your `bookshelf` repository,
and neither will a Git repository in `bookshelf/public`.
Create a new repository on GitHub named `bookshelf` (without a README).
Once that's done, create a new Git repository on your local system
in `bookshelf/public` and add remote:
```bash
$ cd public
$ git init
$ git remote add origin git@github.com:<github-username>/bookshelf.git
```
There, create and check out a new branch `gh-pages`.
```bash
$ git checkout -b gh-pages
Switched to a new branch 'gh-pages'
```
Add all the files (within `bookshelf/public`) to the index,
commit them, and push the changes to GitHub.
```bash
$ git add --all
$ git commit -m "bookshelf added"
$ git push -f origin gh-pages
```
In couple of minutes, your website will be live
at `https://<github-username>.github.io/bookshelf/`.
Anytime, you can regenerate your site with:
```bash
$ (cd ..; hugo --theme=hugo_theme_robust)
$ git add --all
$ git commit -m "<some change message>"
$ git push -f origin gh-pages
```
----
This quickstart was originally written by [Shekhar Gulati](https://twitter.com/shekhargulati) in his [52 Technologies in 2016](https://github.com/shekhargulati/52-technologies-in-2016) blog series.
-126
View File
@@ -1,126 +0,0 @@
---
aliases:
- /doc/source-directory/
lastmod: 2015-02-09
date: 2013-07-01
menu:
main:
parent: getting started
next: /content/organization
notoc: true
prev: /overview/configuration
title: Source Organization
weight: 50
---
Hugo takes a single directory and uses it as the input for creating a complete
website.
The top level of a source directory will typically have the following elements:
▸ archetypes/
▸ content/
▸ data/
▸ i18n/
▸ layouts/
▸ static/
▸ themes/
config.toml
Learn more about the different directories and what their purpose is:
* [config]({{< relref "overview/configuration.md" >}})
* [data]({{< relref "extras/datafiles.md" >}})
* [i18n]({{< relref "content/multilingual.md#translation-of-strings" >}})
* [archetypes]({{< relref "content/archetypes.md" >}})
* [content]({{< relref "content/organization.md" >}})
* [layouts]({{< relref "templates/overview.md" >}})
* [static]({{< relref "themes/creation.md#static" >}})
* [themes]({{< relref "themes/overview.md" >}})
## Example
An example directory may look like:
.
├── config.toml
├── archetypes
| └── default.md
├── content
| ├── post
| | ├── firstpost.md
| | └── secondpost.md
| └── quote
| | ├── first.md
| | └── second.md
├── data
├── i18n
├── layouts
| ├── _default
| | ├── single.html
| | └── list.html
| ├── partials
| | ├── header.html
| | └── footer.html
| ├── taxonomy
| | ├── category.html
| | ├── post.html
| | ├── quote.html
| | └── tag.html
| ├── post
| | ├── li.html
| | ├── single.html
| | └── summary.html
| ├── quote
| | ├── li.html
| | ├── single.html
| | └── summary.html
| ├── shortcodes
| | ├── img.html
| | ├── vimeo.html
| | └── youtube.html
| ├── index.html
| └── sitemap.xml
├── themes
| ├── hyde
| └── doc
└── static
├── css
└── js
This directory structure tells us a lot about this site:
1. The website intends to have two different types of content: *posts* and *quotes*.
2. It will also apply two different taxonomies to that content: *categories* and *tags*.
3. It will be displaying content in 3 different views: a list, a summary and a full page view.
## Content for home page and other list pages
Since Hugo 0.18, "everything" is a `Page` that can have content and metadata, like `.Params`, attached to it -- and share the same set of [page variables](/templates/variables/).
To add content and frontmatter to the home page, a section, a taxonomy or a taxonomy terms listing, add a markdown file with the base name `_index` on the relevant place on the file system.
For the default Markdown content, the filename will be `_index.md`.
Se the example directory tree below.
**Note that you don't have to create `_index` file for every section, taxonomy and similar, a default page will be created if not present, but with no content and default values for `.Title` etc.**
```bash
└── content
├── _index.md
├── categories
│   ├── _index.md
│   └── photo
│   └── _index.md
├── post
│   ├── _index.md
│   └── firstpost.md
└── tags
├── _index.md
└── hugo
└── _index.md
```

Some files were not shown because too many files have changed in this diff Show More