mirror of
https://github.com/gohugoio/hugo.git
synced 2026-09-01 03:02:38 +00:00
Add missing toc to certain content files
This commit is contained in:
@@ -14,36 +14,37 @@ toc: false
|
||||
needsreview: true
|
||||
---
|
||||
|
||||
When using Hugo with [GitHub Pages](http://pages.github.com/), you can provide
|
||||
your own template for a [custom 404 error page](https://help.github.com/articles/custom-404-pages/)
|
||||
by creating a 404.html template file in your `/layouts` folder.
|
||||
When Hugo generates your site, the `404.html` file will be placed in the root.
|
||||
When using Hugo with [GitHub Pages](http://pages.github.com/), you can provide your own template for a [custom 404 error page](https://help.github.com/articles/custom-404-pages/) by creating a 404.html template file in your `/layouts` folder. When Hugo generates your site, the `404.html` file will be placed in the root.
|
||||
|
||||
404 pages will have all the regular [page
|
||||
variables](/layout/variables/) available to use in the templates.
|
||||
404 pages will have all the regular [page variables][pagevars] available to use in the templates.
|
||||
|
||||
In addition to the standard page variables, the 404 page has access to
|
||||
all site content accessible from `.Data.Pages`.
|
||||
In addition to the standard page variables, the 404 page has access to all site content accessible from `.Data.Pages`.
|
||||
|
||||
▾ layouts/
|
||||
404.html
|
||||
```bash
|
||||
▾ layouts/
|
||||
404.html
|
||||
```
|
||||
|
||||
## 404.html
|
||||
|
||||
This is a basic example of a 404.html template:
|
||||
|
||||
{{ partial "header.html" . }}
|
||||
{{ partial "subheader.html" . }}
|
||||
{{% input "404.html"%}}
|
||||
```html
|
||||
{{ partial "header.html" . }}
|
||||
{{ partial "subheader.html" . }}
|
||||
|
||||
<section id="main">
|
||||
<div>
|
||||
<h1 id="title">{{ .Title }}</h1>
|
||||
</div>
|
||||
</section>
|
||||
<section id="main">
|
||||
<div>
|
||||
<h1 id="title">{{ .Title }}</h1>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{{ partial "footer.html" . }}
|
||||
{{ partial "footer.html" . }}
|
||||
```
|
||||
{{% /input %}}
|
||||
|
||||
### Automatic Loading
|
||||
## Automatic Loading
|
||||
|
||||
Your 404.html file can be set to load automatically when a visitor enters a mistaken URL path, dependent upon the web serving environment you are using. For example:
|
||||
|
||||
@@ -52,3 +53,5 @@ Your 404.html file can be set to load automatically when a visitor enters a mist
|
||||
* _Nginx_ - you might specify `error_page 404 = /404.html;` in your `nginx.conf` file.
|
||||
* _Amazon AWS S3_ - when setting a bucket up for static web serving, you can specify the error file.
|
||||
* _Caddy Server_ - using `errors { 404 /404.html }`. [Details here](https://caddyserver.com/docs/errors)
|
||||
|
||||
[pagevars]: /variables-and-params/page-variables/
|
||||
@@ -10,7 +10,7 @@ tags: [data,dynamic,csv,json,toml,yaml]
|
||||
weight: 80
|
||||
draft: false
|
||||
aliases: [/extras/datafiles/,/extras/datadrivencontent/,/doc/datafiles/]
|
||||
toc: false
|
||||
toc: true
|
||||
needsreview: true
|
||||
---
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ tags: [lists,sections,pagination]
|
||||
weight: 140
|
||||
draft: false
|
||||
aliases: [/extras/pagination,/doc/pagination/]
|
||||
toc: false
|
||||
toc: true
|
||||
needsreview: true
|
||||
---
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ categories: [templates]
|
||||
weight: 150
|
||||
draft: false
|
||||
aliases: [/templates/rss/]
|
||||
toc: false
|
||||
toc: true
|
||||
needsreview: true
|
||||
---
|
||||
|
||||
@@ -22,7 +22,8 @@ Like all other templates, you can use a single RSS template to generate all of y
|
||||
|
||||
RSS pages are of the type `Page` and have all the [page variables](/layout/variables/) available to use in the templates.
|
||||
|
||||
## Which Template will be rendered?
|
||||
## Which Template will be Rendered?
|
||||
|
||||
Hugo uses a set of rules to figure out which template to use when rendering a specific page.
|
||||
|
||||
Hugo will use the following prioritized list. If a file isn’t present, then the next one in the list will be used. This enables you to craft specific layouts when you want to without creating more templates than necessary. For most sites only the `\_default` file at the end of the list will be needed.
|
||||
@@ -49,51 +50,55 @@ Hugo will use the following prioritized list. If a file isn’t present, then th
|
||||
* /themes/`THEME`/layouts/\_default/rss.xml
|
||||
* [Embedded rss.xml](#the-embedded-rss-xml:eceb479b7b3b2077408a2878a29e1320)
|
||||
|
||||
|
||||
## Configuring RSS
|
||||
|
||||
If the following values are specified in the site’s config file (`config.toml`), then they will be included in the RSS output. Example values are provided.
|
||||
|
||||
languageCode = "en-us"
|
||||
copyright = "This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License."
|
||||
```toml
|
||||
languageCode = "en-us"
|
||||
copyright = "This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License."
|
||||
|
||||
[author]
|
||||
name = "My Name Here"
|
||||
[author]
|
||||
name = "My Name Here"
|
||||
```
|
||||
|
||||
|
||||
## The Embedded rss.xml
|
||||
This is the default RSS template that ships with Hugo. It adheres to the [RSS 2.0 Specification][RSS 2.0].
|
||||
|
||||
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
|
||||
<channel>
|
||||
<title>{{ with .Title }}{{.}} on {{ end }}{{ .Site.Title }}</title>
|
||||
<link>{{ .Permalink }}</link>
|
||||
<description>Recent content {{ with .Title }}in {{.}} {{ end }}on {{ .Site.Title }}</description>
|
||||
<generator>Hugo -- gohugo.io</generator>{{ with .Site.LanguageCode }}
|
||||
<language>{{.}}</language>{{end}}{{ with .Site.Author.email }}
|
||||
<managingEditor>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</managingEditor>{{end}}{{ with .Site.Author.email }}
|
||||
<webMaster>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</webMaster>{{end}}{{ with .Site.Copyright }}
|
||||
<copyright>{{.}}</copyright>{{end}}{{ if not .Date.IsZero }}
|
||||
<lastBuildDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</lastBuildDate>{{ end }}
|
||||
<atom:link href="{{.URL}}" rel="self" type="application/rss+xml" />
|
||||
{{ range first 15 .Data.Pages }}
|
||||
<item>
|
||||
<title>{{ .Title }}</title>
|
||||
<link>{{ .Permalink }}</link>
|
||||
<pubDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate>
|
||||
{{ with .Site.Author.email }}<author>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</author>{{end}}
|
||||
<guid>{{ .Permalink }}</guid>
|
||||
<description>{{ .Content | html }}</description>
|
||||
</item>
|
||||
{{ end }}
|
||||
</channel>
|
||||
</rss>
|
||||
```xml
|
||||
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
|
||||
<channel>
|
||||
<title>{{ with .Title }}{{.}} on {{ end }}{{ .Site.Title }}</title>
|
||||
<link>{{ .Permalink }}</link>
|
||||
<description>Recent content {{ with .Title }}in {{.}} {{ end }}on {{ .Site.Title }}</description>
|
||||
<generator>Hugo -- gohugo.io</generator>{{ with .Site.LanguageCode }}
|
||||
<language>{{.}}</language>{{end}}{{ with .Site.Author.email }}
|
||||
<managingEditor>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</managingEditor>{{end}}{{ with .Site.Author.email }}
|
||||
<webMaster>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</webMaster>{{end}}{{ with .Site.Copyright }}
|
||||
<copyright>{{.}}</copyright>{{end}}{{ if not .Date.IsZero }}
|
||||
<lastBuildDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</lastBuildDate>{{ end }}
|
||||
<atom:link href="{{.URL}}" rel="self" type="application/rss+xml" />
|
||||
{{ range first 15 .Data.Pages }}
|
||||
<item>
|
||||
<title>{{ .Title }}</title>
|
||||
<link>{{ .Permalink }}</link>
|
||||
<pubDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate>
|
||||
{{ with .Site.Author.email }}<author>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</author>{{end}}
|
||||
<guid>{{ .Permalink }}</guid>
|
||||
<description>{{ .Content | html }}</description>
|
||||
</item>
|
||||
{{ end }}
|
||||
</channel>
|
||||
</rss>
|
||||
```
|
||||
|
||||
**Important**: _Hugo will automatically add the following header line to this file on render… please don't include this in the template as it's not valid HTML._
|
||||
|
||||
```css
|
||||
{{% warning "XML Header" %}}
|
||||
Hugo will automatically add the following header line to this file on render…please don't include this in the template as it's not valid HTML.
|
||||
```xml
|
||||
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
|
||||
```
|
||||
{{% /warning %}}
|
||||
|
||||
## Referencing your RSS Feed in `<head>`
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ Hugo assumes your content section and content type are the same unless you tell
|
||||
|
||||
This is why #1 and #3 come before #2 and #4, respectively. Values in angle brackets (`<>`) are variables.
|
||||
|
||||
### Lookup Order for Single Page Templates
|
||||
## Lookup Order for Single Page Templates
|
||||
|
||||
1. `/layouts/<TYPE>/<LAYOUT>.html`
|
||||
2. `/layouts/<SECTION>/<LAYOUT>.html`
|
||||
@@ -44,7 +44,7 @@ This is why #1 and #3 come before #2 and #4, respectively. Values in angle brack
|
||||
9. `/themes/<THEME>/layouts/<SECTION>/single.html`
|
||||
10. `/themes/<THEME>/layouts/_default/single.html`
|
||||
|
||||
### Single Page Template Lookup Order Examples
|
||||
## Single Page Lookup Examples
|
||||
|
||||
The following examples assume two things:
|
||||
|
||||
@@ -85,7 +85,7 @@ Now we can look at the front matter for the three single-page content (i.e.`.md`
|
||||
`_index.md` may seem like a single page of content but is actually a specific `kind` in Hugo. Whereas `my-first-post.md`, `my-second-post.md`, and `my-first-event.md` are all of kind `page`, all `_index.md` files in a Hugo project are of kind `section` and therefore do not submit themselves to the ***single*** page template lookup. Instead, `events/_index.md` will render according to the lookup order of [section and list templates](templates/section-and-list-templates/).
|
||||
{{% /note %}}
|
||||
|
||||
#### `my-first-post.md`
|
||||
### `my-first-post.md`
|
||||
|
||||
{{% input "content/posts/my-first-post.md" %}}
|
||||
```yaml
|
||||
@@ -113,7 +113,7 @@ When it comes time for Hugo to render the content to the page, it will go throug
|
||||
|
||||
Notice the term `UNSPECIFIED` rather than `UNDEFINED`. If you don't tell Hugo the specific type and layout, it makes inferences based on sane defaults. `my-first-post.md` does not specify a content `type` in its front matter. Therefore, Hugo assumes the content `type` and `section` (i.e. `posts`, which is defined by file location) are one in the same. The `layout` also is not specified in the front matter. Hugo assumes that `my-first-post.md`, which is of type `page` and a *single* piece of content, should default to the next occurrence of a `single.html` template in the lookup.
|
||||
|
||||
#### `my-second-post.md`
|
||||
### `my-second-post.md`
|
||||
|
||||
{{% input "content/posts/my-second-post.md" %}}
|
||||
```yaml
|
||||
@@ -147,7 +147,7 @@ In the case of `my-second-post.md`, the front matter specifies the content `type
|
||||
Notice that the directory for the template for `my-second-post.md` is `review` and not `reviews`. This is because *type is always singular*.
|
||||
{{% /note%}}
|
||||
|
||||
#### `my-first-event.md`
|
||||
### `my-first-event.md`
|
||||
|
||||
{{% input "content/events/my-first-event.md" %}}
|
||||
```yaml
|
||||
@@ -177,7 +177,7 @@ Here is the lookup order for `my-first-event.md`:
|
||||
`my-first-event.md` is significant because it demonstrates the role of the lookup order in Hugo themes. Both the root project directory *and* the `mytheme` themes directory have a file at `_default/single.html`. Understanding this order allows you to [customize Hugo themes](/themes/customizing-a-theme/) by creating template files with identical names in your project directory that step in front of theme template files in the lookup. This allows you to customize the look and feel of your website while maintaining compatibility with the theme's upstream.
|
||||
{{% /note %}}
|
||||
|
||||
## Single-Page Template Files Examples
|
||||
## Single Page Template Files Examples
|
||||
|
||||
Content pages are of the type `page` and will therefore have all the [page variables][] and [site variables][] available to use in their templates.
|
||||
|
||||
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
@@ -41,6 +41,6 @@ docsearch({
|
||||
apiKey: '41fdb7fafd9b009498ef9ab6d3fb1886',
|
||||
indexName: 'hugodocsconcept',
|
||||
inputSelector: '#search-input',
|
||||
debug: false // Set debug to true if you want to inspect the dropdown
|
||||
debug: true // Set debug to true if you want to inspect the dropdown
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -18,14 +18,14 @@
|
||||
</div>
|
||||
<div class="showcase-meta">
|
||||
<div class="showcase-links">
|
||||
{{with .Params.sitelink}}
|
||||
<span class="showcase-title"><a href="{{.}}" target="_blank">{{$title}}</a></span>
|
||||
{{else}}
|
||||
<h3>{{$title}}</h3>
|
||||
{{end}}
|
||||
{{with .Params.sourcelink}}
|
||||
<span class="showcase-source"><a href="{{.}}" target="_blank"><i class="icon-code"></i>Source</a></span>
|
||||
{{end}}
|
||||
{{with .Params.sitelink}}
|
||||
<span class="showcase-title"><a href="{{.}}" target="_blank">{{$title}}</a></span>
|
||||
{{else}}
|
||||
<h3>{{$title}}</h3>
|
||||
{{end}}
|
||||
{{with .Params.sourcelink}}
|
||||
<span class="showcase-source"><a href="{{.}}" target="_blank"><i class="icon-code"></i>Source</a></span>
|
||||
{{end}}
|
||||
</div>
|
||||
{{- with .Params.tags -}}
|
||||
<ul class="tags showcase-tags">
|
||||
|
||||
@@ -64,6 +64,12 @@ main.showcase-list {
|
||||
font-size: .8em;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
.showcase-title {
|
||||
font-weight:bold;
|
||||
a {
|
||||
font-weight:bold;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user