Skip to content

Commit

Permalink
Squashed 'docs/' changes from 1dc05a16b..715741f73
Browse files Browse the repository at this point in the history
715741f73 Add Netlify config for a split testin branch
4917f0636 Mention that math add/sub/mul/div functions can do float math too
31632beeb Document .Site.Params.mainSections
3416ba80d Update sectionvars.md
295ccb463 Update sections.md
15b5a0342 Fix duplicated paragraph
eb13db670 Fix text highlight
fa46cafdf Get 1password-support ready
979bb5698 Add 1password support showcase
ceb94d1e1 Fix readDir function links

git-subtree-dir: docs
git-subtree-split: 715741f7393cec2a9b34254bda6e815e9391a632
  • Loading branch information
bep committed Feb 27, 2018
1 parent 374d184 commit 900b5f6
Show file tree
Hide file tree
Showing 23 changed files with 99 additions and 45 deletions.
2 changes: 0 additions & 2 deletions content/content-management/front-matter.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion content/content-management/sections.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}}


Expand Down
2 changes: 1 addition & 1 deletion content/content-management/urls.md
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
27 changes: 16 additions & 11 deletions content/functions/math.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,19 @@ draft: false
aliases: []
---

| Function | Description | Example |
|----------------|-------------------------------------------------------------------------------|----------------------------------|
| `add` | Adds two integers. | `{{add 1 2}}` &rarr; 3 |
| `div` | Divides two integers. | `{{div 6 3}}` &rarr; 2 |
| `mod` | Modulus of two integers. | `{{mod 15 3}}` &rarr; 0 |
| `modBool` | Boolean of modulus of two integers. Evaluates to `true` if result equals 0. | `{{modBool 15 3}}` &rarr; true |
| `mul` | Multiplies two integers. | `{{mul 2 3}}` &rarr; 6 |
| `sub` | Subtracts two integers. | `{{sub 3 2}}` &rarr; 1 |
| `math.Ceil` | Returns the least integer value greater than or equal to the given number. | `{{math.Ceil 2.1}}` &rarr; 3 |
| `math.Floor` | Returns the greatest integer value less than or equal to the given number. | `{{math.Floor 1.9}}` &rarr; 1 |
| `math.Round` | Returns the nearest integer, rounding half away from zero. | `{{math.Round 1.5}}` &rarr; 2 |
| Function | Description | Example |
|--------------|-----------------------------------------------------------------------------|----------------------------------|
| `add` | Adds two numbers. | `{{add 1 2}}` &rarr; `3` |
| | *If one of the numbers is a float, the result is a float.* | `{{add 1.1 2}}` &rarr; `3.1` |
| `sub` | Subtracts two numbers. | `{{sub 3 2}}` &rarr; `1` |
| | *If one of the numbers is a float, the result is a float.* | `{{sub 3 2.5}}` &rarr; `0.5` |
| `mul` | Multiplies two numbers. | `{{mul 2 3}}` &rarr; `6` |
| | *If one of the numbers is a float, the result is a float.* | `{{mul 2 3.1}}` &rarr; `6.2` |
| `div` | Divides two numbers. | `{{div 6 3}}` &rarr; `2` |
| | | `{{div 6 4}}` &rarr; `1` |
| | *If one of the numbers is a float, the result is a float.* | `{{div 6 4.0}}` &rarr; `1.5` |
| `mod` | Modulus of two integers. | `{{mod 15 3}}` &rarr; `0` |
| `modBool` | Boolean of modulus of two integers. Evaluates to `true` if result equals 0. | `{{modBool 15 3}}` &rarr; `true` |
| `math.Ceil` | Returns the least integer value greater than or equal to the given number. | `{{math.Ceil 2.1}}` &rarr; `3` |
| `math.Floor` | Returns the greatest integer value less than or equal to the given number. | `{{math.Floor 1.9}}` &rarr; `1` |
| `math.Round` | Returns the nearest integer, rounding half away from zero. | `{{math.Round 1.5}}` &rarr; `2` |
17 changes: 17 additions & 0 deletions content/functions/where.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/
14 changes: 7 additions & 7 deletions content/readfiles/sectionvars.md
Original file line number Diff line number Diff line change
@@ -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 changes: 5 additions & 0 deletions content/showcase/1password-support/bio.md
Original file line number Diff line number Diff line change
@@ -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.
Binary file added content/showcase/1password-support/featured.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
39 changes: 39 additions & 0 deletions content/showcase/1password-support/index.md
Original file line number Diff line number Diff line change
@@ -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.
4 changes: 0 additions & 4 deletions content/showcase/1password/bio.md

This file was deleted.

Binary file removed content/showcase/1password/featured.png
Binary file not shown.
15 changes: 0 additions & 15 deletions content/showcase/1password/index.md

This file was deleted.

9 changes: 5 additions & 4 deletions content/templates/files.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down Expand Up @@ -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*:

Expand Down Expand Up @@ -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/
Expand Down
8 changes: 8 additions & 0 deletions netlify.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -21,3 +28,4 @@ HUGO_VERSION = "0.36.1"

[context.next.environment]
HUGO_ENABLEGITINFO = "true"

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 900b5f6

Please sign in to comment.