From: Bjørn Erik Pedersen Date: Mon, 2 Apr 2018 06:53:34 +0000 (+0200) Subject: Merge commit 'ed8bf081fdbf336e026517b7e1b123c039014ab5' X-Git-Tag: v0.38~5 X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=558825cc201da2264be2e82d24fbf0d1105a0c2e;p=brevno-suite%2Fhugo Merge commit 'ed8bf081fdbf336e026517b7e1b123c039014ab5' --- 558825cc201da2264be2e82d24fbf0d1105a0c2e diff --cc docs/config.toml index 74b10fce,00000000..842b3df0 mode 100644,000000..100644 --- a/docs/config.toml +++ b/docs/config.toml @@@ -1,274 -1,0 +1,273 @@@ +baseURL = "https://gohugo.io/" +paginate = 100 +defaultContentLanguage = "en" +enableEmoji = true +# Set the unicode character used for the "return" link in page footnotes. +footnotereturnlinkcontents = "↩" +languageCode = "en-us" +metaDataFormat = "yaml" +title = "Hugo" +theme = "gohugoioTheme" + +googleAnalytics = "UA-7131036-4" + +pluralizeListTitles = false + +# We do redirects via Netlify's _redirects file, generated by Hugo (see "outputs" below). +disableAliases = true + +# Highlighting config (Pygments) +# It is (currently) not in use, but you can do ```go in a content file if you want to. +pygmentsCodeFences = true + +pygmentsOptions = "" +# Use the Chroma stylesheet - # TODO(bep) build new CSS when we have picked a new style. - pygmentsUseClasses = false ++pygmentsUseClasses = true +pygmentsUseClassic = false + +# See https://help.farbox.com/pygments.html +pygmentsStyle = "trac" + +[outputs] +home = [ "HTML", "RSS", "REDIR", "HEADERS" ] +section = [ "HTML", "RSS"] + +[mediaTypes] +[mediaTypes."text/netlify"] +suffix = "" +delimiter = "" + +[outputFormats] +[outputFormats.REDIR] +mediatype = "text/netlify" +baseName = "_redirects" +isPlainText = true +notAlternative = true +[outputFormats.HEADERS] +mediatype = "text/netlify" +baseName = "_headers" +isPlainText = true +notAlternative = true + +[related] + +threshold = 80 +includeNewer = true +toLower = false + +[[related.indices]] +name = "keywords" +weight = 100 +[[related.indices]] +name = "date" +weight = 10 +pattern = "2006" + +[social] +twitter = "GoHugoIO" + +#CUSTOM PARAMS +[params] + description = "The world’s fastest framework for building websites" + ## Used for views in rendered HTML (i.e., rather than using the .Hugo variable) + release = "0.38-DEV" + ## Setting this to true will add a "noindex" to *EVERY* page on the site + removefromexternalsearch = false + ## Gh repo for site footer (include trailing slash) + ghrepo = "https://github.com/gohugoio/hugoDocs/" + ## GH Repo for filing a new issue + github_repo = "https://github.com/gohugoio/hugo/issues/new" + ### Edit content repo (set to automatically enter "edit" mode; this is good for "improve this page" links) + ghdocsrepo = "https://github.com/gohugoio/hugoDocs/tree/master/docs" + ## Gitter URL + gitter = "https://gitter.im/spf13/hugo" + ## Discuss Forum URL + forum = "https://discourse.gohugo.io/" + ## Google Tag Manager + gtmid = "" + + # First one is picked as the Twitter card image if not set on page. + images = ["images/gohugoio-card.png"] + + flex_box_interior_classes = "flex-auto w-100 w-40-l mr3 mb3 bg-white ba b--moon-gray nested-copy-line-height" + + #sidebar_direction = "sidebar_left" + +# MARKDOWN +## Configuration for BlackFriday markdown parser: https://github.com/russross/blackfriday +[blackfriday] + plainIDAnchors = true + # See https://github.com/gohugoio/hugo/issues/2424 + hrefTargetBlank = false + angledQuotes = false + latexDashes = true + +[imaging] +# See https://github.com/disintegration/imaging +# CatmullRom is a sharp bicubic filter which should fit the docs site well with its many screenshots. +# Note that you can also set this per image processing. +resampleFilter = "CatmullRom" + +# Defatult JPEG quality setting. Default is 75. +quality = 75 + +anchor = "smart" + + +## As of v0.20, all content files include a default "categories" value that's the same as the section. This was a cheap future-proofing method and should/could be changed accordingly. +[taxonomies] + category = "categories" + +# High level items + +[[menu.docs]] + name = "About Hugo" + weight = 1 + identifier = "about" + url = "/about/" + +[[menu.docs]] + name = "Getting Started" + weight = 5 + identifier = "getting-started" + url = "/getting-started/" + + +[[menu.docs]] + name = "Themes" + weight = 15 + identifier = "themes" + post = "break" + url = "/themes/" + +# Core Menus + +[[menu.docs]] + name = "Content Management" + weight = 20 + identifier = "content-management" + post = "expanded" + url = "/content-management/" + +[[menu.docs]] + name = "Templates" + weight = 25 + identifier = "templates" + + url = "/templates/" + +[[menu.docs]] + name = "Functions" + weight = 30 + identifier = "functions" + url = "/functions/" + +[[menu.docs]] + name = "Variables" + weight = 35 + identifier = "variables" + url = "/variables/" + +[[menu.docs]] + name = "CLI" + weight = 40 + post = "break" + identifier = "commands" + url = "/commands/" + + + +# LOW LEVEL ITEMS + + +[[menu.docs]] + name = "Troubleshooting" + weight = 60 + identifier = "troubleshooting" + url = "/troubleshooting/" + +[[menu.docs]] + name = "Tools" + weight = 70 + identifier = "tools" + url = "/tools/" + +[[menu.docs]] + name = "Hosting & Deployment" + weight = 80 + identifier = "hosting-and-deployment" + url = "/hosting-and-deployment/" + +[[menu.docs]] + name = "Contribute" + weight = 100 + post = "break" + identifier = "contribute" + url = "/contribute/" + +#[[menu.docs]] +# name = "Tags" +# weight = 120 +# identifier = "tags" +# url = "/tags/" + + +# [[menu.docs]] +# name = "Categories" +# weight = 140 +# identifier = "categories" +# url = "/categories/" + +######## QUICKLINKS + + [[menu.quicklinks]] + name = "Fundamentals" + weight = 1 + identifier = "fundamentals" + url = "/tags/fundamentals/" + + + + +######## GLOBAL ITEMS TO BE SHARED WITH THE HUGO SITES + +[[menu.global]] + name = "News" + weight = 1 + identifier = "news" + url = "/news/" + + [[menu.global]] + name = "Docs" + weight = 5 + identifier = "docs" + url = "/documentation/" + + [[menu.global]] + name = "Themes" + weight = 10 + identifier = "themes" + url = "https://themes.gohugo.io/" + + [[menu.global]] + name = "Showcase" + weight = 20 + identifier = "showcase" + url = "/showcase/" + + # Anything with a weight > 100 gets an external icon + [[menu.global]] + name = "Community" + weight = 150 + icon = true + identifier = "community" + post = "external" + url = "https://discourse.gohugo.io/" + + + [[menu.global]] + name = "GitHub" + weight = 200 + identifier = "github" + post = "external" + url = "https://github.com/gohugoio/hugo" diff --cc docs/content/content-management/page-bundles.md index f497a59b,00000000..09aeae8e mode 100644,000000..100644 --- a/docs/content/content-management/page-bundles.md +++ b/docs/content/content-management/page-bundles.md @@@ -1,168 -1,0 +1,182 @@@ +--- +title : "Page Bundles" +description : "Content organization using Page Bundles" +date : 2018-01-24T13:09:00-05:00 +lastmod : 2018-01-28T22:26:40-05:00 +linktitle : "Page Bundles" +keywords : ["page", "bundle", "leaf", "branch"] +categories : ["content management"] +toc : true +menu : + docs: + identifier : "page-bundles" + parent : "content-management" + weight : 11 +--- + +Page Bundles are a way to group [Page Resources](/content-management/page-resources/). + +A Page Bundle can be one of: + +- Leaf Bundle (leaf means it has no children) +- Branch Bundle (home page, section, taxonomy terms, taxonomy list) + +| | Leaf Bundle | Branch Bundle | +|-----------------|--------------------------------------------------------|---------------------------------------------------------| +| Usage           | Collection of resources (pages, images etc.) for single pages | Collection of non-page resources (images etc.)for list pages | +| Index file name | `index.md` [^fn:1] | `_index.md` [^fn:1] | +| Layout type | `single` | `list` | +| Nesting | Doesn't allow nesting of more bundles under it | Allows nesting of leaf/branch bundles under it | +| Example | `content/posts/my-post/index.md` | `content/posts/_index.md` | + + +## Leaf Bundles {#leaf-bundles} + +A _Leaf Bundle_ is a directory at any hierarchy within the `content/` +directory, that contains an **`index.md`** file. + +### Examples of Leaf Bundle organization {#examples-of-leaf-bundle-organization} + +```text +content/ +├── about +│ ├── index.md +├── posts +│ ├── my-post +│ │ ├── content1.md +│ │ ├── content2.md +│ │ ├── image1.jpg +│ │ ├── image2.png +│ │ └── index.md +│ └── my-another-post +│    └── index.md +│ +└── another-section + ├── .. +    └── not-a-leaf-bundle + ├── .. +    └── another-leaf-bundle +    └── index.md +``` + +In the above example `content/` directory, there are four leaf +bundles: + +about +: This leaf bundle is at the root level (directly under + `content` directory) and has only the `index.md`. + +my-post +: This leaf bundle has the `index.md`, two other content + Markdown files and two image files. + +my-another-post +: This leaf bundle has only the `index.md`. + +another-leaf-bundle +: This leaf bundle is nested under couple of + directories. This bundle also has only the `index.md`. + +{{% note %}} +The hierarchy depth at which a leaf bundle is created does not matter, +as long as it is not inside another **leaf** bundle. +{{% /note %}} + + +### Headless Bundle {#headless-bundle} + +A headless bundle is a bundle that is configured to not get published +anywhere: + +- It will have no `Permalink` and no rendered HTML in `public/`. +- It will not be part of `.Site.RegularPages`, etc. + +But you can get it by `.Site.GetPage`. Here is an example: + +```html +{{ $headless := .Site.GetPage "page" "some-headless-bundle" }} +{{ $reusablePages := $headless.Resources.Match "author*" }} +

Authors

+{{ range $reusablePages }} +

{{ .Title }}

