Merge commit '900b5f6cfe5a377ef369d26cd700201be4cf6b06'
|
@ -167,8 +167,6 @@ include_toc: true
|
|||
show_comments: false
|
||||
```
|
||||
|
||||
These two user-defined fields can then be accessed via `.Params.include_toc` and `.Params.show_comments`, respectively. The [Variables][variables] section provides more information on using Hugo's page- and site-level variables in your templates.
|
||||
|
||||
|
||||
## Order Content Through Front Matter
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ blog
|
|||
{{% note %}}
|
||||
When we talk about a **section** in correlation with template selection, it is currently always the root section only (`/blog/funny/mypost/ => blog`).
|
||||
|
||||
It is currently not possible to add a specific layout for one of the sub-sections.
|
||||
If you need a specific template for a sub-section, you need to adjust either the `type` or `layout` in front matter.
|
||||
{{% /note %}}
|
||||
|
||||
|
||||
|
|
|
@ -146,7 +146,7 @@ aliases: [/posts/my-old-url/]
|
|||
---
|
||||
```
|
||||
|
||||
Assuming a `baseURL` of `example.com`, the contents of the auto-generated alias `.html` found at `https://example.com/posts/my-old-url/ will contain the following:`
|
||||
Assuming a `baseURL` of `example.com`, the contents of the auto-generated alias `.html` found at `https://example.com/posts/my-old-url/` will contain the following:
|
||||
|
||||
```
|
||||
<!DOCTYPE html>
|
||||
|
|
|
@ -20,14 +20,19 @@ draft: false
|
|||
aliases: []
|
||||
---
|
||||
|
||||
| Function | Description | Example |
|
||||
|----------------|-------------------------------------------------------------------------------|----------------------------------|
|
||||
| `add` | Adds two integers. | `{{add 1 2}}` → 3 |
|
||||
| `div` | Divides two integers. | `{{div 6 3}}` → 2 |
|
||||
| `mod` | Modulus of two integers. | `{{mod 15 3}}` → 0 |
|
||||
| `modBool` | Boolean of modulus of two integers. Evaluates to `true` if result equals 0. | `{{modBool 15 3}}` → true |
|
||||
| `mul` | Multiplies two integers. | `{{mul 2 3}}` → 6 |
|
||||
| `sub` | Subtracts two integers. | `{{sub 3 2}}` → 1 |
|
||||
| `math.Ceil` | Returns the least integer value greater than or equal to the given number. | `{{math.Ceil 2.1}}` → 3 |
|
||||
| `math.Floor` | Returns the greatest integer value less than or equal to the given number. | `{{math.Floor 1.9}}` → 1 |
|
||||
| `math.Round` | Returns the nearest integer, rounding half away from zero. | `{{math.Round 1.5}}` → 2 |
|
||||
| Function | Description | Example |
|
||||
|--------------|-----------------------------------------------------------------------------|----------------------------------|
|
||||
| `add` | Adds two numbers. | `{{add 1 2}}` → `3` |
|
||||
| | *If one of the numbers is a float, the result is a float.* | `{{add 1.1 2}}` → `3.1` |
|
||||
| `sub` | Subtracts two numbers. | `{{sub 3 2}}` → `1` |
|
||||
| | *If one of the numbers is a float, the result is a float.* | `{{sub 3 2.5}}` → `0.5` |
|
||||
| `mul` | Multiplies two numbers. | `{{mul 2 3}}` → `6` |
|
||||
| | *If one of the numbers is a float, the result is a float.* | `{{mul 2 3.1}}` → `6.2` |
|
||||
| `div` | Divides two numbers. | `{{div 6 3}}` → `2` |
|
||||
| | | `{{div 6 4}}` → `1` |
|
||||
| | *If one of the numbers is a float, the result is a float.* | `{{div 6 4.0}}` → `1.5` |
|
||||
| `mod` | Modulus of two integers. | `{{mod 15 3}}` → `0` |
|
||||
| `modBool` | Boolean of modulus of two integers. Evaluates to `true` if result equals 0. | `{{modBool 15 3}}` → `true` |
|
||||
| `math.Ceil` | Returns the least integer value greater than or equal to the given number. | `{{math.Ceil 2.1}}` → `3` |
|
||||
| `math.Floor` | Returns the greatest integer value less than or equal to the given number. | `{{math.Floor 1.9}}` → `1` |
|
||||
| `math.Round` | Returns the nearest integer, rounding half away from zero. | `{{math.Round 1.5}}` → `2` |
|
||||
|
|
|
@ -134,4 +134,21 @@ Only the following operators are available for `nil`
|
|||
{{ end }}
|
||||
```
|
||||
|
||||
## Portable `where` filters
|
||||
|
||||
This is especially important for themes, but to list the most relevant pages on the front page or similar, you can use `.Site.Params.mainSections` list.
|
||||
|
||||
This will, by default, list pages from the _section with the most pages_.
|
||||
|
||||
```html
|
||||
{{ $pages := where .Site.RegularPages "Type" "in" .Site.Params.mainSections }}
|
||||
```
|
||||
|
||||
The user can override the default in `config.toml`:
|
||||
|
||||
```toml
|
||||
[params]
|
||||
mainSections = ["blog", "docs"]
|
||||
```
|
||||
|
||||
[intersect]: /functions/intersect/
|
||||
|
|
|
@ -1,20 +1,20 @@
|
|||
.CurrentSection
|
||||
: the page's current section. The value can be the page itself if it is a section or the homepage.
|
||||
: The page's current section. The value can be the page itself if it is a section or the homepage.
|
||||
|
||||
.InSection $anotherPage
|
||||
: whether the given page is in the current section. Note that this will always return false for pages that are not either regular, home or section pages.
|
||||
: Whether the given page is in the current section. Note that this will always return false for pages that are not either regular, home or section pages.
|
||||
|
||||
.IsAncestor $anotherPage
|
||||
: whether the current page is an ancestor of the given page. Note that this method is not relevant for taxonomy lists and taxonomy terms pages.
|
||||
: Whether the current page is an ancestor of the given page. Note that this method is not relevant for taxonomy lists and taxonomy terms pages.
|
||||
|
||||
.IsDescendant $anotherPage
|
||||
: whether the current page is a descendant of the given page. Note that this method is not relevant for taxonomy lists and taxonomy terms pages.
|
||||
: Whether the current page is a descendant of the given page. Note that this method is not relevant for taxonomy lists and taxonomy terms pages.
|
||||
|
||||
.Parent
|
||||
: a section's parent section or a page's section.
|
||||
: A section's parent section or a page's section.
|
||||
|
||||
.Section
|
||||
: the [section](/content-management/sections/) this content belongs to. **Note:** For nested sections, this is the first path element in the directory, for example, `/blog/funny/mypost/ => blog`.
|
||||
: The [section](/content-management/sections/) this content belongs to. **Note:** For nested sections, this is the first path element in the directory, for example, `/blog/funny/mypost/ => blog`.
|
||||
|
||||
.Sections
|
||||
: the [sections](/content-management/sections/) below this content.
|
||||
: The [sections](/content-management/sections/) below this content.
|
||||
|
|
5
docs/content/showcase/1password-support/bio.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
|
||||
**1Password** is a password manager that keeps you safe online. It protects your secure information behind the one password only you know.
|
||||
|
||||
|
||||
The [1Password Support](https://support.1password.com/) website was built from scratch with **Hugo** and enhanced with **React** and **Elasticsearch** to give us the best of both worlds: The simplicity and performance of a static site, with the richness of a hosted web app.
|
BIN
docs/content/showcase/1password-support/featured.png
Normal file
After Width: | Height: | Size: 162 KiB |
39
docs/content/showcase/1password-support/index.md
Normal file
|
@ -0,0 +1,39 @@
|
|||
---
|
||||
|
||||
title: 1Password Support
|
||||
date: 2018-02-22
|
||||
description: "Showcase: \"Compiles 400 pages in five languages in the blink of an eye.\""
|
||||
siteURL: https://support.1password.com/
|
||||
byline: "[Mitch Cohen](https://github.com/mitchchn), Documentation Team Lead"
|
||||
aliases: [/showcase/1password/]
|
||||
|
||||
---
|
||||
|
||||
At 1Password, we used to go through a different documentation platform every month: blog engines, ebooks, wikis, site generators written in Ruby and JavaScript. Each was inadequate in its own special way. Then we found **Hugo**. We made one last switch, and we're glad we did.
|
||||
|
||||
### Not all static site generators are created equal
|
||||
|
||||
Finding a tool that will make your customers, writers, designers, _and_ DevOps team happy is no easy task, but we managed it with Hugo:
|
||||
|
||||
**Hugo is static**. We're a security company, so we swear by static sites and use them wherever possible. We feel much safer pointing customers at HTML files than at a complicated server which needs to be hardened.
|
||||
|
||||
**Hugo is Go**. We love the Go programming language at 1Password, and we were delighted to learn that Hugo used the same Go template syntax that our designers and front-end developers had already mastered.
|
||||
|
||||
**Hugo is FAST**. Our previous static site generator took nearly a minute to compile our (then much smaller) site. Developers might be used to this, but it wasn't cutting it for writers who wanted to see live previews of their work. Hugo did the same job in milliseconds, and to this day compiles 400 pages in five languages in the blink of an eye.
|
||||
|
||||
**Hugo is flexible**. Thanks to Hugo's content and layout system, we were able to preserve our existing file and folder structure and port our entire production site in a few days. We could then create new content types that weren't possible before, like these snazzy [showcases](https://support.1password.com/explore/extension/).
|
||||
|
||||
**Hugo is great for writers**. Our documentation team was already comfortable with Markdown and Git and could start creating content for Hugo with zero downtime. Once we added shortcodes, our writers were able to dress up articles with features like [platform boxes](https://support.1password.com/get-the-apps/) with just a bit of new syntax.
|
||||
|
||||
**Hugo has an amazing developer community**. Hugo updates are frequent and filled to the brim with features and fixes. As we developed the multilingual version of our site, we submitted PRs for features we needed and were helped through the process by [@bep](https://github.com/bep) and others.
|
||||
|
||||
**Hugo is simple to deploy**. Hugo has just the right amount of configuration options to fit into our build system without being too complicated.
|
||||
|
||||
### Tech specs
|
||||
|
||||
* [1Password Support](https://support.1password.com) uses Hugo with a custom theme. It shares styles and some template code with [1Password.com](https://1password.com), which we also moved to Hugo in 2016.
|
||||
* Code and articles live in a private GitHub repository, which is deployed to a static content server using Git hooks.
|
||||
* Writers build and preview the site on their computers and contribute content using pull requests.
|
||||
* We use Hugo's [multilingual support](/content-management/multilingual/) to build the site in English, Spanish, French, Italian, German, and Russian. With the help of Hugo, 1Password Support became our very first site in multiple languages.
|
||||
* Our [contact form](https://support.1password.com/contact) is a single-page React app. We were able to integrate it with Hugo seamlessly thanks to its support for static files.
|
||||
* The one part of the support site which is not static is our search engine, which we developed with Elasticsearch and host on AWS.
|
|
@ -1,4 +0,0 @@
|
|||
|
||||
**1Password** is a popular password manager.
|
||||
|
||||
Their website is built with **Hugo**.
|
Before Width: | Height: | Size: 85 KiB |
|
@ -1,15 +0,0 @@
|
|||
---
|
||||
|
||||
title: 1password.com
|
||||
|
||||
date: 2018-02-16
|
||||
|
||||
description: "Showcase: \"1Password is my favourite piece of boring software, and I was happy to see that they built their website with Hugo\""
|
||||
|
||||
siteURL: https://1password.com/
|
||||
|
||||
byline: "[bep](https://github.com/bep), Hugo Lead"
|
||||
|
||||
---
|
||||
|
||||
**1Password** is my favourite piece of boring software. It just works. I was pleased to read that they use [Go](https://golang.org/) (aka Golang) extensively to build their software. This is also Hugo's platform. And I was also happy to see that they have **built their website with Hugo**.
|
|
@ -21,11 +21,11 @@ toc: true
|
|||
|
||||
## Traverse Local Files
|
||||
|
||||
With Hugo's [`readDir` and `readFile` template functions][reads], you can traverse your website's files on your server.
|
||||
With Hugo's [`readDir`][readDir] and [`readFile`][readFile] template functions, you can traverse your website's files on your server.
|
||||
|
||||
## Use `readDir`
|
||||
|
||||
The [`readDir` function][reads] returns an array of [`os.FileInfo`][osfileinfo]. It takes the file's `path` as a single string argument. This path can be to any directory of your website (i.e., as found on your server's file system).
|
||||
The [`readDir` function][readDir] returns an array of [`os.FileInfo`][osfileinfo]. It takes the file's `path` as a single string argument. This path can be to any directory of your website (i.e., as found on your server's file system).
|
||||
|
||||
Whether the path is absolute or relative does not matter because---at least for `readDir`---the root of your website (typically `./public/`) in effect becomes both:
|
||||
|
||||
|
@ -56,7 +56,7 @@ The initial slash `/` in `pathURL` is important in the `directoryindex` shortcod
|
|||
|
||||
## Use `readFile`
|
||||
|
||||
The [`readfile` function][reads] reads a file from disk and converts it into a string to be manipulated by other Hugo functions or added as-is. `readFile` takes the file, including path, as an argument passed to the function.
|
||||
The [`readfile` function][readFile] reads a file from disk and converts it into a string to be manipulated by other Hugo functions or added as-is. `readFile` takes the file, including path, as an argument passed to the function.
|
||||
|
||||
To use the `readFile` function in your templates, make sure the path is relative to your *Hugo project's root directory*:
|
||||
|
||||
|
@ -107,7 +107,8 @@ And here is the result as [called directly in the Hugo docs][] and rendered for
|
|||
[called directly in the Hugo docs]: https://github.com/gohugoio/hugo/blob/master/docs/content/templates/files.md
|
||||
[dirindex]: https://github.com/gohugoio/hugo/blob/master/docs/layouts/shortcodes/directoryindex.html
|
||||
[osfileinfo]: https://golang.org/pkg/os/#FileInfo
|
||||
[reads]: /functions/readfile/
|
||||
[readDir]: /functions/readdir/
|
||||
[readFile]: /functions/readfile/
|
||||
[sc]: /content-management/shortcodes/
|
||||
[sct]: /templates/shortcode-templates/
|
||||
[readfilesource]: https://github.com/gohugoio/hugo/blob/master/
|
||||
|
|
|
@ -7,6 +7,13 @@ HUGO_VERSION = "0.36.1"
|
|||
HUGO_ENV = "production"
|
||||
HUGO_ENABLEGITINFO = "true"
|
||||
|
||||
[context.split1]
|
||||
command = "hugo --enableGitInfo"
|
||||
|
||||
[context.split1.environment]
|
||||
HUGO_VERSION = "0.36.1"
|
||||
HUGO_ENV = "production"
|
||||
|
||||
[context.deploy-preview]
|
||||
command = "hugo -b $DEPLOY_PRIME_URL"
|
||||
|
||||
|
@ -21,3 +28,4 @@ HUGO_VERSION = "0.36.1"
|
|||
|
||||
[context.next.environment]
|
||||
HUGO_ENABLEGITINFO = "true"
|
||||
|
||||
|
|
After Width: | Height: | Size: 283 KiB |
After Width: | Height: | Size: 105 KiB |
After Width: | Height: | Size: 71 KiB |
Before Width: | Height: | Size: 150 KiB |
Before Width: | Height: | Size: 66 KiB |
Before Width: | Height: | Size: 48 KiB |
After Width: | Height: | Size: 183 KiB |
After Width: | Height: | Size: 62 KiB |
After Width: | Height: | Size: 90 KiB |