ref: b3bd71fec90ea2680a68d28e7ac5e82f80eafdde
parent: 8b8fb417ae065954a056ea018bd092748cc9127c
author: Anthony Fok <[email protected]>
date: Tue Mar 17 20:44:12 EDT 2015
Update Hugo docs with the initialisms suggested by golint In particular: * .Url → .URL (for node, menu and paginator) * .Site.BaseUrl → .Site.BaseURL * getJson → getJSON * getCsv → getCSV * safeHtml → safeHTML * safeCss → safeCSS * safeUrl → safeURL Continued effort in fixing #959.
--- a/docs/content/content/organization.md
+++ b/docs/content/content/organization.md
@@ -67,7 +67,7 @@
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
+Defined in the front matter, the `slug` can take the place of the filename for the
destination.
### filepath
@@ -75,18 +75,18 @@
with the same path. Includes [section](/content/sections/).
### section
-section can be provided in the front matter overriding the section derived from
+`section` can be provided in the front matter overriding the section derived from
the source content location on disk. See [section](/content/sections/).
### path
-path can be provided in the front matter. This will replace the actual
+`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
+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.
@@ -116,27 +116,27 @@
http://spf13.com/projects/hugo
- baseUrl section slug
+ baseURL section slug
⊢-----^--------⊣ ⊢--^---⊣ ⊢-^⊣
http://spf13.com/projects/hugo
- baseUrl section slug
+ baseURL section slug
⊢-----^--------⊣ ⊢--^--⊣ ⊢--^--⊣
http://spf13.com/extras/indexes/example
- baseUrl path slug
+ baseURL path slug
⊢-----^--------⊣ ⊢------^-----⊣ ⊢--^--⊣
http://spf13.com/extras/indexes/example
- baseUrl url
+ baseURL url
⊢-----^--------⊣ ⊢-----^-----⊣
http://spf13.com/projects/hugo
- baseUrl url
+ baseURL url
⊢-----^--------⊣ ⊢--------^-----------⊣
http://spf13.com/extras/indexes/example
--- a/docs/content/extras/dynamiccontent.md
+++ b/docs/content/extras/dynamiccontent.md
@@ -19,8 +19,8 @@
[CSV](http://en.wikipedia.org/wiki/Comma-separated_values) file
from nearly any resource.
-"Dynamic Content" currently consists of two functions, `getJson`
-and `getCsv`, which are available in **all template files**.
+"Dynamic Content" currently consists of two functions, `getJSON`
+and `getCSV`, which are available in **all template files**.
## Implementation details
@@ -28,26 +28,26 @@
In any HTML template or Markdown document, call the functions like this:
- {{ $dataJ := getJson "url" }}
- {{ $dataC := getCsv "separator" "url" }}
+ {{ $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" }}
+ {{ $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
+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" }}
+ {{ $gistJ := getJSON $urlPre "/users/GITHUB_USERNAME/gists" }}
will resolve internally to:
- {{ $gistJ := getJson "https://api.github.com/users/GITHUB_USERNAME/gists" }}
+ {{ $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:
@@ -54,7 +54,7 @@
<ul>
{{ $urlPre := "https://api.github.com" }}
- {{ $gistJ := getJson $urlPre "/users/GITHUB_USERNAME/gists" }}
+ {{ $gistJ := getJSON $urlPre "/users/GITHUB_USERNAME/gists" }}
{{ range first 5 $gistJ }}
{{ if .public }}
<li><a href="{{ .html_url }}" target="_blank">{{ .description }}</a></li>
@@ -65,7 +65,7 @@
### Example for CSV files
-For `getCsv`, the one-character long separator must be placed in the
+For `getCSV`, the one-character long separator must be placed in the
first position followed by the URL.
<table>
@@ -79,7 +79,7 @@
<tbody>
{{ $url := "http://a-big-corp.com/finance/employee-salaries.csv" }}
{{ $sep := "," }}
- {{ range $i, $r := getCsv $sep $url }}
+ {{ range $i, $r := getCSV $sep $url }}
<tr>
<td>{{ index $r 0 }}</td>
<td>{{ index $r 1 }}</td>
@@ -113,7 +113,7 @@
### Loading local files
-To load local files with the two functions `getJson` and `getCsv`, the
+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.
--- a/docs/content/extras/menus.md
+++ b/docs/content/extras/menus.md
@@ -27,7 +27,7 @@
A menu entry has the following properties:
-* **Url** string
+* **URL** string
* **Name** string
* **Menu** string
* **Identifier** string
@@ -112,15 +112,15 @@
Pre: "<i class='fa fa-heart'></i>"
Weight: -110
Identifier: "about"
- Url: "/about/"
+ URL: "/about/"
- Name: "getting started"
Pre: "<i class='fa fa-road'></i>"
Weight: -100
- Url: "/getting-started/"
+ 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`.
+**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`.
## Nesting
@@ -164,12 +164,12 @@
</a>
<ul class="sub">
{{ range .Children }}
- <li{{if $currentNode.IsMenuCurrent "main" . }} class="active"{{end}}><a href="{{.Url}}"> {{ .Name }} </a> </li>
+ <li{{if $currentNode.IsMenuCurrent "main" . }} class="active"{{end}}><a href="{{.URL}}"> {{ .Name }} </a> </li>
{{ end }}
</ul>
{{else}}
<li>
- <a class="" href="{{.Url}}">
+ <a class="" href="{{.URL}}">
{{ .Pre }}
<span>{{ .Name }}</span>
</a>
--- a/docs/content/extras/pagination.md
+++ b/docs/content/extras/pagination.md
@@ -17,16 +17,16 @@
Pagination can be configured in the site configuration (e.g. `config.toml`):
-* `Paginate` (default `10`)
+* `Paginate` (default `10`)
* `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/`.
+`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 only relevant for the templates for the home page and the list pages (sections and taxonomies).**
+**A `.Paginator` is provided to help building a pager menu. This is 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`:
@@ -37,7 +37,7 @@
## Build the navigation
-The `.Paginator` contains enough information to build a paginator interface.
+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):
@@ -67,7 +67,7 @@
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
+* `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
--- a/docs/content/overview/configuration.md
+++ b/docs/content/overview/configuration.md
@@ -40,11 +40,11 @@
builddrafts = false
baseurl = "http://yoursite.example.com/"
canonifyurls = true
-
+
[taxonomies]
category = "categories"
tag = "tags"
-
+
[params]
description = "Tesla's Awesome Hugo Site"
author = "Nikola Tesla"
@@ -74,67 +74,67 @@
---
archetypedir: "archetype"
# hostname (and path) to the root eg. http://spf13.com/
- baseurl: ""
+ baseURL: ""
# include content marked as draft
- buildDrafts: false
+ buildDrafts: false
# include content with datePublished in the future
- buildFuture: false
- canonifyUrls: false
+ buildFuture: false
+ canonifyURLs: false
# config file (default is path/config.yaml|json|toml)
- config: "config.toml"
+ config: "config.toml"
contentdir: "content"
dataDir: "data"
defaultExtension: "html"
defaultLayout: "post"
# filesystem path to write files to
- destination: ""
+ destination: ""
disableLiveReload: false
# Do not build RSS files
- disableRSS: false
+ disableRSS: false
# Do not build Sitemap file
- disableSitemap: false
+ disableSitemap: false
# edit new content with this editor, if provided
- editor: ""
+ editor: ""
footnoteAnchorPrefix: ""
footnoteReturnLinkContents: ""
languageCode: ""
layoutdir: "layouts"
# Enable Logging
- log: false
+ log: false
# Log File path (if set, logging enabled automatically)
- logFile: ""
+ logFile: ""
# "yaml", "toml", "json"
- metaDataFormat: "toml"
+ metaDataFormat: "toml"
newContentEditor: ""
# Don't sync modification time of files
- noTimes: false
+ noTimes: false
paginate: 10
paginatePath: "page"
- permalinks:
+ permalinks:
# Pluralize titles in lists using inflect
- pluralizeListTitles: true
+ pluralizeListTitles: true
publishdir: "public"
# color-codes for highlighting derived from this style
pygmentsStyle: "monokai"
# true: use pygments-css or false: color-codes directly
- pygmentsUseClasses: false
+ pygmentsUseClasses: false
sitemap: ""
- # filesystem path to read files relative from
- source: ""
+ # filesystem path to read files relative from
+ source: ""
staticdir: "static"
# display memory and timing of different steps of the program
- stepAnalysis: false
+ stepAnalysis: false
# theme to use (located in /themes/THEMENAME/)
- theme: ""
+ theme: ""
title: ""
# if true, use /filename.html instead of /filename/
- uglyUrls: false
+ uglyURLs: false
# verbose output
- verbose: false
+ verbose: false
# verbose logging
- verboseLog: false
+ verboseLog: false
# watch filesystem for changes and recreate as needed
- watch: false
+ watch: false
---
--- a/docs/content/taxonomies/displaying.md
+++ b/docs/content/taxonomies/displaying.md
@@ -52,7 +52,7 @@
<ul>
{{ range .Site.Taxonomies.series.golang }}
- <li><a href="{{ .Url }}">{{ .Name }}</a></li>
+ <li><a href="{{ .URL }}">{{ .Name }}</a></li>
{{ end }}
</ul>
--- a/docs/content/templates/content.md
+++ b/docs/content/templates/content.md
@@ -67,7 +67,7 @@
{{ partial "header.html" . }}
{{ partial "subheader.html" . }}
- {{ $baseurl := .Site.BaseUrl }}
+ {{ $baseurl := .Site.BaseURL }}
<section id="main">
<h1 id="title">{{ .Title }}</h1>
@@ -116,7 +116,7 @@
{{ partial "header.html" . }}
{{ partial "subheader.html" . }}
- {{ $baseurl := .Site.BaseUrl }}
+ {{ $baseurl := .Site.BaseURL }}
<section id="main">
<h1 id="title">{{ .Title }}</h1>
--- a/docs/content/templates/functions.md
+++ b/docs/content/templates/functions.md
@@ -262,7 +262,7 @@
e.g. `<a href="/tags/{{ . | urlize }}">{{ . }}</a>`
-### safeHtml
+### safeHTML
Declares the provided string as a "safe" HTML document fragment
so Go html/template will not filter it. It should not be used
for HTML from a third-party, or HTML with unclosed tags or comments.
@@ -271,11 +271,11 @@
copyright = "© 2015 Jane Doe. <a href=\"http://creativecommons.org/licenses/by/4.0/\">Some rights reserved</a>."
-`{{ .Site.Copyright | safeHtml }}` would then output:
+`{{ .Site.Copyright | safeHTML }}` would then output:
> © 2015 Jane Doe. <a href="http://creativecommons.org/licenses/by/4.0/">Some rights reserved</a>.
-However, without the `safeHtml` function, html/template assumes
+However, without the `safeHTML` function, html/template assumes
`.Site.Copyright` to be unsafe, escaping all HTML tags,
rendering the whole string as plain-text like this:
@@ -284,7 +284,7 @@
</blockquote>
<!--
-### safeHtmlAttr
+### safeHTMLAttr
Declares the provided string as a "safe" HTML attribute
from a trusted source, for example, ` dir="ltr"`,
so Go html/template will not filter it.
@@ -295,11 +295,11 @@
name = "IRC: #golang at freenode"
url = "irc://irc.freenode.net/#golang"
-* `<a href="{{ .Url }}">` ⇒ `<a href="#ZgotmplZ">` (Bad!)
-* `<a {{ printf "href=%q" .Url | safeHtmlAttr }}>` ⇒ `<a href="irc://irc.freenode.net/#golang">` (Good!)
+* `<a href="{{ .URL }}">` ⇒ `<a href="#ZgotmplZ">` (Bad!)
+* `<a {{ printf "href=%q" .URL | safeHTMLAttr }}>` ⇒ `<a href="irc://irc.freenode.net/#golang">` (Good!)
-->
-### safeCss
+### safeCSS
Declares the provided string as a known "safe" CSS string
so Go html/templates will not filter it.
"Safe" means CSS content that matches any of:
@@ -311,13 +311,13 @@
Example: Given `style = "color: red;"` defined in the front matter of your `.md` file:
-* `<p style="{{ .Params.style | safeCss }}">…</p>` ⇒ `<p style="color: red;">…</p>` (Good!)
+* `<p style="{{ .Params.style | safeCSS }}">…</p>` ⇒ `<p style="color: red;">…</p>` (Good!)
* `<p style="{{ .Params.style }}">…</p>` ⇒ `<p style="ZgotmplZ">…</p>` (Bad!)
Note: "ZgotmplZ" is a special value that indicates that unsafe content reached a
CSS or URL context.
-### safeUrl
+### safeURL
Declares the provided string as a "safe" URL or URL substring (see [RFC 3986][]).
A URL like `javascript:checkThatFormNotEditedBeforeLeavingPage()` from a trusted
source should go in the page, but by default dynamic `javascript:` URLs are
@@ -325,7 +325,7 @@
[RFC 3986]: http://tools.ietf.org/html/rfc3986
-Without `safeUrl`, only the URI schemes `http:`, `https:` and `mailto:`
+Without `safeURL`, only the URI schemes `http:`, `https:` and `mailto:`
are considered safe by Go. If any other URI schemes, e.g. `irc:` and
`javascript:`, are detected, the whole URL would be replaced with
`#ZgotmplZ`. This is to "defang" any potential attack in the URL,
@@ -341,7 +341,7 @@
<ul class="sidebar-menu">
{{ range .Site.Menus.main }}
- <li><a href="{{ .Url }}">{{ .Name }}</a></li>
+ <li><a href="{{ .URL }}">{{ .Name }}</a></li>
{{ end }}
</ul>
@@ -348,9 +348,9 @@
would produce `<li><a href="#ZgotmplZ">IRC: #golang at freenode</a></li>`
for the `irc://…` URL.
-To fix this, add ` | safeUrl` after `.Url` on the 3rd line, like this:
+To fix this, add ` | safeURL` after `.URL` on the 3rd line, like this:
- <li><a href="{{ .Url | safeUrl }}">{{ .Name }}</a></li>
+ <li><a href="{{ .URL | safeURL }}">{{ .Name }}</a></li>
With this change, we finally get `<li><a href="irc://irc.freenode.net/#golang">IRC: #golang at freenode</a></li>`
as intended.
--- a/docs/content/templates/go-templates.md
+++ b/docs/content/templates/go-templates.md
@@ -236,14 +236,14 @@
By default, Go Templates remove HTML comments from output. This has the unfortunate side effect of removing Internet Explorer conditional comments. As a workaround, use something like this:
- {{ "<!--[if lt IE 9]>" | safeHtml }}
+ {{ "<!--[if lt IE 9]>" | safeHTML }}
<script src="html5shiv.js"></script>
- {{ "<![endif]-->" | safeHtml }}
+ {{ "<![endif]-->" | safeHTML }}
Alternatively, use the backtick (`` ` ``) to quote the IE conditional comments, avoiding the tedious task of escaping every double quotes (`"`) inside, as demonstrated in the [examples](http://golang.org/pkg/text/template/#hdr-Examples) in the Go text/template documentation, e.g.:
```
-{{ `<!--[if lt IE 7]><html class="no-js lt-ie9 lt-ie8 lt-ie7"><![endif]-->` | safeHtml }}
+{{ `<!--[if lt IE 7]><html class="no-js lt-ie9 lt-ie8 lt-ie7"><![endif]-->` | safeHTML }}
```
## Context (a.k.a. the dot)
@@ -355,7 +355,7 @@
```
{{if .Site.Params.CopyrightHTML}}<footer>
-<div class="text-center">{{.Site.Params.CopyrightHTML | safeHtml}}</div>
+<div class="text-center">{{.Site.Params.CopyrightHTML | safeHTML}}</div>
</footer>{{end}}
```
--- a/docs/content/templates/homepage.md
+++ b/docs/content/templates/homepage.md
@@ -56,7 +56,7 @@
{{ partial "meta.html" . }}
- <base href="{{ .Site.BaseUrl }}">
+ <base href="{{ .Site.BaseURL }}">
<title>{{ .Site.Title }}</title>
<link rel="canonical" href="{{ .Permalink }}">
<link href="{{ .RSSlink }}" rel="alternate" type="application/rss+xml" title="{{ .Site.Title }}" />
--- a/docs/content/templates/partials.md
+++ b/docs/content/templates/partials.md
@@ -60,7 +60,7 @@
{{ partial "meta.html" . }}
- <base href="{{ .Site.BaseUrl }}">
+ <base href="{{ .Site.BaseURL }}">
<title> {{ .Title }} : spf13.com </title>
<link rel="canonical" href="{{ .Permalink }}">
{{ if .RSSlink }}<link href="{{ .RSSlink }}" rel="alternate" type="application/rss+xml" title="{{ .Title }}" />{{ end }}
--- a/docs/content/templates/sitemap.md
+++ b/docs/content/templates/sitemap.md
@@ -39,7 +39,7 @@
{{ range .Data.Pages }}
<url>
<loc>{{ .Permalink }}</loc>
- <lastmod>{{ safeHtml ( .Date.Format "2006-01-02T15:04:05-07:00" ) }}</lastmod>{{ with .Sitemap.ChangeFreq }}
+ <lastmod>{{ safeHTML ( .Date.Format "2006-01-02T15:04:05-07:00" ) }}</lastmod>{{ with .Sitemap.ChangeFreq }}
<changefreq>{{ . }}</changefreq>{{ end }}{{ if ge .Sitemap.Priority 0.0 }}
<priority>{{ .Sitemap.Priority }}</priority>{{ end }}
</url>
--- a/docs/content/templates/variables.md
+++ b/docs/content/templates/variables.md
@@ -72,7 +72,7 @@
**.Title** The title for the content.<br>
**.Date** The date the content is published on.<br>
**.Permalink** The Permanent link for this node<br>
-**.Url** The relative URL for this node.<br>
+**.URL** The relative URL for this node.<br>
**.Ref(ref)** Returns the permalink for `ref`. See [cross-references]({{% ref "extras/crossreferences.md" %}}). Does not handle in-page fragments correctly.<br>
**.RelRef(ref)** Returns the relative permalink for `ref`. See [cross-references]({{% ref "extras/crossreferences.md" %}}). Does not handle in-page fragments correctly.<br>
**.RSSLink** Link to the taxonomies' RSS link.<br>
@@ -86,7 +86,7 @@
Also available is `.Site` which has the following:
-**.Site.BaseUrl** The base URL for the site as defined in the site configuration file.<br>
+**.Site.BaseURL** The base URL for the site as defined in the site configuration file.<br>
**.Site.Taxonomies** The [taxonomies](/taxonomies/usage/) for the entire site. Replaces the now-obsolete `.Site.Indexes` since v0.11.<br>
**.Site.LastChange** The date of the last change of the most recent content.<br>
**.Site.Pages** Array of all content ordered by Date, newest first. Replaces the now-deprecated `.Site.Recent` starting v0.13.<br>
--- a/docs/layouts/partials/menu.html
+++ b/docs/layouts/partials/menu.html
@@ -16,12 +16,12 @@
</a>
<ul class="sub{{if $currentNode.HasMenuCurrent "main" . }} open{{end}}">
{{ range .Children }}
- <li{{if $currentNode.IsMenuCurrent "main" . }} class="active"{{end}}><a href="{{.Url}}">{{ .Name }}</a> </li>
+ <li{{if $currentNode.IsMenuCurrent "main" . }} class="active"{{end}}><a href="{{.URL}}">{{ .Name }}</a> </li>
{{ end }}
</ul>
{{else}}
<li>
- <a class="" href="{{.Url}}">
+ <a class="" href="{{.URL}}">
{{ .Pre }}
<!--<i class="icon_house_alt"></i>-->
<span>{{ .Name }}</span>