+ {{ .Content }} +{{ end }} +``` + ++_In this example, we are assuming the `some-headless-bundle` to be a headless ++ bundle containing one or more **page** resources whose `.Name` matches ++ `"author*"`._ ++ ++Explanation of the above example: ++ ++1. Get the `some-headless-bundle` Page "object". ++2. Collect a *slice* of resources in this *Page Bundle* that matches ++ `"author*"` using `.Resources.Match`. ++3. Loop through that *slice* of nested pages, and output their `.Title` and ++ `.Content`. ++ ++--- ++ +A leaf bundle can be made headless by adding below in the Front Matter +(in the `index.md`): + +```toml +headless = true +``` + +{{% note %}} +Only leaf bundles can be made headless. +{{% /note %}} + +There are many use cases of such headless page bundles: + +- Shared media galleries +- Reusable page content "snippets" + + +## Branch Bundles {#branch-bundles} + +A _Branch Bundle_ is any directory at any hierarchy within the +`content/` directory, that contains at least an **`_index.md`** file. + +This `_index.md` can also be directly under the `content/` directory. + +{{% note %}} +Here `md` (markdown) is used just as an example. You can use any file +type as a content resource as long as it is a content type recognized by Hugo. +{{% /note %}} + + +### Examples of Branch Bundle organization {#examples-of-branch-bundle-organization} + +```text +content/ +├── branch-bundle-1 +│   ├── branch-content1.md +│   ├── branch-content2.md +│   ├── image1.jpg +│   ├── image2.png +│   └── _index.md +└── branch-bundle-2 + ├── _index.md + └── a-leaf-bundle + └── index.md +``` + +In the above example `content/` directory, there are two branch +bundles (and a leaf bundle): + +`branch-bundle-1` +: This branch bundle has the `_index.md`, two + other content Markdown files and two image files. + +`branch-bundle-2` +: This branch bundle has the `_index.md` and a + nested leaf bundle. + +{{% note %}} +The hierarchy depth at which a branch bundle is created does not +matter. +{{% /note %}} + +[^fn:1]: The `.md` extension is just an example. The extension can be `.html`, `.json` or any of any valid MIME type. diff --cc docs/content/content-management/syntax-highlighting.md index ffb430bd,00000000..67d443fd mode 100644,000000..100644 --- a/docs/content/content-management/syntax-highlighting.md +++ b/docs/content/content-management/syntax-highlighting.md @@@ -1,188 -1,0 +1,188 @@@ +--- +title: Syntax Highlighting +description: Hugo comes with reallly fast syntax highlighting from Chroma. +date: 2017-02-01 +publishdate: 2017-02-01 +keywords: [highlighting,pygments,chroma,code blocks,syntax] +categories: [content management] +menu: + docs: + parent: "content-management" + weight: 300 +weight: 20 +sections_weight: 20 +draft: false +aliases: [/extras/highlighting/,/extras/highlight/,/tools/syntax-highlighting/] +toc: true +--- + +From Hugo 0.28, the default syntax hightlighter in Hugo is [Chroma](https://github.com/alecthomas/chroma); it is built in Go and is really, really fast -- and for the most important parts compatible with Pygments. + +If you want to continue to use Pygments (see below), set `pygmentsUseClassic=true` in your site config. + +The example below shows a simple code snippet from the Hugo source highlighted with the `highlight` shortcode. Note that the gohugo.io site is generated with `pygmentsUseClasses=true` (see [Generate Syntax Highlighter CSS](#generate-syntax-highlighter-css)). + +* `linenos=inline` or `linenos=table` (`table` will give copy-and-paste friendly code blocks) turns on line numbers. +* `hl_lines` lists a set of line numbers or line number ranges to be highlighted. Note that the hyphen range syntax is only supported for Chroma. +* `linenostart=199` starts the line number count from 199. + +With that, this: + +``` +{{}} +// ... code +{{}} +``` + +Gives this: + +{{< highlight go "linenos=table,hl_lines=8 15-17,linenostart=199" >}} +// GetTitleFunc returns a func that can be used to transform a string to +// title case. +// +// The supported styles are +// +// - "Go" (strings.Title) +// - "AP" (see https://www.apstylebook.com/) +// - "Chicago" (see http://www.chicagomanualofstyle.org/home.html) +// +// If an unknown or empty style is provided, AP style is what you get. +func GetTitleFunc(style string) func(s string) string { + switch strings.ToLower(style) { + case "go": + return strings.Title + case "chicago": + tc := transform.NewTitleConverter(transform.ChicagoStyle) + return tc.Title + default: + tc := transform.NewTitleConverter(transform.APStyle) + return tc.Title + } +} +{{< / highlight >}} + + - ## Configure Syntax Hightlighter ++## Configure Syntax Highlighter +To make the transition from Pygments to Chroma seamless, they share a common set of configuration options: + +pygmentsOptions +: A comma separated list of options. See below for a full list. + +pygmentsCodefences +: Set to true to enable syntax highlighting in code fences with a language tag in markdown (see below for an example). + +pygmentsStyle +: The style of code highlighting. See https://help.farbox.com/pygments.html for a gallery. Note that this option is not relevant when `pygmentsUseClasses` is set. + +pygmentsUseClasses +: Set to `true` to use CSS classes to format your highlighted code. See [Generate Syntax Highlighter CSS](#generate-syntax-highlighter-css). + +pygmentsCodefencesGuessSyntax +: Set to `true` to try to do syntax highlighting on code fenced blocks in markdown without a language tag. + +pygmentsUseClassic +: Set to true to use Pygments instead of the much faster Chroma. + +### Options + +`pygmentsOptions` can be set either in site config or overridden per code block in the Highlight shortcode or template func. + +noclasses +: Use inline style. + +linenos +: For Chroma, any value in this setting will print line numbers. Pygments has some more fine grained control. + +linenostart +: Start the line numbers from this value (default is 1). + + +hl_lines +: Highlight a space separated list of line numbers. For Chroma, you can provide a list of ranges, i.e. "3-8 10-20". + + +The full set of supported options for Pygments is: `encoding`, `outencoding`, `nowrap`, `full`, `title`, `style`, `noclasses`, `classprefix`, `cssclass`, `cssstyles`, `prestyles`, `linenos`, `hl_lines`, `linenostart`, `linenostep`, `linenospecial`, `nobackground`, `lineseparator`, `lineanchors`, `linespans`, `anchorlinenos`, `startinline`. See the [Pygments HTML Formatter Documentation](http://pygments.org/docs/formatters/#HtmlFormatter) for details. + + +## Generate Syntax Highlighter CSS + +If you run with `pygmentsUseClasses=true` in your site config, you need a style sheet. + +You can generate one with Hugo: + +```bash +hugo gen chromastyles --style=monokai > syntax.css +``` + +Run `hugo gen chromastyles -h` for more options. See https://help.farbox.com/pygments.html for a gallery of available styles. + + +## Highlight Shortcode + +Highlighting is carried out via the [built-in shortcode](/content-management/shortcodes/) `highlight`. `highlight` takes exactly one required parameter for the programming language to be highlighted and requires a closing shortcode. Note that `highlight` is *not* used for client-side javascript highlighting. + +### Example `highlight` Shortcode + +{{< code file="example-highlight-shortcode-input.md" >}} +{{}} +
+
+

{{ .Title }}

+ {{ range .Data.Pages }} + {{ .Render "summary"}} + {{ end }} +
+
+{{}} +{{< /code >}} + + + +## Highlight Template Func + +See [Highlight](/functions/highlight/). + +## Highlight in Code Fences + +It is also possible to add syntax highlighting with GitHub flavored code fences. To enable this, set the `pygmentsCodeFences` to `true` in Hugo's [configuration file](/getting-started/configuration/); + +```` +```html +
+
+

{{ .Title }}

