mirror of
https://github.com/gohugoio/hugo.git
synced 2026-08-24 23:38:53 +00:00
Fix spacing issue caused by command line template
This commit is contained in:
@@ -27,8 +27,9 @@ Not running a website generator on your HTTP server has many benefits. The most
|
||||
* ["An Introduction to Static Site Generators", David Walsh][]
|
||||
* ["Static Site Generators", O-Reilly][]
|
||||
* [StaticGen: Top Open-Source Static Site Generators (GitHub Stars)][]
|
||||
* ["Top 10 Static Website Generators," Netlify blog][]
|
||||
* ["Top 10 Static Website Generators", Netlify blog][]
|
||||
* ["Hugo vs. Wordpress page load speed comparison: Hugo leaves WordPress in its dust", GettingThingsTech][hugovwordpress]
|
||||
* ["The Resurgence of Static", dotCMS][dotcms]
|
||||
|
||||
|
||||
["An Introduction to Static Site Generators", David Walsh]: https://davidwalsh.name/introduction-static-site-generators
|
||||
@@ -36,3 +37,4 @@ Not running a website generator on your HTTP server has many benefits. The most
|
||||
["Top 10 Static Website Generators," Netlify blog]: https://www.netlify.com/blog/2016/05/02/top-ten-static-website-generators/
|
||||
[hugovwordpress]: https://gettingthingstech.com/hugo-vs.-wordpress-page-load-speed-comparison-hugo-leaves-wordpress-in-its-dust/
|
||||
[StaticGen: Top Open-Source Static Site Generators (GitHub Stars)]: https://www.staticgen.com/
|
||||
[dotcms]: https://dotcms.com/blog/post/the-resurgence-of-static
|
||||
|
||||
@@ -218,6 +218,7 @@ This is no longer a site navigation link and is instead a button along with "Fil
|
||||
|
||||
* Reworked considerably. Page titles have all been changed to reflect their obvious connection to *templating*.
|
||||
* "Lookup order" page added. The order of the template pages in the main navigation is now such that it could be seen as a sequence of pages showing how to learn templating. Hence the primer, lookup order, and base templates as the first three pages in this section.
|
||||
* Shortcodes, menus, pagination
|
||||
|
||||
### Taxonomies
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
---
|
||||
title: Content Types
|
||||
linktitle: Content Types
|
||||
description:
|
||||
description: Hugo provides support for sites with multiple content types and assumes your site will be organized into sections, where each section will use the corresponding type.
|
||||
date: 2017-02-01
|
||||
publishdate: 2017-02-01
|
||||
lastmod: 2017-02-01
|
||||
@@ -16,9 +16,13 @@ needsreview: true
|
||||
|
||||
Hugo provides full support for sites with multiple content types. A **content type** can have a unique set of metadata (i.e., [front matter][]) or customized [template][] and can be created by the `hugo new` command via content [archetypes][].
|
||||
|
||||
{{% note "Hugo Content Type != MIME Type" %}}
|
||||
It's important to distinguish the difference between Hugo's content types and [MIME types](https://en.wikipedia.org/wiki/Media_type). In Hugo, a content type is a piece of information (i.e. content item) that has multiple attributes (i.e. front matter/metadata and a content block). It is not necessarily related to a file format or file extension.
|
||||
{{% /note %}}
|
||||
|
||||
A good example of when multiple types are needed is to look at [Tumblr][]. A piece of "content" could be a photo, quote or post, each with different meta data and rendered differently.
|
||||
|
||||
## Assigning a content type
|
||||
## Assigning a Content Type
|
||||
|
||||
Hugo assumes that your site will be organized into [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.
|
||||
|
||||
@@ -36,7 +40,7 @@ Creating a new content type is easy in Hugo. You simply provide the templates an
|
||||
Remember, all of the following are *optional*. If you do not specifically declare content types in your front matter or develop specific layouts for content types, Hugo is smart enough to infer the content type from the file path and content section (see [content sections](/content-management/sections/)).
|
||||
{{% /note %}}
|
||||
|
||||
### Create Type Layout Directory
|
||||
### Create a Type Layout Directory
|
||||
|
||||
Create a directory with the name of the type in `/layouts`. Type is always singular; e.g., even if your content directory is `content/posts`, create `/layouts/post/`.
|
||||
|
||||
@@ -52,7 +56,7 @@ Create a file called `post.html` inside the section lists template directory, `/
|
||||
|
||||
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 section contents][]. Hugo makes no assumptions 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 Corresponding Archetype
|
||||
|
||||
Create an archetype file for your type at `yourtype.md` in the `/archetypes` directory; e.g., `/archetypes/post.md`.
|
||||
|
||||
|
||||
@@ -1,24 +1,30 @@
|
||||
---
|
||||
title: md5
|
||||
linktitle:
|
||||
description:
|
||||
linktitle: md5
|
||||
description: hashes the given input and returns its MD5 checksum.
|
||||
godocref:
|
||||
date: 2017-02-01
|
||||
publishdate: 2017-02-01
|
||||
lastmod: 2017-02-01
|
||||
tags: []
|
||||
categories: [functions]
|
||||
toc: false
|
||||
tags: []
|
||||
signature:
|
||||
workson: []
|
||||
hugoversion:
|
||||
relatedfuncs: []
|
||||
deprecated: false
|
||||
draft: false
|
||||
aliases: []
|
||||
---
|
||||
|
||||
## Example
|
||||
The `md5` function hashes the given input and returns its MD5 checksum.
|
||||
|
||||
## Advanced Example
|
||||
```html
|
||||
{{ md5 "Hello world, gophers!" }}
|
||||
<!-- returns the string "b3029f756f98f79e7f1b7f1d1f0dd53b" -->
|
||||
```
|
||||
|
||||
This can be useful if you want to use [Gravatar](https://en.gravatar.com/) for generating a unique avatar:
|
||||
|
||||
```html
|
||||
<img src="https://www.gravatar.com/avatar/{{ md5 "your@email.com" }}?s=100&d=identicon">
|
||||
```
|
||||
|
||||
@@ -11,7 +11,6 @@ weight: 50
|
||||
draft: false
|
||||
needsreview: true
|
||||
aliases: [/overview/source-directory/]
|
||||
notesforauthors:
|
||||
---
|
||||
|
||||
<!-- copied from old overview/source-directory -->
|
||||
|
||||
@@ -54,7 +54,7 @@ For more detailed explanations, read the installation guides that follow for [Wi
|
||||
* [Git][installgit]
|
||||
* [Go 1.5+][installgo]
|
||||
|
||||
#### Get directly from GitHub
|
||||
#### Get Hugo Directly from GitHub
|
||||
|
||||
```sh
|
||||
export GOPATH=$HOME/go
|
||||
@@ -303,7 +303,7 @@ The following aims to be a complete guide to installing Hugo on your Windows PC.
|
||||
2. You will use `C:\Hugo\Sites` as the starting point for your site.
|
||||
3. You will use `C:\Hugo\bin` to store executable files.
|
||||
|
||||
### Setup Your Directories
|
||||
### Set up Your Directories
|
||||
|
||||
You'll need a place to store the Hugo executable, your content (the files that you build), and the generated files (the HTML that Hugo builds for you).
|
||||
|
||||
@@ -326,7 +326,7 @@ You'll need a place to store the Hugo executable, your content (the files that y
|
||||
3. Find the Windows files near the bottom (they're in alphabetical order, so Windows is last) – download either the 32-bit or 64-bit file depending on whether you have 32-bit or 64-bit Windows. (If you don't know, [see here](https://esupport.trendmicro.com/en-us/home/pages/technical-support/1038680.aspx).)
|
||||
4. Move the ZIP file into your `C:\Hugo\bin` folder.
|
||||
5. Double-click on the ZIP file and extract its contents. Be sure to extract the contents into the same `C:\Hugo\bin` folder – Windows will do this by default unless you tell it to extract somewhere else.
|
||||
6. You should now have three new files: hugo executable (example: hugo_0.18_windows_amd64.exe), license.md, and readme.md. (you can delete the ZIP download now.). Rename that hugo executable (hugo_hugo-version_platform_arch.exe) to hugo.exe for ease of use.
|
||||
6. You should now have three new files: hugo executable (e.g. `hugo_0.18_windows_amd64.exe`), `license.md`, and `readme.md`. (You can delete the ZIP download now.) Rename that hugo executable (`hugo_hugo-version_platform_arch.exe`) to `hugo.exe` for ease of use.
|
||||
7. Now add Hugo to your Windows PATH settings:
|
||||
|
||||
##### For Windows 10 users:
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
---
|
||||
title: Hosting on Netlify
|
||||
linktitle: Hosting on Netlify
|
||||
description:
|
||||
date: 2017-02-01
|
||||
publishdate: 2017-02-01
|
||||
lastmod: 2017-02-25
|
||||
categories: [hosting and deployment]
|
||||
tags: [netlify,hosting,deployment]
|
||||
authors: [Ryan Watters]
|
||||
weight: 20
|
||||
draft: false
|
||||
aliases: []
|
||||
toc: true
|
||||
needsreview:
|
||||
notesforauthors:
|
||||
---
|
||||
@@ -11,7 +11,6 @@ weight: 30
|
||||
draft: false
|
||||
aliases: [/layout/homepage/,/templates/homepage/]
|
||||
toc: false
|
||||
needsreview: true
|
||||
---
|
||||
|
||||
The homepage of a website is often formatted differently than the other pages. In Hugo you can define your own homepage template.
|
||||
@@ -19,7 +18,7 @@ The homepage of a website is often formatted differently than the other pages. I
|
||||
Homepage is a `Page` and therefore has all the [page variables][pagevars] and [site variables][sitevars] available for use.
|
||||
|
||||
{{% note "The Only Required Template" %}}
|
||||
The homepage template is the *only* required template for building a site and useful when bootstrapping a new site and template. It is also the only required template if you are developing a single page site.
|
||||
The homepage template is the *only* required template for building a site and therefore useful when bootstrapping a new site and template. It is also the only required template if you are developing a single-page website.
|
||||
{{% /note %}}
|
||||
|
||||
## Homepage Template Lookup Order
|
||||
|
||||
@@ -11,26 +11,18 @@ weight: 90
|
||||
draft: false
|
||||
aliases: [/templates/partials/,/layout/chrome/,/extras/analytics/]
|
||||
toc: true
|
||||
notesforauthors:
|
||||
needsreview: true
|
||||
---
|
||||
|
||||
## Partials vs Templates
|
||||
|
||||
In practice, it's very convenient to split out common template portions into a
|
||||
partial template that can be included anywhere. As you create the rest of your
|
||||
templates, you will include templates from the `/layouts/partials/` directory
|
||||
or from arbitrary partial subdirectories like `/layouts/partials/post/tag/`.
|
||||
In practice, it's very convenient to split out common template portions into a partial template that can be included anywhere. As you create the rest of your templates, you will include templates from the `/layouts/partials/` directory or from arbitrary partial subdirectories like `/layouts/partials/post/tag/`.
|
||||
|
||||
Partials are especially important for [themes][] because they give theme users an opportunity to [overwrite just a small portion of a theme][customize] while maintaining compatibility with the theme's upstream.
|
||||
|
||||
Theme developers may want to include a few partials with empty HTML
|
||||
files in the theme just so end users have an easy place to inject their
|
||||
customized content.
|
||||
Theme developers may want to include a few partials with empty HTML files in the theme just so end users have an easy place to inject their customized content.
|
||||
|
||||
I've found it helpful to include a header and footer template in
|
||||
partials so I can include those in all the full page layouts. There is
|
||||
nothing special about header.html and footer.html other than they seem
|
||||
like good names to use for inclusion in your other templates.
|
||||
I've found it helpful to include a header and footer template in partials so I can include those in all the full page layouts. There is nothing special about header.html and footer.html other than they seem like good names to use for inclusion in your other templates.
|
||||
|
||||
```bash
|
||||
▾ layouts/
|
||||
@@ -41,17 +33,13 @@ like good names to use for inclusion in your other templates.
|
||||
|
||||
## Partial vs Template
|
||||
|
||||
Version v0.12 of Hugo introduced the `partial` call inside the template system.
|
||||
This is a change to the way partials were handled previously inside the
|
||||
template system. In earlier versions, Hugo didn’t treat partials specially, and
|
||||
you could include a partial template with the `template` call in the standard
|
||||
template language.
|
||||
Version v0.12 of Hugo introduced the `partial` call inside the template system. This is a change to the way partials were handled previously inside the template system. In earlier versions, Hugo didn’t treat partials specially, and you could include a partial template with the `template` call in the standard template language.
|
||||
|
||||
With the addition of the theme system in v0.11, it became apparent that a theme & override-aware partial was needed.
|
||||
|
||||
When using Hugo v0.12 and above, please use the `partial` call (and leave out the “partial/” path). The old approach would still work, but wouldn’t benefit from the ability to have users override the partial theme file with local layouts.
|
||||
|
||||
## Example header.html
|
||||
## Example `header.html`
|
||||
|
||||
This header template is used for [spf13.com](http://spf13.com/):
|
||||
|
||||
@@ -75,7 +63,7 @@ This header template is used for [spf13.com](http://spf13.com/):
|
||||
```
|
||||
{{% /code %}}
|
||||
|
||||
## Example footer.html
|
||||
## Example `footer.html`
|
||||
|
||||
This footer template is used for [spf13.com](http://spf13.com/):
|
||||
|
||||
@@ -120,7 +108,7 @@ Note that the subdirectories you create under /layouts/partials can be named wha
|
||||
|
||||
For more examples of referencing these templates, see [single content templates](/templates/content/), [list templates](/templates/list/) and [homepage templates](/templates/homepage/).
|
||||
|
||||
## Variable scoping
|
||||
## Variable Scoping
|
||||
|
||||
As you might have noticed, `partial` calls receive two parameters.
|
||||
|
||||
|
||||
@@ -334,26 +334,9 @@ within each group in alphabetical order by title.
|
||||
{{ end }}
|
||||
```
|
||||
|
||||
## Filtering and Limiting Content
|
||||
## Filtering and Limiting List Content
|
||||
|
||||
Sometimes you only want to list a subset of the available content. A common
|
||||
request is to only display “Posts” on the homepage. Using the `where` function,
|
||||
you can do just that.
|
||||
|
||||
### `first`
|
||||
|
||||
`first` works in a similar manner to the [`limit` keyword in SQL][limitkeyword]. It reduces the array to only the `first N` elements. It takes the array and number of elements as input. `first` takes two arguments:
|
||||
|
||||
1. `array` or `slice of maps or structs`
|
||||
2. `number of elements`
|
||||
|
||||
{{% code file="layout/_default/section.html" %}}
|
||||
```golang
|
||||
{{ range first 10 .Data.Pages }}
|
||||
{{ .Render "summary" }}
|
||||
{{ end }}
|
||||
```
|
||||
{{% /code %}}
|
||||
Sometimes you only want to list a subset of the available content. A common request is to only display “Posts” on the homepage. Using the `where` function, you can do just that.
|
||||
|
||||
### `where`
|
||||
|
||||
@@ -371,6 +354,21 @@ you can do just that.
|
||||
```
|
||||
{{% /code %}}
|
||||
|
||||
### `first`
|
||||
|
||||
`first` works in a similar manner to the [`limit` keyword in SQL][limitkeyword]. It reduces the array to only the `first N` elements. It takes the array and number of elements as input. `first` takes two arguments:
|
||||
|
||||
1. `array` or `slice of maps or structs`
|
||||
2. `number of elements`
|
||||
|
||||
{{% code file="layout/_default/section.html" %}}
|
||||
```golang
|
||||
{{ range first 10 .Data.Pages }}
|
||||
{{ .Render "summary" }}
|
||||
{{ end }}
|
||||
```
|
||||
{{% /code %}}
|
||||
|
||||
### `first` and `where` Together
|
||||
|
||||
Using `first` and `where` together can be very powerful:
|
||||
|
||||
@@ -14,10 +14,9 @@ toc: false
|
||||
needsreview: true
|
||||
---
|
||||
|
||||
Hugo can generated a customized [robots.txt](http://www.robotstxt.org/) in the
|
||||
[same way as any other templates]({{< ref "templates/go-templates.md" >}}).
|
||||
Hugo can generate a customized [robots.txt][robots] in the same way as any other template.
|
||||
|
||||
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:
|
||||
To enable creating your robots.txt as a template, set the `enableRobotsTXT` value to `true` in your [project's configuration file][config]. By default, this option generates a robots.txt with the following content, which tells search engines that they are allowed to crawl everything:
|
||||
|
||||
```http
|
||||
User-agent: *
|
||||
@@ -30,15 +29,22 @@ The [lookup order][lookup] for the `robots.txt` template is as follows:
|
||||
* `/layouts/robots.txt`
|
||||
* `/themes/<THEME>/layout/robots.txt`
|
||||
|
||||
An example of a `robots.txt` layout is:
|
||||
## Robots. txt Template Example
|
||||
|
||||
The following is an example`robots.txt` layout:
|
||||
|
||||
{{% code file="layouts/robots.txt" download="robots.txt" %}}
|
||||
```http
|
||||
User-agent: *
|
||||
|
||||
{{range .Data.Pages}}
|
||||
Disallow: {{.RelPermalink}}{{end}}
|
||||
Disallow: {{.RelPermalink}}
|
||||
{{end}}
|
||||
```
|
||||
{{% /code %}}
|
||||
|
||||
This template disallows all the pages of the site creating one `Disallow` entry for each one.
|
||||
This template disallows all the pages of the site by creating one `Disallow` entry for each page.
|
||||
|
||||
[config]: /getting-started/configuration/
|
||||
[lookup]: /layouts/lookup-order
|
||||
[robots]: http://www.robotstxt.org/
|
||||
@@ -22,7 +22,7 @@ To effectively leverage section page templates, you should first understand the
|
||||
|
||||
### Section Template Lookup Order
|
||||
|
||||
The [lookup order][lookup] for section pages
|
||||
The [lookup order][lookup] for section pages is as follows:
|
||||
|
||||
* /layouts/section/<SECTION>.html
|
||||
* /layouts/\_default/section.html
|
||||
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
@@ -1,5 +1,12 @@
|
||||
{{- define "main" -}}
|
||||
{{ define "main" }}
|
||||
<main class="main">
|
||||
|
||||
<article class="content">
|
||||
<header class="content-header">
|
||||
<h1>Page Not Found</h1>
|
||||
</header>
|
||||
<div class="body-copy">
|
||||
<a href="{{.Site.BaseURL}}"><i class="icon-home"></i> Go Home</a>
|
||||
</div>
|
||||
</article>
|
||||
</main>
|
||||
{{- end -}}
|
||||
{{ end }}
|
||||
@@ -1,16 +1,18 @@
|
||||
{{ define "main" }}
|
||||
<main class="main">
|
||||
<header class="content-header">
|
||||
{{partial "breadcrumb.html" . }}
|
||||
<h1 class="page-title {{if eq .Kind "page"}}{{.Section}}{{end}}" id="{{ .Title | urlize }}">
|
||||
{{- partial "list-icon.html" . -}}
|
||||
{{- .Title | markdownify -}}</h1>
|
||||
{{partial "content-header-links.html" . }}
|
||||
{{partial "tags.html" . }}
|
||||
</header>
|
||||
<div class="body-copy">
|
||||
{{.Content}}
|
||||
{{partial "contents-list.html" .}}
|
||||
<div class="content">
|
||||
<header class="content-header">
|
||||
{{partial "breadcrumb.html" . }}
|
||||
<h1 class="page-title {{if eq .Kind "page"}}{{.Section}}{{end}}" id="{{ .Title | urlize }}">
|
||||
{{- partial "list-icon.html" . -}}
|
||||
{{- .Title | markdownify -}}</h1>
|
||||
{{partial "content-header-links.html" . }}
|
||||
{{partial "tags.html" . }}
|
||||
</header>
|
||||
<div class="body-copy">
|
||||
{{.Content}}
|
||||
{{partial "contents-list.html" .}}
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
{{ end }}
|
||||
@@ -72,7 +72,7 @@ $inline-code-background-color:$hugo-gray-ultra-light;
|
||||
|
||||
//Sidebar & Breadcrumb
|
||||
$site-navigation-width: 280px;
|
||||
$content-max-width: 35em;
|
||||
$content-max-width: 32em;
|
||||
$site-navigation-bg-color:$hugo-gray-ultra-light;
|
||||
$breadcrumb-navigation-bg-color:$hugo-blue-ultra-light;
|
||||
$breadcrumb-navigation-bg-color-active:$hugo-blue;
|
||||
|
||||
@@ -31,6 +31,12 @@
|
||||
transition: background-color .3s ease-in-out;
|
||||
background-color: $hugo-pink;
|
||||
color: $hugo-white;
|
||||
.page-info {
|
||||
color:$hugo-white;
|
||||
h5 {
|
||||
color:$hugo-white;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
&:after {
|
||||
@@ -48,6 +54,7 @@
|
||||
margin: 0px;
|
||||
line-height: 1.2;
|
||||
margin-top: .5em;
|
||||
color:$hugo-pink;
|
||||
}
|
||||
span {
|
||||
width: 100%;
|
||||
|
||||
@@ -42,7 +42,9 @@ main.main {
|
||||
width: 90%;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
max-width: $content-max-width;
|
||||
@include MQ(M){
|
||||
max-width: $content-max-width;
|
||||
}
|
||||
@include MQ(L) {
|
||||
float:left;
|
||||
margin-left:5%;
|
||||
|
||||
Reference in New Issue
Block a user