+ {{ range .Data.Pages }} + {{ .Render "summary"}} + {{ end }} +
+
+``` +```` + + +## Highlight with Pygments Classic + +If you for some reason don't want to use the built-in Chroma highlighter, you can set `pygmentsUseClassic=true` in your config and add Pygments to your path. + +{{% note "Disclaimers on Pygments" %}} +* Pygments is relatively slow and _causes a performance hit when building your site_, but Hugo has been designed to cache the results to disk. +* The caching can be turned off by setting the `--ignoreCache` flag to `true`. +* The languages available for highlighting depend on your Pygments installation. +{{% /note %}} + +If you have never worked with Pygments before, here is a brief primer: + ++ Install Python from [python.org](https://www.python.org/downloads/). Version 2.7.x is already sufficient. ++ Run `pip install Pygments` in order to install Pygments. Once installed, Pygments gives you a command `pygmentize`. Make sure it sits in your PATH; otherwise, Hugo will not be able to find and use it. + +On Debian and Ubuntu systems, you may also install Pygments by running `sudo apt-get install python3-pygments`. + + + +[Prism]: http://prismjs.com +[prismdownload]: http://prismjs.com/download.html +[Highlight.js]: http://highlightjs.org/ +[Rainbow]: http://craig.is/making/rainbows +[Syntax Highlighter]: http://alexgorbatchev.com/SyntaxHighlighter/ +[Google Prettify]: https://github.com/google/code-prettify +[Yandex]: http://yandex.ru/ diff --cc docs/content/functions/GetPage.md index 669589c1,00000000..1a8a51c1 mode 100644,000000..100644 --- a/docs/content/functions/GetPage.md +++ b/docs/content/functions/GetPage.md @@@ -1,65 -1,0 +1,82 @@@ +--- +title: .GetPage +description: "Gets a `Page` of a given `Kind` and `path`." +godocref: +date: 2017-02-01 +publishdate: 2017-02-01 +lastmod: 2017-02-01 +categories: [functions] +menu: + docs: + parent: "functions" +keywords: [sections,lists,indexes] - signature: [".GetPage TYPE PATH"] ++signature: [".GetPage KIND PATH"] +workson: [] +hugoversion: +relatedfuncs: [] +deprecated: false +aliases: [] +--- + - Every `Page` has a `Kind` attribute that shows what kind of page it is. While this attribute can be used to list pages of a certain `kind` using `where`, often it can be useful to fetch a single page by its path. ++Every `Page` has a [`Kind` attribute][page_kinds] that shows what kind of page it is. While this attribute can be used to list pages of a certain `kind` using `where`, often it can be useful to fetch a single page by its path. + - `.GetPage` looks up a page of a given `Kind` and `path`. ++`.GetPage` returns a page of a given `Kind` and `path`. ++ ++{{% note %}} ++If the `path` is `"foo/bar.md"`, it can be written as exactly that, or broken up ++into multiple strings as `"foo" "bar.md"`. ++{{% /note %}} + +``` +{{ with .Site.GetPage "section" "blog" }}{{ .Title }}{{ end }} +``` + - This method wil return `nil` when no page could be found, so the above will not print anything if the blog section isn't found. ++This method wil return `nil` when no page could be found, so the above will not print anything if the blog section is not found. + - For a regular page: ++For a regular page (whose `Kind` is `page`): + +``` - {{ with .Site.GetPage "page" "blog" "my-post.md" }}{{ .Title }}{{ end }} ++{{ with .Site.GetPage "page" "blog/my-post.md" }}{{ .Title }}{{ end }} +``` + - Note that the path can also be supplied like this: ++Note that the `path` can also be supplied like this, where the slash-separated ++path elements are added as separate strings: + +``` - {{ with .Site.GetPage "page" "blog/my-post.md" }}{{ .Title }}{{ end }} ++{{ with .Site.GetPage "page" "blog" "my-post.md" }}{{ .Title }}{{ end }} +``` + - The valid page kinds are: *page, home, section, taxonomy and taxonomyTerm.* - +## `.GetPage` Example + +This code snippet---in the form of a [partial template][partials]---allows you to do the following: + +1. Grab the index object of your `tags` [taxonomy][]. +2. Assign this object to a variable, `$t` +3. Sort the terms associated with the taxonomy by popularity. +4. Grab the top two most popular terms in the taxonomy (i.e., the two most popular tags assigned to content. + +{{< code file="grab-top-two-tags.html" >}} + +{{< /code >}} + ++## `.GetPage` on Page Bundles ++ ++If the page retrieved by `.GetPage` is a [Leaf Bundle][leaf_bundle], and you ++need to get the nested _**page** resources_ in that, you will need to use the ++methods in `.Resources` as explained in the [Page Resources][page_resources] ++section. ++ ++See the [Headless Bundle][headless_bundle] documentation for an example. ++ + +[partials]: /templates/partials/ +[taxonomy]: /content-management/taxonomies/ ++[page_kinds]: /templates/section-templates/#page-kinds ++[leaf_bundle]: /content-management/page-bundles/#leaf-bundles ++[headless_bundle]: /content-management/page-bundles/#headless-bundle ++[page_resources]: /content-management/page-resources/ diff --cc docs/content/getting-started/code-toggle.md index 00000000,00000000..ae3e3e84 new file mode 100644 --- /dev/null +++ b/docs/content/getting-started/code-toggle.md @@@ -1,0 -1,0 +1,75 @@@ ++--- ++title: Code Toggle ++description: Code Toggle tryout and showcase. ++date: 2018-03-16 ++categories: [getting started,fundamentals] ++keywords: [configuration,toml,yaml,json] ++weight: 60 ++sections_weight: 60 ++draft: false ++toc: true ++--- ++ ++## The Config Toggler! ++ ++This is an exemple for the Config Toggle shortcode. ++Its purpose is to let users choose a Config language by clicking on its corresponding tab. Upon doing so, every Code toggler on the page will be switched to the target language. Also, target language will be saved in user's `localStorage` so when they go to a different pages, Code Toggler display their last "toggled" config language. ++ ++## That Congig Toggler ++ ++{{< code-toggle file="config">}} ++ ++baseURL: "https://yoursite.example.com/" ++title: "My Hugo Site" ++footnoteReturnLinkContents: "↩" ++permalinks: ++ post: /:year/:month/:title/ ++params: ++ Subtitle: "Hugo is Absurdly Fast!" ++ AuthorName: "Jon Doe" ++ GitHubUser: "spf13" ++ ListOfFoo: ++ - "foo1" ++ - "foo2" ++ SidebarRecentLimit: 5 ++{{< /code-toggle >}} ++ ++## Another Config Toggler! ++ ++{{< code-toggle file="theme">}} ++ ++# theme.toml template for a Hugo theme ++ ++name = "Hugo Theme" ++license = "MIT" ++licenselink = "https://github.com/budparr/gohugo.io/blob/master/LICENSE.md" ++description = "" ++homepage = "https://github.com/budparr/gohugo.io" ++tags = ["website"] ++features = ["", ""] ++min_version = 0.18 ++ ++[author] ++ name = "Bud Parr" ++ homepage = "https://github.com/budparr" ++ ++{{< /code-toggle >}} ++ ++## Two regular code blocks ++ ++{{< code file="bf-config.toml" >}} ++[blackfriday] ++ angledQuotes = true ++ fractions = false ++ plainIDAnchors = true ++ extensions = ["hardLineBreak"] ++{{< /code >}} ++ ++{{< code file="bf-config.yml" >}} ++blackfriday: ++ angledQuotes: true ++ fractions: false ++ plainIDAnchors: true ++ extensions: ++ - hardLineBreak ++{{< /code >}} diff --cc docs/content/getting-started/configuration.md index 292b3e68,00000000..ba2c87e8 mode 100644,000000..100644 --- a/docs/content/getting-started/configuration.md +++ b/docs/content/getting-started/configuration.md @@@ -1,436 -1,0 +1,453 @@@ +--- +title: Configure Hugo +linktitle: Configuration +description: How to configure your Hugo site. +date: 2013-07-01 +publishdate: 2017-01-02 +lastmod: 2017-03-05 +categories: [getting started,fundamentals] +keywords: [configuration,toml,yaml,json] +menu: + docs: + parent: "getting-started" + weight: 60 +weight: 60 +sections_weight: 60 +draft: false +aliases: [/overview/source-directory/,/overview/configuration/] +toc: true +--- + +Hugo uses the `config.toml`, `config.yaml`, or `config.json` (if found in the +site root) as the default site config file. + +The user can choose to override that default with one or more site config files +using the command line `--config` switch. + +Examples: + +``` +hugo --config debugconfig.toml +hugo --config a.toml,b.toml,c.toml +``` + +{{% note %}} +Multiple site config files can be specified as a comma-separated string to the `--config` switch. +{{% /note %}} + +## All Configuration Settings + +The following is the full list of Hugo-defined variables with their default +value in parentheses. Users may choose to override those values in their site +config file(s). + +archetypeDir ("archetypes") +: The directory where Hugo finds archetype files (content templates). + +baseURL +: Hostname (and path) to the root, e.g. http://bep.is/ + +blackfriday +: See [Configure Blackfriday](/getting-started/configuration/#configure-blackfriday) + +buildDrafts (false) +: Include drafts when building. + +buildExpired (false) +: Include content already expired. + +buildFuture (false) +: Include content with publishdate in the future. + +canonifyURLs (false) +: Enable to turn relative URLs into absolute. + +contentDir ("content") +: The directory from where Hugo reads content files. + +dataDir ("data") +: The directory from where Hugo reads data files. + +defaultContentLanguage ("en") +: Content without language indicator will default to this language. + +defaultContentLanguageInSubdir (false) +: Render the default content language in subdir, e.g. `content/en/`. The site root `/` will then redirect to `/en/`. + +disableHugoGeneratorInject (false) +: Hugo will, by default, inject a generator meta tag in the HTML head on the _home page only_. You can turn it off, but we would really appreciate if you don't, as this is a good way to watch Hugo's popularity on the rise. + +disableKinds ([]) +: Enable disabling of all pages of the specified *Kinds*. Allowed values in this list: `"page"`, `"home"`, `"section"`, `"taxonomy"`, `"taxonomyTerm"`, `"RSS"`, `"sitemap"`, `"robotsTXT"`, `"404"`. + +disableLiveReload (false) +: Disable automatic live reloading of browser window. + +disablePathToLower (false) +: Do not convert the url/path to lowercase. + +enableEmoji (false) +: Enable Emoji emoticons support for page content; see the [Emoji Cheat Sheet](https://www.webpagefx.com/tools/emoji-cheat-sheet/). + +enableGitInfo (false) +: Enable `.GitInfo` object for each page (if the Hugo site is versioned by Git). This will then update the `Lastmod` parameter for each page using the last git commit date for that content file. + +enableMissingTranslationPlaceholders (false) +: Show a placeholder instead of the default value or an empty string if a translation is missing. + +enableRobotsTXT (false) +: Enable generation of `robots.txt` file. + +frontmatter + +: See [Front matter Configuration](#configure-front-matter). + +footnoteAnchorPrefix ("") +: Prefix for footnote anchors. + +footnoteReturnLinkContents ("") +: Text to display for footnote return links. + +googleAnalytics ("") +: Google Analytics tracking ID. + +hasCJKLanguage (false) +: If true, auto-detect Chinese/Japanese/Korean Languages in the content. This will make `.Summary` and `.WordCount` behave correctly for CJK languages. + +imaging +: See [Image Processing Config](/content-management/image-processing/#image-processing-config). + +languages +: See [Configure Languages](/content-management/multilingual/#configure-languages). + +languageCode ("") +: The site's language code. + +disableLanguages +: See [Disable a Language](/content-management/multilingual/#disable-a-language) + +layoutDir ("layouts") +: The directory from where Hugo reads layouts (templates). + +log (false) +: Enable logging. + +logFile ("") +: Log File path (if set, logging enabled automatically). + +menu +: See [Add Non-content Entries to a Menu](/content-management/menus/#add-non-content-entries-to-a-menu). + +metaDataFormat ("toml") +: Front matter meta-data format. Valid values: `"toml"`, `"yaml"`, or `"json"`. + +newContentEditor ("") +: The editor to use when creating new content. + +noChmod (false) +: Don't sync permission mode of files. + +noTimes (false) +: Don't sync modification time of files. + +paginate (10) +: Default number of pages per page in [pagination](/templates/pagination/). + +paginatePath ("page") +: The path element used during pagination (https://example.com/page/2). + +permalinks +: See [Content Management](/content-management/urls/#permalinks). + +pluralizeListTitles (true) +: Pluralize titles in lists. + +preserveTaxonomyNames (false) +: Preserve special characters in taxonomy names ("Gérard Depardieu" vs "Gerard Depardieu"). + +publishDir ("public") +: The directory to where Hugo will write the final static site (the HTML files etc.). + +pygmentsCodeFencesGuessSyntax (false) +: Enable syntax guessing for code fences without specified language. + +pygmentsStyle ("monokai") +: Color-theme or style for syntax highlighting. See [Pygments Color Themes](https://help.farbox.com/pygments.html). + +pygmentsUseClasses (false) +: Enable using external CSS for syntax highlighting. + +related +: See [Related Content](/content-management/related/#configure-related-content). + +relativeURLs (false) +: Enable this to make all relative URLs relative to content root. Note that this does not affect absolute URLs. + +rssLimit (unlimited) +: Maximum number of items in the RSS feed. + +sectionPagesMenu ("") +: See ["Section Menu for Lazy Bloggers"](/templates/menu-templates/#section-menu-for-lazy-bloggers). + +sitemap +: Default [sitemap configuration](/templates/sitemap-template/#configure-sitemap-xml). + +staticDir ("static") +: Relative directory from where Hugo reads static files. + +stepAnalysis (false) +: Display memory and timing of different steps of the program. + +summaryLength (70) +: The length of text to show in a [`.Summary`](/content-management/summaries/#hugo-defined-automatic-summary-splitting). + +taxonomies - : See [Configure Taxonomies](content-management/taxonomies#configure-taxonomies). ++: See [Configure Taxonomies](/content-management/taxonomies#configure-taxonomies). + +theme ("") +: Theme to use (located by default in `/themes/THEMENAME/`). + +themesDir ("themes") +: The directory where Hugo reads the themes from. + +title ("") +: Site title. + +uglyURLs (false) - : When enabled, creates URL on the form `/filename.html` instead of `/filename/`. ++: When enabled, creates URL of the form `/filename.html` instead of `/filename/`. + +verbose (false) +: Enable verbose output. + +verboseLog (false) +: Enable verbose logging. + +watch (false) +: Watch filesystem for changes and recreate as needed. + +{{% note %}} +If you are developing your site on a \*nix machine, here is a handy shortcut for finding a configuration option from the command line: +``` +cd ~/sites/yourhugosite +hugo config | grep emoji +``` + +which shows output like + +``` +enableemoji: true +``` +{{% /note %}} + +## Configuration Lookup Order + +Similar to the template [lookup order][], Hugo has a default set of rules for searching for a configuration file in the root of your website's source directory as a default behavior: + +1. `./config.toml` +2. `./config.yaml` +3. `./config.json` + +In your `config` file, you can direct Hugo as to how you want your website rendered, control your website's menus, and arbitrarily define site-wide parameters specific to your project. + ++ +## YAML Configuration + ++{{< code file="config.yml">}} ++baseURL: "https://yoursite.example.com/" ++title: "My Hugo Site" ++footnoteReturnLinkContents: "↩" ++permalinks: ++ post: /:year/:month/:title/ ++params: ++ Subtitle: "Hugo is Absurdly Fast!" ++ AuthorName: "Jon Doe" ++ GitHubUser: "spf13" ++ ListOfFoo: ++ - "foo1" ++ - "foo2" ++ SidebarRecentLimit: 5 ++{{< /code >}} ++ +The following is a typical example of a YAML configuration file. The values nested under `params:` will populate the [`.Site.Params`][] variable for use in [templates][]: + +{{< code file="config.yml">}} +baseURL: "https://yoursite.example.com/" +title: "My Hugo Site" +footnoteReturnLinkContents: "↩" +permalinks: + post: /:year/:month/:title/ +params: + Subtitle: "Hugo is Absurdly Fast!" + AuthorName: "Jon Doe" + GitHubUser: "spf13" + ListOfFoo: + - "foo1" + - "foo2" + SidebarRecentLimit: 5 +{{< /code >}} + +## TOML Configuration + +The following is an example of a TOML configuration file. The values under `[params]` will populate the `.Site.Params` variable for use in [templates][]: + +{{< code file="config.toml">}} +contentDir = "content" +layoutDir = "layouts" +publishDir = "public" +buildDrafts = false +baseURL = "https://yoursite.example.com/" +canonifyURLs = true +title = "My Hugo Site" + +[taxonomies] + category = "categories" + tag = "tags" + +[params] + subtitle = "Hugo is Absurdly Fast!" + author = "John Doe" +{{< /code >}} + + + +## Configure with Environment Variables + +In addition to the 3 config options already mentioned, configuration key-values can be defined through operating system environment variables. + +For example, the following command will effectively set a website's title on Unix-like systems: + +``` +$ env HUGO_TITLE="Some Title" hugo +``` + +This is really useful if you use a service such as Netlify to deploy your site. Look at the Hugo docs [Netlify configuration file](https://github.com/gohugoio/hugoDocs/blob/master/netlify.toml) for an example. + +{{% note "Setting Environment Variables" %}} +Names must be prefixed with `HUGO_` and the configuration key must be set in uppercase when setting operating system environment variables. +{{% /note %}} + +{{< todo >}} +Test and document setting params via JSON env var. +{{< /todo >}} + +## Ignore Files When Rendering + +The following statement inside `./config.toml` will cause Hugo to ignore files ending with `.foo` and `.boo` when rendering: + +``` +ignoreFiles = [ "\\.foo$", "\\.boo$" ] +``` + +The above is a list of regular expressions. Note that the backslash (`\`) character is escaped in this example to keep TOML happy. + +## Configure Front Matter + +### Configure Dates + +Dates are important in Hugo, and you can configure how Hugo assigns dates to your content pages. You do this by adding a `frontmatter` section to your `config.toml`. + + +The default configuration is: + +```toml +[frontmatter] +date = ["date","publishDate", "lastmod"] +lastmod = [":git" "lastmod", "date","publishDate"] +publishDate = ["publishDate", "date"] +expiryDate = ["expiryDate"] +``` + +If you, as an example, have a non-standard date parameter in some of your content, you can override the setting for `date`: + + ```toml +[frontmatter] +date = [ "myDate", ":default"] +``` + +The `:default` is a shortcut to the default settings. The above will set `.Date` to the date value in `myDate` if present, if not we will look in `date`,`publishDate`, `lastmod` and pick the first valid date. + +In the list to the right, values starting with ":" are date handlers with a special meaning (see below). The others are just names of date parameters (case insensitive) in your front matter configuration. Also note that Hugo have some built-in aliases to the above: `lastmod` => `modified`, `publishDate` => `pubdate`, `published` and `expiryDate` => `unpublishdate`. With that, as an example, using `pubDate` as a date in front matter, will, by default, be assigned to `.PublishDate`. + +The special date handlers are: + + +`:fileModTime` +: Fetches the date from the content file's last modification timestamp. + +An example: + + ```toml +[frontmatter] +lastmod = ["lastmod" ,":fileModTime", ":default"] +``` + + +The above will try first to extract the value for `.Lastmod` starting with the `lastmod` front matter parameter, then the content file's modification timestamp. The last, `:default` should not be needed here, but Hugo will finally look for a valid date in `:git`, `date` and then `publishDate`. + + +`:filename` +: Fetches the date from the content file's filename. For example, `218-02-22-mypage.md` will extract the date `218-02-22`. Also, if `slug is not set, `mypage` will be used as the value for `.Slug`. + +An example: + +```toml +[frontmatter] +date = [":filename", ":default"] +``` + +The above will try first to extract the value for `.Date` from the filename, then it will look in front matter parameters `date`, `publishDate` and lastly `lastmod`. + + +`:git` +: This is the Git author date for the last revision of this content file. This will only be set if `--enableGitInfo` is set or `enableGitInfo = true` is set in site config. + +## Configure Blackfriday + +[Blackfriday](https://github.com/russross/blackfriday) is Hugo's built-in Markdown rendering engine. + +Hugo typically configures Blackfriday with sane default values that should fit most use cases reasonably well. + +However, if you have specific needs with respect to Markdown, Hugo exposes some of its Blackfriday behavior options for you to alter. The following table lists these Hugo options, paired with the corresponding flags from Blackfriday's source code ( [html.go](https://github.com/russross/blackfriday/blob/master/html.go) and [markdown.go](https://github.com/russross/blackfriday/blob/master/markdown.go)). + +{{< readfile file="/content/readfiles/bfconfig.md" markdown="true" >}} + +{{% note %}} +1. Blackfriday flags are *case sensitive* as of Hugo v0.15. +2. Blackfriday flags must be grouped under the `blackfriday` key and can be set on both the site level *and* the page level. Any setting on a page will override its respective site setting. +{{% /note %}} + +{{< code file="bf-config.toml" >}} +[blackfriday] + angledQuotes = true + fractions = false + plainIDAnchors = true + extensions = ["hardLineBreak"] +{{< /code >}} + +{{< code file="bf-config.yml" >}} +blackfriday: + angledQuotes: true + fractions: false + plainIDAnchors: true + extensions: + - hardLineBreak +{{< /code >}} + +## Configure Additional Output Formats + +Hugo v0.20 introduced the ability to render your content to multiple output formats (e.g., to JSON, AMP html, or CSV). See [Output Formats][] for information on how to add these values to your Hugo project's configuration file. + +## Configuration Format Specs + +* [TOML Spec][toml] +* [YAML Spec][yaml] +* [JSON Spec][json] + +[`.Site.Params`]: /variables/site/ +[directory structure]: /getting-started/directory-structure +[json]: https://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf "Specification for JSON, JavaScript Object Notation" +[lookup order]: /templates/lookup-order/ +[Output Formats]: /templates/output-formats/ +[templates]: /templates/ +[toml]: https://github.com/toml-lang/toml +[yaml]: http://yaml.org/spec/ diff --cc docs/content/hosting-and-deployment/hosting-on-gitlab.md index 9c4a8978,00000000..c38908ca mode 100644,000000..100644 --- a/docs/content/hosting-and-deployment/hosting-on-gitlab.md +++ b/docs/content/hosting-and-deployment/hosting-on-gitlab.md @@@ -1,92 -1,0 +1,84 @@@ +--- +title: Host on GitLab +linktitle: Host on GitLab +description: GitLab makes it incredibly easy to build, deploy, and host your Hugo website via their free GitLab Pages service, which provides native support for Hugo. +date: 2016-06-23 +publishdate: 2016-06-23 +lastmod: 2017-11-16 +categories: [hosting and deployment] +keywords: [hosting,deployment,git,gitlab] +authors: [Riku-Pekka Silvola] +menu: + docs: + parent: "hosting-and-deployment" + weight: 40 +weight: 40 +sections_weight: 40 +draft: false +toc: true +wip: false +aliases: [/tutorials/hosting-on-gitlab/] +--- + - {{% warning %}} - GitLab has temporarily turned off custom domains support because of a security issue. The plan is to re-enable it after the 20th of February. - For more information: - https://about.gitlab.com/2018/02/05/gitlab-pages-custom-domain-validation/ - {{% /warning %}} - - {{< todo >}}Remove the above when fixed.{{< /todo >}} - +[GitLab](https://gitlab.com/) makes it incredibly easy to build, deploy, and host your Hugo website via their free GitLab Pages service, which provides [native support for Hugo, as well as numerous other static site generators](https://gitlab.com/pages/hugo). + +## Assumptions + +* Working familiarity with Git for version control +* Completion of the Hugo [Quick Start][] +* A [GitLab account](https://gitlab.com/users/sign_in) +* A Hugo website on your local machine that you are ready to publish + +## Create .gitlab-ci.yml + +``` +cd your-hugo-site +``` + +In the root directory of your Hugo site, create a `.gitlab-ci.yml` file. The `.gitlab-ci.yml` configures the GitLab CI on how to build your page. Simply add the content below. + +{{< code file="gitlab-ci.yml" >}} +image: monachus/hugo + +variables: + GIT_SUBMODULE_STRATEGY: recursive + +pages: + script: + - hugo + artifacts: + paths: + - public + only: + - master +{{< /code >}} + +## Push Your Hugo Website to GitLab + +Next, create a new repository on GitLab. It is *not* necessary to make the repository public. In addition, you might want to add `/public` to your .gitignore file, as there is no need to push compiled assets to GitLab or keep your output website in version control. + +``` +# initialize new git repository +git init + +# add /public directory to our .gitignore file +echo "/public" >> .gitignore + +# commit and push code to master branch +git add . +git commit -m "Initial commit" +git remote add origin https://gitlab.com/YourUsername/your-hugo-site.git +git push -u origin master +``` + +## Wait for Your Page to Build + +That's it! You can now follow the CI agent building your page at `https://gitlab.com///pipelines`. + +After the build has passed, your new website is available at `https://.gitlab.io//`. + +## Next Steps + +GitLab supports using custom CNAME's and TLS certificates. For more details on GitLab Pages, see the [GitLab Pages setup documentation](https://about.gitlab.com/2016/04/07/gitlab-pages-setup/). + +[Quick Start]: /getting-started/quick-start/ diff --cc docs/content/templates/data-templates.md index 385bd10a,00000000..c0b2b514 mode 100644,000000..100644 --- a/docs/content/templates/data-templates.md +++ b/docs/content/templates/data-templates.md @@@ -1,255 -1,0 +1,255 @@@ +--- +title: Data Templates +linktitle: +description: In addition to Hugo's built-in variables, you can specify your own custom data in templates or shortcodes that pull from both local and dynamic sources. +date: 2017-02-01 +publishdate: 2017-02-01 +lastmod: 2017-03-12 +categories: [templates] +keywords: [data,dynamic,csv,json,toml,yaml] +menu: + docs: + parent: "templates" + weight: 80 +weight: 80 +sections_weight: 80 +draft: false +aliases: [/extras/datafiles/,/extras/datadrivencontent/,/doc/datafiles/] +toc: true +--- + + + +Hugo supports loading data from YAML, JSON, and TOML files located in the `data` directory in the root of your Hugo project. + +{{< youtube FyPgSuwIMWQ >}} + +## The Data Folder + +The `data` folder is where you can store additional data for Hugo to use when generating your site. Data files aren't used to generate standalone pages; rather, they're meant to be supplemental to content files. This feature can extend the content in case your front matter fields grow out of control. Or perhaps you want to show a larger dataset in a template (see example below). In both cases, it's a good idea to outsource the data in their own files. + +These files must be YAML, JSON, or TOML files (using the `.yml`, `.yaml`, `.json`, or `.toml` extension). The data will be accessible as a `map` in the `.Site.Data` variable. + +## Data Files in Themes + +Data Files can also be used in [Hugo themes][themes] but note that theme data files follow the same logic as other template files in the [Hugo lookup order][lookup] (i.e., given two files with the same name and relative path, the file in the root project `data` directory will override the file in the `themes//data` directory). + +Therefore, theme authors should take care to not include data files that could be easily overwritten by a user who decides to [customize a theme][customize]. For theme-specific data items that shouldn't be overridden, it can be wise to prefix the folder structure with a namespace; e.g. `mytheme/data//somekey/...`. To check if any such duplicate exists, run hugo with the `-v` flag. + +The keys in the map created with data templates from data files will be a dot-chained set of `path`, `filename`, and `key` in file (if applicable). + +This is best explained with an example: + +## Example: Jaco Pastorius' Solo Discography + +[Jaco Pastorius](http://en.wikipedia.org/wiki/Jaco_Pastorius_discography) was a great bass player, but his solo discography is short enough to use as an example. [John Patitucci](http://en.wikipedia.org/wiki/John_Patitucci) is another bass giant. + +The example below is a bit contrived, but it illustrates the flexibility of data Files. This example uses TOML as its file format with the two following data files: + +* `data/jazz/bass/jacopastorius.toml` +* `data/jazz/bass/johnpatitucci.toml` + +`jacopastorius.toml` contains the content below. `johnpatitucci.toml` contains a similar list: + +``` +discography = [ +"1974 – Modern American Music … Period! The Criteria Sessions", +"1974 – Jaco", +"1976 - Jaco Pastorius", +"1981 - Word of Mouth", +"1981 - The Birthday Concert (released in 1995)", +"1982 - Twins I & II (released in 1999)", +"1983 - Invitation", +"1986 - Broadway Blues (released in 1998)", +"1986 - Honestly Solo Live (released in 1990)", +"1986 - Live In Italy (released in 1991)", +"1986 - Heavy'n Jazz (released in 1992)", +"1991 - Live In New York City, Volumes 1-7.", +"1999 - Rare Collection (compilation)", +"2003 - Punk Jazz: The Jaco Pastorius Anthology (compilation)", +"2007 - The Essential Jaco Pastorius (compilation)" +] +``` + +The list of bass players can be accessed via `.Site.Data.jazz.bass`, a single bass player by adding the filename without the suffix, e.g. `.Site.Data.jazz.bass.jacopastorius`. + +You can now render the list of recordings for all the bass players in a template: + +``` +{{ range $.Site.Data.jazz.bass }} + {{ partial "artist.html" . }} +{{ end }} +``` + +And then in the `partials/artist.html`: + +``` +
    +{{ range .discography }} +
  • {{ . }}
  • +{{ end }} +
+``` + +Discover a new favorite bass player? Just add another `.toml` file in the same directory. + +## Example: Accessing Named Values in a Data File + +Assume you have the following YAML structure in your `User0123.yml` data file located directly in `data/`: + +``` +Name: User0123 +"Short Description": "He is a **jolly good** fellow." +Achievements: + - "Can create a Key, Value list from Data File" + - "Learns Hugo" + - "Reads documentation" +``` + +You can use the following code to render the `Short Description` in your layout:: + +``` +
Short Description of {{.Site.Data.User0123.Name}}:

{{ index .Site.Data.User0123 "Short Description" | markdownify }}

+``` + +Note the use of the [`markdownify` template function][markdownify]. This will send the description through the Blackfriday Markdown rendering engine. + + + +## Data-Driven Content + - In addition to the [data files](/extras/datafiles/) feature, Hugo also a "data-driven content" feature, which lets you load any [JSON](http://www.json.org/) or [CSV](http://en.wikipedia.org/wiki/Comma-separated_values) file from nearly any resource. ++In addition to the [data files](/extras/datafiles/) feature, Hugo also has a "data-driven content" feature, which lets you load any [JSON](http://www.json.org/) or [CSV](http://en.wikipedia.org/wiki/Comma-separated_values) file from nearly any resource. + +Data-driven content currently consists of two functions, `getJSON` and `getCSV`, which are available in all template files. + +## Implementation details + +### Call the Functions with a URL + +In your template, call the functions like this: + +``` +{{ $dataJ := getJSON "url" }} +{{ $dataC := getCSV "separator" "url" }} +``` + +If you use a prefix or postfix for the URL, the functions accept [variadic arguments][variadic]: + +``` +{{ $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 be one character long. + +All passed arguments will be joined to the final URL: + +``` +{{ $urlPre := "https://api.github.com" }} +{{ $gistJ := getJSON $urlPre "/users/GITHUB_USERNAME/gists" }} +``` + +This will resolve internally to the following: + +``` +{{ $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: + +``` +
    + {{ $urlPre := "https://api.github.com" }} + {{ $gistJ := getJSON $urlPre "/users/GITHUB_USERNAME/gists" }} + {{ range first 5 $gistJ }} + {{ if .public }} +
  • {{ .description }}
  • + {{ end }} + {{ end }} +
+``` + +### Example for CSV files + +For `getCSV`, the one-character-long separator must be placed in the first position followed by the URL. The following is an example of creating an HTML table in a [partial template][partials] from a published CSV: + +{{< code file="layouts/partials/get-csv.html" >}} + + + + + + + + + + {{ $url := "http://a-big-corp.com/finance/employee-salaries.csv" }} + {{ $sep := "," }} + {{ range $i, $r := getCSV $sep $url }} + + + + + + {{ end }} + +
NamePositionSalary
{{ index $r 0 }}{{ index $r 1 }}{{ index $r 2 }}
+{{< /code >}} + +The expression `{{index $r number}}` must be used to output the nth-column from the current row. + +### Cache URLs + +Each downloaded URL will be cached in the default folder `$TMPDIR/hugo_cache/`. The variable `$TMPDIR` will be resolved to your system-dependent temporary directory. + +With the command-line flag `--cacheDir`, you can specify any folder on your system as a caching directory. + +You can also set `cacheDir` in the [main configuration file][config]. + +If you don't like caching at all, you can fully disable caching with the command line flag `--ignoreCache`. + +### Authentication When Using REST URLs + +Currently, you can only use those authentication methods that can be put into an URL. [OAuth][] and other authentication methods are not implemented. + +### Load Local files + +To load local files with `getJSON` and `getCSV`, the source files must reside within Hugo's working directory. The file extension does not matter, but the content does. + +It applies the same output logic as above in [Calling the Functions with a URL](#calling-the-functions-with-a-url). + +## LiveReload with Data Files + +There is no chance to trigger a [LiveReload][] when the content of a URL changes. However, when a *local* file changes (i.e., `data/*` and `themes//data/*`), a LiveReload will be triggered. Symlinks are not supported. Note too that because downloading of data takes a while, Hugo stops processing your Markdown files until the data download has completed. + +{{% warning "URL Data and LiveReload" %}} +If you change any local file and the LiveReload is triggered, Hugo will read the data-driven (URL) content from the cache. If you have disabled the cache (i.e., by running the server with `hugo server --ignoreCache`), Hugo will re-download the content every time LiveReload triggers. This can create *huge* traffic. You may reach API limits quickly. +{{% /warning %}} + +## Examples of Data-driven Content + +- Photo gallery JSON powered: [https://github.com/pcdummy/hugo-lightslider-example](https://github.com/pcdummy/hugo-lightslider-example) +- GitHub Starred Repositories [in a post](https://github.com/SchumacherFM/blog-cs/blob/master/content%2Fposts%2Fgithub-starred.md) using data-driven content in a [custom short code](https://github.com/SchumacherFM/blog-cs/blob/master/layouts%2Fshortcodes%2FghStarred.html). + +## Specs for Data Formats + +* [TOML Spec][toml] +* [YAML Spec][yaml] +* [JSON Spec][json] +* [CSV Spec][csv] + +[config]: /getting-started/configuration/ +[csv]: https://tools.ietf.org/html/rfc4180 +[customize]: /themes/customizing/ +[json]: https://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf "Specification for JSON, JavaScript Object Notation" +[LiveReload]: /getting-started/usage/#livereload +[lookup]: /templates/lookup-order/ +[markdownify]: /functions/markdownify/ +[OAuth]: http://en.wikipedia.org/wiki/OAuth +[partials]: /templates/partials/ +[themes]: /themes/ +[toml]: https://github.com/toml-lang/toml +[variadic]: http://en.wikipedia.org/wiki/Variadic_function +[vars]: /variables/ +[yaml]: http://yaml.org/spec/ diff --cc docs/content/troubleshooting/build-performance.md index fa8929c7,00000000..bc4d30d5 mode 100644,000000..100644 --- a/docs/content/troubleshooting/build-performance.md +++ b/docs/content/troubleshooting/build-performance.md @@@ -1,111 -1,0 +1,111 @@@ +--- +title: Build Performance +linktitle: Build Performance +description: An overview of features used for diagnosing and improving performance issues in site builds. +date: 2017-03-12 +publishdate: 2017-03-12 +lastmod: 2017-03-12 +keywords: [performance, build] +categories: [troubleshooting] +menu: + docs: + parent: "troubleshooting" +weight: 3 +slug: +aliases: [] +toc: true +--- + +{{% note %}} - The example site used below is from https://github.com/gohugoio/hugo/examples/blog ++The example site used below is from https://github.com/gohugoio/hugo/tree/master/examples/blog +{{% /note %}} + +## Template Metrics + +Hugo is a very fast static site generator, but it is possible to write +inefficient templates. Hugo's *template metrics* feature is extremely helpful +in pinpointing which templates are executed most often and how long those +executions take **in terms of CPU time**. + +| Metric Name | Description | +|---------------------|-------------| +| cumulative duration | The cumulative time spent executing a given template. | +| average duration | The average time spent executing a given template. | +| maximum duration | The maximum time a single execution took for a given template. | +| count | The number of times a template was executed. | +| template | The template name. | + +``` +▶ hugo --templateMetrics +Started building sites ... + +Built site for language en: +0 draft content +0 future content +0 expired content +2 regular pages created +22 other pages created +0 non-page files copied +0 paginator pages created +4 tags created +3 categories created +total in 18 ms + +Template Metrics: + + cumulative average maximum + duration duration duration count template + ---------- -------- -------- ----- -------- + 6.419663ms 583.605µs 994.374µs 11 _internal/_default/rss.xml + 4.718511ms 1.572837ms 3.880742ms 3 indexes/category.html + 4.642666ms 2.321333ms 3.282842ms 2 post/single.html + 4.364445ms 396.767µs 2.451372ms 11 partials/header.html + 2.346069ms 586.517µs 903.343µs 4 indexes/tag.html + 2.330919ms 211.901µs 2.281342ms 11 partials/header.includes.html + 1.238976ms 103.248µs 446.084µs 12 post/li.html + 972.16µs 972.16µs 972.16µs 1 _internal/_default/sitemap.xml + 953.597µs 953.597µs 953.597µs 1 index.html + 822.263µs 822.263µs 822.263µs 1 indexes/post.html + 567.498µs 51.59µs 112.205µs 11 partials/navbar.html + 348.22µs 31.656µs 88.249µs 11 partials/meta.html + 346.782µs 173.391µs 276.176µs 2 post/summary.html + 235.184µs 21.38µs 124.383µs 11 partials/footer.copyright.html + 132.003µs 12µs 117.999µs 11 partials/menu.html + 72.547µs 6.595µs 63.764µs 11 partials/footer.html +``` + +{{% note %}} +**A Note About Parallelism** + +Hugo builds pages in parallel where multiple pages are generated +simultaneously. Because of this parallelism, the sum of "cumulative duration" +values is usually greater than the actual time it takes to build a site. +{{% /note %}} + + +## Cached Partials + +Some `partial` templates such as sidebars or menus are executed many times +during a site build. Depending on the content within the `partial` template and +the desired output, the template may benefit from caching to reduce the number +of executions. The [`partialCached`][partialCached] template function provides +caching capabilities for `partial` templates. + +{{% tip %}} +Note that you can create cached variants of each `partial` by passing additional +parameters to `partialCached` beyond the initial context. See the +`partialCached` documentation for more details. +{{% /tip %}} + + +## Step Analysis + +Hugo provides a means of seeing metrics about each step in the site build +process. We call that *Step Analysis*. The *step analysis* output shows the +total time per step, the cumulative time after each step (in parentheses), +the memory usage per step, and the total memory allocations per step. + +To enable *step analysis*, use the `--stepAnalysis` option when running Hugo. + + +[partialCached]:{{< ref "functions/partialCached.md" >}} diff --cc docs/themes/gohugoioTheme/layouts/shortcodes/code-toggle.html index 00000000,00000000..c695a7aa new file mode 100644 --- /dev/null +++ b/docs/themes/gohugoioTheme/layouts/shortcodes/code-toggle.html @@@ -1,0 -1,0 +1,24 @@@ ++{{ $langs := (slice "yaml" "toml" "json") }} ++
++
++ {{- with .Get "file" -}} ++
{{ . }}.
++ {{- end -}} ++ {{ range $langs }} ++   ++ {{ end }} ++
++
++ {{ range $langs }} ++
++ {{ highlight ($.Inner | transform.Remarshal . | safeHTML) . ""}} ++
++ {{ if ne ($.Get "copy") "false" }} ++ ++ {{/* Functionality located within filesaver.js The copy here is located in the css with .copy class so it can be replaced with JS on success */}} ++ {{end}} ++ {{ end }} ++
++ ++
diff --cc docs/themes/gohugoioTheme/src/css/_chroma.css index b15e0755,00000000..d00ea65e mode 100644,000000..100644 --- a/docs/themes/gohugoioTheme/src/css/_chroma.css +++ b/docs/themes/gohugoioTheme/src/css/_chroma.css @@@ -1,67 -1,0 +1,65 @@@ - /* Background */ .chroma { background-color: #f0f0f0 } - /* Error */ .chroma .err { } - /* LineTableTD */ .chroma .lntd { ; vertical-align: top; padding: 0; margin: 0; border: 0; } - /* LineTable */ .chroma .lntable { ; border-spacing: 0; padding: 0; margin: 0; border: 0; width: 100%; overflow: auto; display: block; } - /* LineHighlight */ .chroma .hl { background-color: #ffffcc; display: block; width: 100% } - /* LineNumbersTable */ .chroma .lnt { ; margin-right: 0.4em; padding: 0 0.4em 0 0.4em; display: block; } - /* LineNumbers */ .chroma .ln { ; margin-right: 0.4em; padding: 0 0.4em 0 0.4em; } - /* Keyword */ .chroma .k { color: #007020; font-weight: bold } - /* KeywordConstant */ .chroma .kc { color: #007020; font-weight: bold } - /* KeywordDeclaration */ .chroma .kd { color: #007020; font-weight: bold } - /* KeywordNamespace */ .chroma .kn { color: #007020; font-weight: bold } - /* KeywordPseudo */ .chroma .kp { color: #007020 } - /* KeywordReserved */ .chroma .kr { color: #007020; font-weight: bold } - /* KeywordType */ .chroma .kt { color: #902000 } - /* NameAttribute */ .chroma .na { color: #4070a0 } - /* NameBuiltin */ .chroma .nb { color: #007020 } - /* NameClass */ .chroma .nc { color: #0e84b5; font-weight: bold } - /* NameConstant */ .chroma .no { color: #60add5 } - /* NameDecorator */ .chroma .nd { color: #555555; font-weight: bold } - /* NameEntity */ .chroma .ni { color: #d55537; font-weight: bold } - /* NameException */ .chroma .ne { color: #007020 } - /* NameFunction */ .chroma .nf { color: #06287e } - /* NameLabel */ .chroma .nl { color: #002070; font-weight: bold } - /* NameNamespace */ .chroma .nn { color: #0e84b5; font-weight: bold } - /* NameTag */ .chroma .nt { color: #062873; font-weight: bold } - /* NameVariable */ .chroma .nv { color: #bb60d5 } - /* LiteralString */ .chroma .s { color: #4070a0 } - /* LiteralStringAffix */ .chroma .sa { color: #4070a0 } - /* LiteralStringBacktick */ .chroma .sb { color: #4070a0 } - /* LiteralStringChar */ .chroma .sc { color: #4070a0 } - /* LiteralStringDelimiter */ .chroma .dl { color: #4070a0 } - /* LiteralStringDoc */ .chroma .sd { color: #4070a0; font-style: italic } - /* LiteralStringDouble */ .chroma .s2 { color: #4070a0 } - /* LiteralStringEscape */ .chroma .se { color: #4070a0; font-weight: bold } - /* LiteralStringHeredoc */ .chroma .sh { color: #4070a0 } - /* LiteralStringInterpol */ .chroma .si { color: #70a0d0; font-style: italic } - /* LiteralStringOther */ .chroma .sx { color: #c65d09 } - /* LiteralStringRegex */ .chroma .sr { color: #235388 } - /* LiteralStringSingle */ .chroma .s1 { color: #4070a0 } - /* LiteralStringSymbol */ .chroma .ss { color: #517918 } - /* LiteralNumber */ .chroma .m { color: #40a070 } - /* LiteralNumberBin */ .chroma .mb { color: #40a070 } - /* LiteralNumberFloat */ .chroma .mf { color: #40a070 } - /* LiteralNumberHex */ .chroma .mh { color: #40a070 } - /* LiteralNumberInteger */ .chroma .mi { color: #40a070 } - /* LiteralNumberIntegerLong */ .chroma .il { color: #40a070 } - /* LiteralNumberOct */ .chroma .mo { color: #40a070 } - /* Operator */ .chroma .o { color: #666666 } - /* OperatorWord */ .chroma .ow { color: #007020; font-weight: bold } - /* Comment */ .chroma .c { color: #60a0b0; font-style: italic } - /* CommentHashbang */ .chroma .ch { color: #60a0b0; font-style: italic } - /* CommentMultiline */ .chroma .cm { color: #60a0b0; font-style: italic } - /* CommentSingle */ .chroma .c1 { color: #60a0b0; font-style: italic } - /* CommentSpecial */ .chroma .cs { color: #60a0b0; background-color: #fff0f0 } - /* CommentPreproc */ .chroma .cp { color: #007020 } - /* CommentPreprocFile */ .chroma .cpf { color: #007020 } - /* GenericDeleted */ .chroma .gd { color: #a00000 } ++/* Background */ .chroma { background-color: #ffffff } ++/* Error */ .chroma .err { color: #a61717; background-color: #e3d2d2 } ++/* LineTableTD */ .chroma .lntd { vertical-align: top; padding: 0; margin: 0; border: 0; } ++/* LineTable */ .chroma .lntable { border-spacing: 0; padding: 0; margin: 0; border: 0; width: auto; overflow: auto; display: block; } ++/* LineHighlight */ .chroma .hl { display: block; width: 100%;background-color: #ffffcc } ++/* LineNumbersTable */ .chroma .lnt { margin-right: 0.4em; padding: 0 0.4em 0 0.4em; } ++/* LineNumbers */ .chroma .ln { margin-right: 0.4em; padding: 0 0.4em 0 0.4em; } ++/* Keyword */ .chroma .k { font-weight: bold } ++/* KeywordConstant */ .chroma .kc { font-weight: bold } ++/* KeywordDeclaration */ .chroma .kd { font-weight: bold } ++/* KeywordNamespace */ .chroma .kn { font-weight: bold } ++/* KeywordPseudo */ .chroma .kp { font-weight: bold } ++/* KeywordReserved */ .chroma .kr { font-weight: bold } ++/* KeywordType */ .chroma .kt { color: #445588; font-weight: bold } ++/* NameAttribute */ .chroma .na { color: #008080 } ++/* NameBuiltin */ .chroma .nb { color: #999999 } ++/* NameClass */ .chroma .nc { color: #445588; font-weight: bold } ++/* NameConstant */ .chroma .no { color: #008080 } ++/* NameEntity */ .chroma .ni { color: #800080 } ++/* NameException */ .chroma .ne { color: #990000; font-weight: bold } ++/* NameFunction */ .chroma .nf { color: #990000; font-weight: bold } ++/* NameNamespace */ .chroma .nn { color: #555555 } ++/* NameTag */ .chroma .nt { color: #000080 } ++/* NameVariable */ .chroma .nv { color: #008080 } ++/* LiteralString */ .chroma .s { color: #bb8844 } ++/* LiteralStringAffix */ .chroma .sa { color: #bb8844 } ++/* LiteralStringBacktick */ .chroma .sb { color: #bb8844 } ++/* LiteralStringChar */ .chroma .sc { color: #bb8844 } ++/* LiteralStringDelimiter */ .chroma .dl { color: #bb8844 } ++/* LiteralStringDoc */ .chroma .sd { color: #bb8844 } ++/* LiteralStringDouble */ .chroma .s2 { color: #bb8844 } ++/* LiteralStringEscape */ .chroma .se { color: #bb8844 } ++/* LiteralStringHeredoc */ .chroma .sh { color: #bb8844 } ++/* LiteralStringInterpol */ .chroma .si { color: #bb8844 } ++/* LiteralStringOther */ .chroma .sx { color: #bb8844 } ++/* LiteralStringRegex */ .chroma .sr { color: #808000 } ++/* LiteralStringSingle */ .chroma .s1 { color: #bb8844 } ++/* LiteralStringSymbol */ .chroma .ss { color: #bb8844 } ++/* LiteralNumber */ .chroma .m { color: #009999 } ++/* LiteralNumberBin */ .chroma .mb { color: #009999 } ++/* LiteralNumberFloat */ .chroma .mf { color: #009999 } ++/* LiteralNumberHex */ .chroma .mh { color: #009999 } ++/* LiteralNumberInteger */ .chroma .mi { color: #009999 } ++/* LiteralNumberIntegerLong */ .chroma .il { color: #009999 } ++/* LiteralNumberOct */ .chroma .mo { color: #009999 } ++/* Operator */ .chroma .o { font-weight: bold } ++/* OperatorWord */ .chroma .ow { font-weight: bold } ++/* Comment */ .chroma .c { color: #999988; font-style: italic } ++/* CommentHashbang */ .chroma .ch { color: #999988; font-style: italic } ++/* CommentMultiline */ .chroma .cm { color: #999988; font-style: italic } ++/* CommentSingle */ .chroma .c1 { color: #999988; font-style: italic } ++/* CommentSpecial */ .chroma .cs { color: #999999; font-weight: bold; font-style: italic } ++/* CommentPreproc */ .chroma .cp { color: #999999; font-weight: bold } ++/* CommentPreprocFile */ .chroma .cpf { color: #999999; font-weight: bold } ++/* GenericDeleted */ .chroma .gd { color: #000000; background-color: #ffdddd } +/* GenericEmph */ .chroma .ge { font-style: italic } - /* GenericError */ .chroma .gr { color: #ff0000 } - /* GenericHeading */ .chroma .gh { color: #000080; font-weight: bold } - /* GenericInserted */ .chroma .gi { color: #00a000 } ++/* GenericError */ .chroma .gr { color: #aa0000 } ++/* GenericHeading */ .chroma .gh { color: #999999 } ++/* GenericInserted */ .chroma .gi { color: #000000; background-color: #ddffdd } +/* GenericOutput */ .chroma .go { color: #888888 } - /* GenericPrompt */ .chroma .gp { color: #c65d09; font-weight: bold } ++/* GenericPrompt */ .chroma .gp { color: #555555 } +/* GenericStrong */ .chroma .gs { font-weight: bold } - /* GenericSubheading */ .chroma .gu { color: #800080; font-weight: bold } - /* GenericTraceback */ .chroma .gt { color: #0044dd } ++/* GenericSubheading */ .chroma .gu { color: #aaaaaa } ++/* GenericTraceback */ .chroma .gt { color: #aa0000 } +/* TextWhitespace */ .chroma .w { color: #bbbbbb } diff --cc docs/themes/gohugoioTheme/src/css/_tabs.css index 00000000,00000000..4ed15b63 new file mode 100644 --- /dev/null +++ b/docs/themes/gohugoioTheme/src/css/_tabs.css @@@ -1,0 -1,0 +1,30 @@@ ++.tab-button{ ++ margin-bottom:1px; ++ position: relative; ++ z-index: 1; ++ color:#333; ++ border-color:#ccc; ++ outline: none; ++ background-color:white; ++} ++.tab-pane .chroma{ ++ background:none; ++ padding:0; ++} ++.tab-button.active{ ++ border-bottom-color:#f3f4f4; ++ background-color: #f4f4f4; ++} ++.tab-content .tab-pane{ ++ display: none; ++} ++.tab-content .tab-pane.active{ ++ display: block; ++} ++/* Treatment of copy buttons inside a tab module */ ++.tab-content .copy, .tab-content .copied{ ++ display: none; ++} ++.tab-content .tab-pane.active + .copy, .tab-content .tab-pane.active + .copied{ ++ display: block; ++} diff --cc docs/themes/gohugoioTheme/src/css/main.css index db474cdf,00000000..a3ad83a0 mode 100755,000000..100755 --- a/docs/themes/gohugoioTheme/src/css/main.css +++ b/docs/themes/gohugoioTheme/src/css/main.css @@@ -1,42 -1,0 +1,43 @@@ +/*Base Styles*/ +@import '_tachyons'; + +/*type*/ +@import 'font/_muli-200'; +@import 'font/_muli-400'; +@import 'font/_muli-800'; + +@import '_anchorforid'; +@import '_animation'; +@import '_documentation-styles'; + +@import '_algolia'; +@import '_carousel'; +@import '_code'; ++@import '_tabs'; +@import '_color-scheme'; +@import '_columns'; +@import '_content'; +@import '_content-tables'; +@import '_definition-lists'; +@import '_fluid-type'; +@import '_font-family'; +/*@import '_hljs';*/ +@import '_hugo-internal-template-styling'; +@import '_no-js'; +@import '_social-icons'; +@import '_stickyheader'; + +@import '_svg'; +@import '_chroma'; +@import '_variables'; + +.nested-blockquote blockquote { + border-left: 4px solid var(--primary-color); + padding-left: 1em; + /*margin: 0;*/ +} + + +.mw-90 { + max-width:90%; +} diff --cc docs/themes/gohugoioTheme/src/js/clipboardjs.js index f10f07c8,00000000..ffae31c7 mode 100644,000000..100644 --- a/docs/themes/gohugoioTheme/src/js/clipboardjs.js +++ b/docs/themes/gohugoioTheme/src/js/clipboardjs.js @@@ -1,27 -1,0 +1,30 @@@ +var Clipboard = require('clipboard/dist/clipboard.js'); +new Clipboard('.copy', { + target: function(trigger) { ++ if(trigger.classList.contains('copy-toggle')){ ++ return trigger.previousElementSibling; ++ } + return trigger.nextElementSibling; + } + }).on('success', function(e) { + successMessage(e.trigger, 'Copied!'); + e.clearSelection(); + }).on('error', function(e) { + successMessage(e.trigger, fallbackMessage(e.action)); +}); + +function successMessage(elem, msg) { + elem.setAttribute('class', 'copied bg-primary-color-dark f6 absolute top-0 right-0 lh-solid hover-bg-primary-color-dark bn white ph3 pv2'); + elem.setAttribute('aria-label', msg); +} + +function fallbackMessage(elem, action) { + var actionMsg = ''; + var actionKey = (action === 'cut' ? 'X' : 'C'); + if (isMac) { + actionMsg = 'Press ⌘-' + actionKey; + } else { + actionMsg = 'Press Ctrl-' + actionKey; + } + return actionMsg; +} diff --cc docs/themes/gohugoioTheme/src/js/main.js index 4ed81847,00000000..b6ae53f3 mode 100755,000000..100755 --- a/docs/themes/gohugoioTheme/src/js/main.js +++ b/docs/themes/gohugoioTheme/src/js/main.js @@@ -1,26 -1,0 +1,26 @@@ +import styles from './../css/main.css'; +import './anchorforid.js' +import './clipboardjs.js' +import './codeblocks.js' +import './docsearch.js' +//import './hljs.js' +import './lazysizes.js' +import './menutoggle.js' +import './scrolldir.js' +import './smoothscroll.js' - ++import './tabs.js' +import './nojs.js' + + + +// TO use Jquery, just call the modules you want +// var $ = require('jquery/src/core'); +// require('jquery/src/core/init'); +// require('jquery/src/manipulation'); + +// OR, use all of them +// var $ = require('jquery/src/jquery'); + +// And write your code +// $('body').append('

Jquery is working

'); +// diff --cc docs/themes/gohugoioTheme/src/js/tabs.js index 00000000,00000000..dd90fdfa new file mode 100644 --- /dev/null +++ b/docs/themes/gohugoioTheme/src/js/tabs.js @@@ -1,0 -1,0 +1,43 @@@ ++/** ++ * Scripts which manages Code Toggle tabs. ++ */ ++var i; ++// store tabs variable ++var allTabs = document.querySelectorAll("[data-toggle-tab]"); ++var allPanes = document.querySelectorAll("[data-pane]"); ++ ++function toggleTabs(event) { ++ ++ if(event.target){ ++ event.preventDefault(); ++ var clickedTab = event.currentTarget; ++ var targetKey = clickedTab.getAttribute("data-toggle-tab") ++ }else { ++ var targetKey = event ++ } ++ // We store the config language selected in users' localStorage ++ if(window.localStorage){ ++ window.localStorage.setItem("configLangPref", targetKey) ++ } ++ var selectedTabs = document.querySelectorAll("[data-toggle-tab='" + targetKey + "']"); ++ var selectedPanes = document.querySelectorAll("[data-pane='" + targetKey + "']"); ++ ++ for (var i = 0; i < allTabs.length; i++) { ++ allTabs[i].classList.remove("active"); ++ allPanes[i].classList.remove("active"); ++ } ++ ++ for (var i = 0; i < selectedTabs.length; i++) { ++ selectedTabs[i].classList.add("active"); ++ selectedPanes[i].classList.add("active"); ++ } ++ ++} ++ ++for (i = 0; i < allTabs.length; i++) { ++ allTabs[i].addEventListener("click", toggleTabs) ++} ++// Upon page load, if user has a prefered language in its localStorage, tabs are set to it. ++if(window.localStorage.getItem('configLangPref')) { ++ toggleTabs(window.localStorage.getItem('configLangPref')) ++} diff --cc docs/themes/gohugoioTheme/static/dist/app.bundle.js index 6c2fd668,00000000..6391e71e mode 100644,000000..100644 --- a/docs/themes/gohugoioTheme/static/dist/app.bundle.js +++ b/docs/themes/gohugoioTheme/static/dist/app.bundle.js @@@ -1,22 -1,0 +1,22 @@@ - !function(t){function e(r){if(n[r])return n[r].exports;var i=n[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,e),i.l=!0,i.exports}var n={};e.m=t,e.c=n,e.i=function(t){return t},e.d=function(t,n,r){e.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:r})},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=10)}([function(t,e,n){"use strict";var r=function(t){var e=document.createElement("a");return e.className="header-link",e.href="#"+t,e.innerHTML=' ',e},i=function(t,e){for(var n=e.getElementsByTagName("h"+t),i=0;i0&&p.parentNode.classList.add("expand")}}catch(t){a=!0,u=t}finally{try{!s&&l.return&&l.return()}finally{if(a)throw u}}}},function(t,e,n){"use strict";n(12)({apiKey:"167e7998590aebda7f9fedcf86bc4a55",indexName:"hugodocs",inputSelector:"#search-input",debug:!0})},function(t,e,n){"use strict";n(13),n(14)},function(t,e,n){"use strict";function r(){for(var t=this.dataset.target.split(" "),e=document.querySelector(".mobilemenu:not(.dn)"),n=document.querySelector(".desktopmenu:not(.dn)"),r=document.querySelector(".desktopmenu:not(.dn)"),i=0;i=0?function(){var t=window.pageYOffset;(t>=i-s||window.innerHeight+t>=document.body.offsetHeight)&&clearInterval(u)}:function(){window.pageYOffset<=(i||0)&&clearInterval(u)};var u=setInterval(a,16)},e=document.querySelectorAll("#TableOfContents ul li a");[].forEach.call(e,function(e){e.addEventListener("click",function(n){n.preventDefault();var r=e.getAttribute("href"),i=document.querySelector(r),o=e.getAttribute("data-speed");i&&t(i,o||500)},!1)})}}()},function(t,e){},function(t,e,n){"use strict";var r=n(9);!function(t){t&&t.__esModule}(r);n(0),n(1),n(2),n(3),n(4),n(5),n(7),n(8),n(6)},function(t,e,n){var r,r;/*! ++!function(t){function e(r){if(n[r])return n[r].exports;var i=n[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,e),i.l=!0,i.exports}var n={};e.m=t,e.c=n,e.i=function(t){return t},e.d=function(t,n,r){e.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:r})},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=11)}([function(t,e,n){"use strict";var r=function(t){var e=document.createElement("a");return e.className="header-link",e.href="#"+t,e.innerHTML=' ',e},i=function(t,e){for(var n=e.getElementsByTagName("h"+t),i=0;i0&&p.parentNode.classList.add("expand")}}catch(t){a=!0,u=t}finally{try{!s&&l.return&&l.return()}finally{if(a)throw u}}}},function(t,e,n){"use strict";n(13)({apiKey:"167e7998590aebda7f9fedcf86bc4a55",indexName:"hugodocs",inputSelector:"#search-input",debug:!0})},function(t,e,n){"use strict";n(14),n(15)},function(t,e,n){"use strict";function r(){for(var t=this.dataset.target.split(" "),e=document.querySelector(".mobilemenu:not(.dn)"),n=document.querySelector(".desktopmenu:not(.dn)"),r=document.querySelector(".desktopmenu:not(.dn)"),i=0;i=0?function(){var t=window.pageYOffset;(t>=i-s||window.innerHeight+t>=document.body.offsetHeight)&&clearInterval(u)}:function(){window.pageYOffset<=(i||0)&&clearInterval(u)};var u=setInterval(a,16)},e=document.querySelectorAll("#TableOfContents ul li a");[].forEach.call(e,function(e){e.addEventListener("click",function(n){n.preventDefault();var r=e.getAttribute("href"),i=document.querySelector(r),o=e.getAttribute("data-speed");i&&t(i,o||500)},!1)})}}()},function(t,e,n){"use strict";function r(t){if(t.target){t.preventDefault();var e=t.currentTarget,n=e.getAttribute("data-toggle-tab")}else var n=t;window.localStorage&&window.localStorage.setItem("configLangPref",n);for(var r=document.querySelectorAll("[data-toggle-tab='"+n+"']"),i=document.querySelectorAll("[data-pane='"+n+"']"),a=0;a0&&void 0!==arguments[0]?arguments[0]:{};this.action=t.action,this.container=t.container,this.emitter=t.emitter,this.target=t.target,this.text=t.text,this.trigger=t.trigger,this.selectedText=""}},{key:"initSelection",value:function(){this.text?this.selectFake():this.target&&this.selectTarget()}},{key:"selectFake",value:function(){var t=this,e="rtl"==document.documentElement.getAttribute("dir");this.removeFake(),this.fakeHandlerCallback=function(){return t.removeFake()},this.fakeHandler=this.container.addEventListener("click",this.fakeHandlerCallback)||!0,this.fakeElem=document.createElement("textarea"),this.fakeElem.style.fontSize="12pt",this.fakeElem.style.border="0",this.fakeElem.style.padding="0",this.fakeElem.style.margin="0",this.fakeElem.style.position="absolute",this.fakeElem.style[e?"right":"left"]="-9999px";var n=window.pageYOffset||document.documentElement.scrollTop;this.fakeElem.style.top=n+"px",this.fakeElem.setAttribute("readonly",""),this.fakeElem.value=this.text,this.container.appendChild(this.fakeElem),this.selectedText=(0,r.default)(this.fakeElem),this.copyText()}},{key:"removeFake",value:function(){this.fakeHandler&&(this.container.removeEventListener("click",this.fakeHandlerCallback),this.fakeHandler=null,this.fakeHandlerCallback=null),this.fakeElem&&(this.container.removeChild(this.fakeElem),this.fakeElem=null)}},{key:"selectTarget",value:function(){this.selectedText=(0,r.default)(this.target),this.copyText()}},{key:"copyText",value:function(){var t=void 0;try{t=document.execCommand(this.action)}catch(e){t=!1}this.handleResult(t)}},{key:"handleResult",value:function(t){this.emitter.emit(t?"success":"error",{action:this.action,text:this.selectedText,trigger:this.trigger,clearSelection:this.clearSelection.bind(this)})}},{key:"clearSelection",value:function(){this.trigger&&this.trigger.focus(),window.getSelection().removeAllRanges()}},{key:"destroy",value:function(){this.removeFake()}},{key:"action",set:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"copy";if(this._action=t,"copy"!==this._action&&"cut"!==this._action)throw new Error('Invalid "action" value, use either "copy" or "cut"')},get:function(){return this._action}},{key:"target",set:function(t){if(void 0!==t){if(!t||"object"!==(void 0===t?"undefined":i(t))||1!==t.nodeType)throw new Error('Invalid "target" value, use a valid Element');if("copy"===this.action&&t.hasAttribute("disabled"))throw new Error('Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute');if("cut"===this.action&&(t.hasAttribute("readonly")||t.hasAttribute("disabled")))throw new Error('Invalid "target" attribute. You can\'t cut text from elements with "readonly" or "disabled" attributes');this._target=t}},get:function(){return this._target}}]),t}();t.exports=s})},{select:5}],8:[function(e,n,r){!function(i,o){if("function"==typeof t&&t.amd)t(["module","./clipboard-action","tiny-emitter","good-listener"],o);else if(void 0!==r)o(n,e("./clipboard-action"),e("tiny-emitter"),e("good-listener"));else{var s={exports:{}};o(s,i.clipboardAction,i.tinyEmitter,i.goodListener),i.clipboard=s.exports}}(this,function(t,e,n,r){"use strict";function i(t){return t&&t.__esModule?t:{default:t}}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function s(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function a(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}function u(t,e){var n="data-clipboard-"+t;if(e.hasAttribute(n))return e.getAttribute(n)}var c=i(e),l=i(n),h=i(r),f="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},p=function(){function t(t,e){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:{};this.action="function"==typeof t.action?t.action:this.defaultAction,this.target="function"==typeof t.target?t.target:this.defaultTarget,this.text="function"==typeof t.text?t.text:this.defaultText,this.container="object"===f(t.container)?t.container:document.body}},{key:"listenClick",value:function(t){var e=this;this.listener=(0,h.default)(t,"click",function(t){return e.onClick(t)})}},{key:"onClick",value:function(t){var e=t.delegateTarget||t.currentTarget;this.clipboardAction&&(this.clipboardAction=null),this.clipboardAction=new c.default({action:this.action(e),target:this.target(e),text:this.text(e),container:this.container,trigger:e,emitter:this})}},{key:"defaultAction",value:function(t){return u("action",t)}},{key:"defaultTarget",value:function(t){var e=u("target",t);if(e)return document.querySelector(e)}},{key:"defaultText",value:function(t){return u("text",t)}},{key:"destroy",value:function(){this.listener.destroy(),this.clipboardAction&&(this.clipboardAction.destroy(),this.clipboardAction=null)}}],[{key:"isSupported",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:["copy","cut"],e="string"==typeof t?[t]:t,n=!!document.queryCommandSupported;return e.forEach(function(t){n=n&&!!document.queryCommandSupported(t)}),n}}]),e}(l.default);t.exports=d})},{"./clipboard-action":7,"good-listener":4,"tiny-emitter":6}]},{},[8])(8)})},function(t,e,n){/*! docsearch 2.5.2 | © Algolia | github.com/algolia/docsearch */ - !function(e,n){t.exports=n()}("undefined"!=typeof self&&self,function(){return function(t){function e(r){if(n[r])return n[r].exports;var i=n[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,e),i.l=!0,i.exports}var n={};return e.m=t,e.c=n,e.d=function(t,n,r){e.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:r})},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=21)}([function(t,e,n){"use strict";function r(t){return t.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")}var i=n(1);t.exports={isArray:null,isFunction:null,isObject:null,bind:null,each:null,map:null,mixin:null,isMsie:function(){return!!/(msie|trident)/i.test(navigator.userAgent)&&navigator.userAgent.match(/(msie |rv:)(\d+(.\d+)?)/i)[2]},escapeRegExChars:function(t){return t.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")},isNumber:function(t){return"number"==typeof t},toStr:function(t){return void 0===t||null===t?"":t+""},cloneDeep:function(t){var e=this.mixin({},t),n=this;return this.each(e,function(t,r){t&&(n.isArray(t)?e[r]=[].concat(t):n.isObject(t)&&(e[r]=n.cloneDeep(t)))}),e},error:function(t){throw new Error(t)},every:function(t,e){var n=!0;return t?(this.each(t,function(r,i){if(!(n=e.call(null,r,i,t)))return!1}),!!n):n},any:function(t,e){var n=!1;return t?(this.each(t,function(r,i){if(e.call(null,r,i,t))return n=!0,!1}),n):n},getUniqueId:function(){var t=0;return function(){return t++}}(),templatify:function(t){if(this.isFunction(t))return t;var e=i.element(t);return"SCRIPT"===e.prop("tagName")?function(){return e.text()}:function(){return String(t)}},defer:function(t){setTimeout(t,0)},noop:function(){},formatPrefix:function(t,e){return e?"":t+"-"},className:function(t,e,n){return(n?"":".")+t+e},escapeHighlightedString:function(t,e,n){e=e||"";var i=document.createElement("div");i.appendChild(document.createTextNode(e)),n=n||"";var o=document.createElement("div");o.appendChild(document.createTextNode(n));var s=document.createElement("div");return s.appendChild(document.createTextNode(t)),s.innerHTML.replace(RegExp(r(i.innerHTML),"g"),e).replace(RegExp(r(o.innerHTML),"g"),n)}}},function(t,e,n){"use strict";t.exports={element:null}},function(t,e){var n=Object.prototype.hasOwnProperty,r=Object.prototype.toString;t.exports=function(t,e,i){if("[object Function]"!==r.call(e))throw new TypeError("iterator must be a function");var o=t.length;if(o===+o)for(var s=0;s was loaded but did not call our provided callback"),JSONPScriptError:i("JSONPScriptError","