mirror of
https://github.com/gohugoio/hugoDocs.git
synced 2025-08-03 20:49:41 -04:00
Fenced code blocks should have a language specified (#1861)
This commit is contained in:
parent
24393315bf
commit
68f05fdc83
@ -114,6 +114,7 @@
|
||||
"govendor",
|
||||
"Gowans",
|
||||
"Grayscale",
|
||||
"Gregor",
|
||||
"Gruber",
|
||||
"gtag",
|
||||
"gvfs",
|
||||
|
@ -18,7 +18,6 @@ MD034: false
|
||||
MD036: false
|
||||
MD037: false
|
||||
MD038: false
|
||||
MD040: false
|
||||
MD041: false
|
||||
MD046: false
|
||||
MD049: false
|
||||
|
@ -1,4 +1,5 @@
|
||||
**/commands/**
|
||||
**/functions/**
|
||||
**/news/**
|
||||
**/showcase/**
|
||||
**/zh/**
|
||||
|
@ -10,7 +10,6 @@ menu:
|
||||
weight: 4
|
||||
weight: 5
|
||||
sections_weight: 5
|
||||
draft: false
|
||||
aliases: [/security/]
|
||||
toc: true
|
||||
---
|
||||
@ -40,7 +39,7 @@ The default configuration is listed below. Any build using features not in the a
|
||||
|
||||
Note that these and other config settings in Hugo can be overridden by the OS environment. If you want to block all remote HTTP fetching of data:
|
||||
|
||||
```
|
||||
```txt
|
||||
HUGO_SECURITY_HTTP_URLS=none hugo
|
||||
```
|
||||
|
||||
|
@ -42,7 +42,7 @@ For many websites, this is enough configuration. However, you also have the opti
|
||||
|
||||
Disqus has its own [internal template](https://gohugo.io/templates/internal/#disqus) available, to render it add the following code where you want comments to appear:
|
||||
|
||||
```
|
||||
```go-html-template
|
||||
{{ template "_internal/disqus.html" . }}
|
||||
```
|
||||
|
||||
|
@ -19,7 +19,7 @@ toc: true
|
||||
|
||||
Hugo! supports [GoAT](https://github.com/bep/goat) natively. This means that this code block:
|
||||
|
||||
````
|
||||
````txt
|
||||
```goat
|
||||
. . . .--- 1 .-- 1 / 1
|
||||
/ \ | | .---+ .-+ +
|
||||
|
@ -100,7 +100,7 @@ Notice that for security concerns only extensions that do not have path separato
|
||||
|
||||
Example of how to set extensions and attributes:
|
||||
|
||||
```
|
||||
```yml
|
||||
[markup.asciidocExt]
|
||||
extensions = ["asciidoctor-html5s", "asciidoctor-diagram"]
|
||||
workingFolderCurrent = true
|
||||
@ -112,7 +112,7 @@ Example of how to set extensions and attributes:
|
||||
In a complex Asciidoctor environment it is sometimes helpful to debug the exact call to your external helper with all
|
||||
parameters. Run Hugo with `-v`. You will get an output like
|
||||
|
||||
```
|
||||
```txt
|
||||
INFO 2019/12/22 09:08:48 Rendering book-as-pdf.adoc with C:\Ruby26-x64\bin\asciidoctor.bat using asciidoc args [--no-header-footer -r asciidoctor-html5s -b html5s -r asciidoctor-diagram --base-dir D:\prototypes\hugo_asciidoc_ddd\docs -a outdir=D:\prototypes\hugo_asciidoc_ddd\build -] ...
|
||||
```
|
||||
|
||||
|
@ -4,7 +4,6 @@ linktitle: Organization
|
||||
description: Hugo assumes that the same structure that works to organize your source content is used to organize the rendered site.
|
||||
date: 2017-02-01
|
||||
publishdate: 2017-02-01
|
||||
lastmod: 2017-02-01
|
||||
categories: [content management,fundamentals]
|
||||
keywords: [sections,content,organization,bundle,resources]
|
||||
menu:
|
||||
@ -12,7 +11,6 @@ menu:
|
||||
parent: "content-management"
|
||||
weight: 10
|
||||
weight: 10 #rem
|
||||
draft: false
|
||||
aliases: [/content/sections/]
|
||||
toc: true
|
||||
---
|
||||
@ -35,14 +33,13 @@ The bundle documentation is a **work in progress**. We will publish more compreh
|
||||
|
||||
## Organization of Content Source
|
||||
|
||||
|
||||
In Hugo, your content should be organized in a manner that reflects the rendered website.
|
||||
|
||||
While Hugo supports content nested at any level, the top levels (i.e. `content/<DIRECTORIES>`) are special in Hugo and are considered the content type used to determine layouts etc. To read more about sections, including how to nest them, see [sections][].
|
||||
|
||||
Without any additional configuration, the following will automatically work:
|
||||
|
||||
```
|
||||
```txt
|
||||
.
|
||||
└── content
|
||||
└── about
|
||||
@ -73,7 +70,7 @@ The following demonstrates the relationships between your content organization a
|
||||
You can create one `_index.md` for your homepage and one in each of your content sections, taxonomies, and taxonomy terms. The following shows typical placement of an `_index.md` that would contain content and front matter for a `posts` section list page on a Hugo website:
|
||||
|
||||
|
||||
```
|
||||
```txt
|
||||
. url
|
||||
. ⊢--^-⊣
|
||||
. path slug
|
||||
@ -85,7 +82,7 @@ content/posts/_index.md
|
||||
|
||||
At build, this will output to the following destination with the associated values:
|
||||
|
||||
```
|
||||
```txt
|
||||
|
||||
url ("/posts/")
|
||||
⊢-^-⊣
|
||||
@ -104,7 +101,7 @@ The [sections] can be nested as deeply as you want. The important thing to under
|
||||
Single content files in each of your sections will be rendered as [single page templates][singles]. Here is an example of a single `post` within `posts`:
|
||||
|
||||
|
||||
```
|
||||
```txt
|
||||
path ("posts/my-first-hugo-post.md")
|
||||
. ⊢-----------^------------⊣
|
||||
. section slug
|
||||
@ -114,7 +111,7 @@ content/posts/my-first-hugo-post.md
|
||||
|
||||
When Hugo builds your site, the content will be output to the following destination:
|
||||
|
||||
```
|
||||
```txt
|
||||
|
||||
url ("/posts/my-first-hugo-post/")
|
||||
⊢------------^----------⊣
|
||||
@ -180,7 +177,7 @@ slug: "new-post"
|
||||
|
||||
This will render to the following destination according to Hugo's default behavior:
|
||||
|
||||
```
|
||||
```txt
|
||||
example.com/posts/new-post/
|
||||
```
|
||||
|
||||
@ -217,7 +214,7 @@ url: /blog/new-url/
|
||||
|
||||
Assuming your `baseURL` is [configured][config] to `https://example.com`, the addition of `url` to the front matter will make `old-url.md` render to the following destination:
|
||||
|
||||
```
|
||||
```txt
|
||||
https://example.com/blog/new-url/
|
||||
```
|
||||
|
||||
|
@ -94,13 +94,13 @@ MediaType.Suffixes
|
||||
ByType
|
||||
: Returns the page resources of the given type.
|
||||
|
||||
```go
|
||||
```go-html-template
|
||||
{{ .Resources.ByType "image" }}
|
||||
```
|
||||
Match
|
||||
: Returns all the page resources (as a slice) whose `Name` matches the given Glob pattern ([examples](https://github.com/gobwas/glob/blob/master/readme.md)). The matching is case-insensitive.
|
||||
|
||||
```go
|
||||
```go-html-template
|
||||
{{ .Resources.Match "images/*" }}
|
||||
```
|
||||
|
||||
|
@ -40,7 +40,7 @@ Here is the list of "Related" methods available on a page collection such `.Regu
|
||||
|
||||
Returns a collection of pages related the given one.
|
||||
|
||||
```
|
||||
```go-html-template
|
||||
{{ $related := site.RegularPages.Related . }}
|
||||
```
|
||||
|
||||
@ -48,7 +48,7 @@ Returns a collection of pages related the given one.
|
||||
|
||||
Returns a collection of pages related to a given one restricted to a list of indices.
|
||||
|
||||
```
|
||||
```go-html-template
|
||||
{{ $related := site.RegularPages.RelatedIndices . "tags" "date" }}
|
||||
```
|
||||
|
||||
@ -58,7 +58,7 @@ Returns a collection of pages related together by a set of indices and their mat
|
||||
|
||||
In order to build those set and pass them as argument, one must use the `keyVals` function where the first argument would be the `indice` and the consecutive ones its potential `matches`.
|
||||
|
||||
```
|
||||
```go-html-template
|
||||
{{ $related := site.RegularPages.RelatedTo ( keyVals "tags" "hugo" "rocks") ( keyVals "date" .Date ) }}
|
||||
```
|
||||
|
||||
|
@ -40,11 +40,11 @@ Some shortcodes use or require closing shortcodes. Again like HTML, the opening
|
||||
|
||||
Here are two examples of paired shortcodes:
|
||||
|
||||
```
|
||||
```go-html-template
|
||||
{{%/* mdshortcode */%}}Stuff to `process` in the *center*.{{%/* /mdshortcode */%}}
|
||||
```
|
||||
|
||||
```
|
||||
```go-html-template
|
||||
{{</* highlight go */>}} A bunch of code here {{</* /highlight */>}}
|
||||
```
|
||||
|
||||
@ -56,7 +56,7 @@ The examples above use two different delimiters, the difference being the `%` ch
|
||||
|
||||
You can pass multiple lines as parameters to a shortcode by using raw string literals:
|
||||
|
||||
```
|
||||
```go-html-template
|
||||
{{</* myshortcode `This is some <b>HTML</b>,
|
||||
and a new line with a "quoted string".` */>}}
|
||||
```
|
||||
@ -67,7 +67,7 @@ In Hugo `0.55` we changed how the `%` delimiter works. Shortcodes using the `%`
|
||||
|
||||
If you want the old behavior, you can put the following line in the start of your shortcode template:
|
||||
|
||||
```
|
||||
```go-html-template
|
||||
{{ $_hugo_config := `{ "version": 1 }` }}
|
||||
```
|
||||
|
||||
@ -75,7 +75,7 @@ If you want the old behavior, you can put the following line in the start of you
|
||||
|
||||
The `<` character indicates that the shortcode's inner content does *not* need further rendering. Often shortcodes without Markdown include internal HTML:
|
||||
|
||||
```
|
||||
```go-html-template
|
||||
{{</* myshortcode */>}}<p>Hello <strong>World!</strong></p>{{</* /myshortcode */>}}
|
||||
```
|
||||
|
||||
@ -150,13 +150,13 @@ attrlink
|
||||
|
||||
Bloggers often want to include GitHub gists when writing posts. Let's suppose we want to use the [gist at the following url][examplegist]:
|
||||
|
||||
```
|
||||
```txt
|
||||
https://gist.github.com/spf13/7896402
|
||||
```
|
||||
|
||||
We can embed the gist in our content via username and gist ID pulled from the URL:
|
||||
|
||||
```
|
||||
```go-html-template
|
||||
{{</* gist spf13 7896402 */>}}
|
||||
```
|
||||
|
||||
@ -222,7 +222,7 @@ To see even more options for adding syntax-highlighted code blocks to your websi
|
||||
|
||||
If you'd like to embed a photo from [Instagram][], you only need the photo's ID. You can discern an Instagram photo ID from the URL:
|
||||
|
||||
```
|
||||
```txt
|
||||
https://www.instagram.com/p/BWNjjyYFxVx/
|
||||
```
|
||||
|
||||
@ -289,7 +289,7 @@ Read a more extensive description of `ref` and `relref` in the [cross references
|
||||
|
||||
#### Example `ref` and `relref` Input
|
||||
|
||||
```
|
||||
```go-html-template
|
||||
[Neat]({{</* ref "blog/neat.md" */>}})
|
||||
[Who]({{</* relref "about.md#who" */>}})
|
||||
```
|
||||
@ -298,7 +298,7 @@ Read a more extensive description of `ref` and `relref` in the [cross references
|
||||
|
||||
Assuming that standard Hugo pretty URLs are turned on.
|
||||
|
||||
```
|
||||
```html
|
||||
<a href="https://example.com/blog/neat">Neat</a>
|
||||
<a href="/about/#who">Who</a>
|
||||
```
|
||||
@ -307,7 +307,7 @@ Assuming that standard Hugo pretty URLs are turned on.
|
||||
|
||||
You want to include a single tweet into your blog post? Everything you need is the URL of the tweet:
|
||||
|
||||
```
|
||||
```txt
|
||||
https://twitter.com/SanDiegoZoo/status/1453110110599868418
|
||||
```
|
||||
|
||||
@ -337,7 +337,7 @@ Using the preceding `tweet` example, the following simulates the displayed exper
|
||||
|
||||
Adding a video from [Vimeo][] is equivalent to the [YouTube Input shortcode][].
|
||||
|
||||
```
|
||||
```txt
|
||||
https://vimeo.com/channels/staffpicks/146022717
|
||||
```
|
||||
|
||||
@ -360,7 +360,7 @@ Using the preceding `vimeo` example, the following HTML will be added to your re
|
||||
{{% tip %}}
|
||||
If you want to further customize the visual styling of the YouTube or Vimeo output, add a `class` named parameter when calling the shortcode. The new `class` will be added to the `<div>` that wraps the `<iframe>` *and* will remove the inline styles. Note that you will need to call the `id` as a named parameter as well. You can also give the vimeo video a descriptive title with `title`.
|
||||
|
||||
```
|
||||
```go
|
||||
{{</* vimeo id="146022717" class="my-vimeo-wrapper-class" title="My vimeo video" */>}}
|
||||
```
|
||||
{{% /tip %}}
|
||||
@ -375,7 +375,7 @@ Using the preceding `vimeo` example, the following simulates the displayed exper
|
||||
|
||||
The `youtube` shortcode embeds a responsive video player for [YouTube videos][]. Only the ID of the video is required, e.g.:
|
||||
|
||||
```
|
||||
```txt
|
||||
https://www.youtube.com/watch?v=w7Ft2ymGmfc
|
||||
```
|
||||
|
||||
|
@ -49,7 +49,7 @@ Options:
|
||||
|
||||
### Example: Highlight Shortcode
|
||||
|
||||
```
|
||||
```go-html-template
|
||||
{{</* highlight go "linenos=table,hl_lines=8 15-17,linenostart=199" */>}}
|
||||
// ... code
|
||||
{{</* / highlight */>}}
|
||||
@ -102,7 +102,7 @@ See [Highlight](/functions/highlight/).
|
||||
|
||||
Highlighting in code fences is enabled by default.{{< new-in "0.60.0" >}}
|
||||
|
||||
````
|
||||
````txt
|
||||
```go {linenos=table,hl_lines=[8,"15-17"],linenostart=199}
|
||||
// ... code
|
||||
```
|
||||
|
@ -49,7 +49,7 @@ Then, in each of the movies, you would specify terms for each of these taxonomie
|
||||
|
||||
To continue with the example of a movie site, the following demonstrates content relationships from the perspective of the taxonomy:
|
||||
|
||||
```
|
||||
```txt
|
||||
Actor <- Taxonomy
|
||||
Bruce Willis <- Term
|
||||
The Sixth Sense <- Value
|
||||
@ -63,7 +63,7 @@ Actor <- Taxonomy
|
||||
|
||||
From the perspective of the content, the relationships would appear differently, although the data and labels used are the same:
|
||||
|
||||
```
|
||||
```txt
|
||||
Unbreakable <- Value
|
||||
Actors <- Taxonomy
|
||||
Bruce Willis <- Term
|
||||
|
@ -29,7 +29,7 @@ Hugo [v0.60.0](https://github.com/gohugoio/hugo/releases/tag/v0.60.0) made a swi
|
||||
|
||||
Create your Markdown the way you normally would with the appropriate headings. Here is some example content:
|
||||
|
||||
```
|
||||
```md
|
||||
<!-- Your front matter up here -->
|
||||
|
||||
## Introduction
|
||||
|
@ -4,7 +4,6 @@ linktitle: URL Management
|
||||
description: Hugo supports permalinks, aliases, link canonicalization, and multiple options for handling relative vs absolute URLs.
|
||||
date: 2017-02-01
|
||||
publishdate: 2017-02-01
|
||||
lastmod: 2017-03-09
|
||||
keywords: [aliases,redirects,permalinks,urls]
|
||||
categories: [content management]
|
||||
menu:
|
||||
@ -12,7 +11,6 @@ menu:
|
||||
parent: "content-management"
|
||||
weight: 110
|
||||
weight: 110 #rem
|
||||
draft: false
|
||||
aliases: [/extras/permalinks/,/extras/aliases/,/extras/urls/,/doc/redirects/,/doc/alias/,/doc/aliases/]
|
||||
toc: true
|
||||
---
|
||||
@ -141,7 +139,7 @@ On [multilingual sites][multilingual], each translation of a post can have uniqu
|
||||
|
||||
In `/posts/my-new-post.es.md`:
|
||||
|
||||
```
|
||||
```md
|
||||
---
|
||||
aliases:
|
||||
- /es/posts/my-original-post/
|
||||
@ -204,7 +202,7 @@ Hugo's default behavior is to render your content with "pretty" URLs. No non-sta
|
||||
|
||||
The following demonstrates the concept:
|
||||
|
||||
```
|
||||
```txt
|
||||
content/posts/_index.md
|
||||
=> example.com/posts/
|
||||
content/posts/post-1.md
|
||||
@ -219,7 +217,7 @@ If you want a specific piece of content to have an exact URL, you can specify th
|
||||
|
||||
See [Content Organization][contentorg] for more details on paths.
|
||||
|
||||
```
|
||||
```txt
|
||||
.
|
||||
└── content
|
||||
└── about
|
||||
@ -236,7 +234,7 @@ See [Content Organization][contentorg] for more details on paths.
|
||||
|
||||
Here's the same organization run with `hugo --uglyURLs`:
|
||||
|
||||
```
|
||||
```txt
|
||||
.
|
||||
└── content
|
||||
└── about
|
||||
@ -267,13 +265,13 @@ In the May 2014 release of Hugo v0.11, the default value of `canonifyURLs` was s
|
||||
|
||||
To find out the current value of `canonifyURLs` for your website, you may use the handy `hugo config` command added in v0.13.
|
||||
|
||||
```
|
||||
```txt
|
||||
hugo config | grep -i canon
|
||||
```
|
||||
|
||||
Or, if you are on Windows and do not have `grep` installed:
|
||||
|
||||
```
|
||||
```txt
|
||||
hugo config | FINDSTR /I canon
|
||||
```
|
||||
|
||||
|
@ -4,7 +4,6 @@ linktitle: Development
|
||||
description: Hugo relies heavily on contributions from the open source community.
|
||||
date: 2017-02-01
|
||||
publishdate: 2017-02-01
|
||||
lastmod: 2017-02-01
|
||||
categories: [contribute]
|
||||
keywords: [dev,open source]
|
||||
authors: [digitalcraftsman]
|
||||
@ -14,7 +13,6 @@ menu:
|
||||
weight: 10
|
||||
weight: 10
|
||||
sections_weight: 10
|
||||
draft: false
|
||||
toc: true
|
||||
---
|
||||
|
||||
@ -45,13 +43,13 @@ If you are having trouble following the installation guides for Go, check out [G
|
||||
|
||||
Once you're finished installing Go, let's confirm everything is working correctly. Open a terminal---or command line under Windows--and type the following:
|
||||
|
||||
```
|
||||
```txt
|
||||
go version
|
||||
```
|
||||
|
||||
You should see something similar to the following written to the console. Note that the version here reflects the most recent version of Go as of the last update for this page:
|
||||
|
||||
```
|
||||
```txt
|
||||
go version go1.12 darwin/amd64
|
||||
```
|
||||
|
||||
@ -59,7 +57,7 @@ Next, make sure that you set up your `GOPATH` [as described in the installation
|
||||
|
||||
You can print the `GOPATH` with `echo $GOPATH`. You should see a non-empty string containing a valid path to your Go workspace; for example:
|
||||
|
||||
```
|
||||
```txt
|
||||
/Users/<yourusername>/Code/go
|
||||
```
|
||||
|
||||
@ -103,19 +101,19 @@ Hub is a great tool for working with GitHub. The main site for it is [hub.github
|
||||
|
||||
On a Mac, you can install [Hub](https://github.com/github/hub) using [Homebrew](https://brew.sh):
|
||||
|
||||
```
|
||||
```txt
|
||||
brew install hub
|
||||
```
|
||||
|
||||
Now we'll create an [alias in Bash](https://tldp.org/LDP/abs/html/aliases.html) so that typing `git` actually runs `Hub`:
|
||||
|
||||
```
|
||||
```txt
|
||||
echo "alias git='hub'" >> ~/.bash_profile
|
||||
```
|
||||
|
||||
Confirm the installation:
|
||||
|
||||
```
|
||||
```txt
|
||||
git version 2.21.0
|
||||
hub version 2.10.0
|
||||
```
|
||||
@ -134,7 +132,7 @@ We're going to clone the [master Hugo repository](https://github.com/gohugoio/hu
|
||||
|
||||
So, let's make a new directory and clone that master repository:
|
||||
|
||||
```
|
||||
```txt
|
||||
mkdir $HOME/src
|
||||
cd $HOME/src
|
||||
git clone https://github.com/gohugoio/hugo.git
|
||||
@ -145,14 +143,14 @@ git clone https://github.com/gohugoio/hugo.git
|
||||
|
||||
And then, install dependencies of Hugo by running the following in the cloned directory:
|
||||
|
||||
```
|
||||
```txt
|
||||
cd $HOME/src/hugo
|
||||
go install
|
||||
```
|
||||
|
||||
Hugo relies on [mage](https://github.com/magefile/mage) for some convenient build and test targets. If you don't already have it, get it:
|
||||
|
||||
```
|
||||
```txt
|
||||
go install github.com/magefile/mage@latest
|
||||
```
|
||||
|
||||
@ -174,13 +172,13 @@ Now open your fork repository on GitHub and copy the remote URL of your fork. Yo
|
||||
|
||||
Switch back to the terminal and move into the directory of the cloned master repository from the last step.
|
||||
|
||||
```
|
||||
```txt
|
||||
cd $HOME/src/hugo
|
||||
```
|
||||
|
||||
Now Git needs to know that our fork exists by adding the copied remote url:
|
||||
|
||||
```
|
||||
```txt
|
||||
git remote add <YOUR-GITHUB-USERNAME> <COPIED REMOTE-URL>
|
||||
```
|
||||
|
||||
@ -188,7 +186,7 @@ git remote add <YOUR-GITHUB-USERNAME> <COPIED REMOTE-URL>
|
||||
|
||||
Alternatively, you can use the Git wrapper Hub. Hub makes forking a repository easy:
|
||||
|
||||
```
|
||||
```txt
|
||||
git fork
|
||||
```
|
||||
|
||||
@ -198,13 +196,13 @@ That command will log in to GitHub using your account, create a fork of the repo
|
||||
|
||||
Let's check if everything went right by listing all known remotes:
|
||||
|
||||
```
|
||||
```txt
|
||||
git remote -v
|
||||
```
|
||||
|
||||
The output should look similar:
|
||||
|
||||
```
|
||||
```txt
|
||||
digitalcraftsman git@github.com:digitalcraftsman/hugo.git (fetch)
|
||||
digitalcraftsman git@github.com:digitalcraftsman/hugo.git (push)
|
||||
origin https://github.com/gohugoio/hugo (fetch)
|
||||
@ -219,14 +217,14 @@ You should never develop against the "master" branch. The development team will
|
||||
|
||||
First, you should always pull the latest changes from the master repository:
|
||||
|
||||
```
|
||||
```txt
|
||||
git checkout master
|
||||
git pull
|
||||
```
|
||||
|
||||
Now we can create a new branch for your additions:
|
||||
|
||||
```
|
||||
```txt
|
||||
git checkout -b <BRANCH-NAME>
|
||||
```
|
||||
|
||||
@ -244,7 +242,7 @@ We have developed a [separate Hugo documentation contribution guide][docscontrib
|
||||
|
||||
While making changes in the codebase it's a good idea to build the binary to test them:
|
||||
|
||||
```
|
||||
```txt
|
||||
mage hugo
|
||||
```
|
||||
|
||||
@ -252,7 +250,7 @@ This command generates the binary file at the root of the repository.
|
||||
|
||||
If you want to install the binary in `$GOPATH/bin`, run
|
||||
|
||||
```
|
||||
```txt
|
||||
mage install
|
||||
```
|
||||
|
||||
@ -262,7 +260,7 @@ Sometimes changes on the codebase can cause unintended side effects. Or they don
|
||||
|
||||
Make sure the commands
|
||||
|
||||
```
|
||||
```txt
|
||||
mage -v check
|
||||
```
|
||||
|
||||
@ -272,13 +270,13 @@ passes.
|
||||
|
||||
The Go code style guide maybe is opinionated but it ensures that the codebase looks the same, regardless who wrote the code. Go comes with its own formatting tool. Let's apply the style guide to our additions:
|
||||
|
||||
```
|
||||
```txt
|
||||
mage fmt
|
||||
```
|
||||
|
||||
Once you made your additions commit your changes. Make sure that you follow our [code contribution guidelines](https://github.com/gohugoio/hugo/blob/master/CONTRIBUTING.md):
|
||||
|
||||
```
|
||||
```txt
|
||||
# Add all changed files
|
||||
git add --all
|
||||
git commit --message "YOUR COMMIT MESSAGE"
|
||||
@ -296,20 +294,20 @@ If you are unsure what a command does leave the commit as it is. We can fix your
|
||||
|
||||
Let's say you want to modify the last commit message. Run the following command and replace the current message:
|
||||
|
||||
```
|
||||
```txt
|
||||
git commit --amend -m"YOUR NEW COMMIT MESSAGE"
|
||||
```
|
||||
|
||||
Take a look at the commit log to see the change:
|
||||
|
||||
```
|
||||
```txt
|
||||
git log
|
||||
# Exit with q
|
||||
```
|
||||
|
||||
After making the last commit you may have forgot something. There is no need to create a new commit. Just add the latest changes and merge them into the intended commit:
|
||||
|
||||
```
|
||||
```txt
|
||||
git add --all
|
||||
git commit --amend
|
||||
```
|
||||
@ -322,13 +320,13 @@ Modifications such as those described in this section can have serious unintende
|
||||
|
||||
This is a bit more advanced. Git allows you to [rebase](https://git-scm.com/docs/git-rebase) commits interactively. In other words: it allows you to rewrite the commit history.
|
||||
|
||||
```
|
||||
```txt
|
||||
git rebase --interactive @~6
|
||||
```
|
||||
|
||||
The `6` at the end of the command represents the number of commits that should be modified. An editor should open and present a list of last six commit messages:
|
||||
|
||||
```
|
||||
```txt
|
||||
pick 80d02a1 tpl: Add hasPrefix to the template funcs' "smoke test"
|
||||
pick aaee038 tpl: Sort the smoke tests
|
||||
pick f0dbf2c tpl: Add the other test case for hasPrefix
|
||||
@ -341,7 +339,7 @@ In the case above we should merge the last two commits in the commit of this tut
|
||||
|
||||
All operations are written before the commit message. Replace "pick" with an operation. In this case `squash` or `s` for short:
|
||||
|
||||
```
|
||||
```txt
|
||||
pick 80d02a1 tpl: Add hasPrefix to the template funcs' "smoke test"
|
||||
pick aaee038 tpl: Sort the smoke tests
|
||||
pick f0dbf2c tpl: Add the other test case for hasPrefix
|
||||
@ -354,7 +352,7 @@ We also want to rewrite the commits message of the third last commit. We forgot
|
||||
|
||||
You should end up with a similar setup:
|
||||
|
||||
```
|
||||
```txt
|
||||
pick 80d02a1 tpl: Add hasPrefix to the template funcs' "smoke test"
|
||||
pick aaee038 tpl: Sort the smoke tests
|
||||
pick f0dbf2c tpl: Add the other test case for hasPrefix
|
||||
@ -367,7 +365,7 @@ Close the editor. It should open again with a new tab. A text is instructing you
|
||||
|
||||
A last time a new tab opens. Enter a new commit message and save again. Your terminal should contain a status message. Hopefully this one:
|
||||
|
||||
```
|
||||
```txt
|
||||
Successfully rebased and updated refs/heads/<BRANCHNAME>.
|
||||
```
|
||||
|
||||
@ -377,7 +375,7 @@ Check the commit log if everything looks as expected. Should an error occur you
|
||||
|
||||
To push our commits to the fork on GitHub we need to specify a destination. A destination is defined by the remote and a branch name. Earlier, the defined that the remote URL of our fork is the same as our GitHub handle, in my case `digitalcraftsman`. The branch should have the same as our local one. This makes it easy to identify corresponding branches.
|
||||
|
||||
```
|
||||
```txt
|
||||
git push --set-upstream <YOUR-GITHUB-USERNAME> <BRANCHNAME>
|
||||
```
|
||||
|
||||
|
@ -22,7 +22,7 @@ It's best to make changes to the Hugo docs on your local machine to check for co
|
||||
|
||||
You can then create a separate branch for your additions. Be sure to choose a descriptive branch name that best fits the type of content. The following is an example of a branch name you might use for adding a new website to the showcase:
|
||||
|
||||
```
|
||||
```txt
|
||||
git checkout -b jon-doe-showcase-addition
|
||||
```
|
||||
|
||||
@ -32,7 +32,7 @@ The Hugo docs make heavy use of Hugo's [archetypes][] feature. All content secti
|
||||
|
||||
Adding new content to the Hugo docs follows the same pattern, regardless of the content section:
|
||||
|
||||
```
|
||||
```txt
|
||||
hugo new <DOCS-SECTION>/<new-content-lowercase>.md
|
||||
```
|
||||
|
||||
@ -40,7 +40,7 @@ hugo new <DOCS-SECTION>/<new-content-lowercase>.md
|
||||
|
||||
Once you have cloned the Hugo repository, you can create a new function via the following command. Keep the filename lowercase.
|
||||
|
||||
```
|
||||
```txt
|
||||
hugo new functions/newfunction.md
|
||||
```
|
||||
|
||||
@ -96,7 +96,7 @@ Across many pages on the Hugo docs, the typical triple-back-tick Markdown syntax
|
||||
|
||||
Your options for languages are `xml`/`html`, `go`/`golang`, `md`/`markdown`/`mkd`, `handlebars`, `apache`, `toml`, `yaml`, `json`, `css`, `asciidoc`, `ruby`, `powershell`/`ps`, `scss`, `sh`/`zsh`/`bash`/`git`, `http`/`https`, and `javascript`/`js`.
|
||||
|
||||
````
|
||||
````txt
|
||||
```
|
||||
<h1>Hello world!</h1>
|
||||
```
|
||||
@ -115,7 +115,7 @@ With the `code` shortcodes, *you must include triple back ticks and a language d
|
||||
|
||||
`code` is the Hugo docs shortcode you'll use most often. `code` requires has only one named parameter: `file`. Here is the pattern:
|
||||
|
||||
```
|
||||
```go-html-template
|
||||
{{%/* code file="smart/file/name/with/path.html" download="download.html" copy="true" */%}}
|
||||
A whole bunch of coding going on up in here!
|
||||
{{%/* /code */%}}
|
||||
@ -139,7 +139,7 @@ This example HTML code block tells Hugo users the following:
|
||||
1. This file *could* live in `layouts/_default`, as demonstrated by `layouts/_default/single.html` as the value for `file`.
|
||||
2. This snippet is complete enough to be downloaded and implemented in a Hugo project, as demonstrated by `download="single.html"`.
|
||||
|
||||
```
|
||||
```go-html-template
|
||||
{{</* code file="layouts/_default/single.html" download="single.html" */>}}
|
||||
{{ define "main" }}
|
||||
<main>
|
||||
@ -207,7 +207,7 @@ The preceding `output` example will render as follows to the Hugo docs:
|
||||
|
||||
Blockquotes can be added to the Hugo documentation using [typical Markdown blockquote syntax][bqsyntax]:
|
||||
|
||||
```
|
||||
```md
|
||||
> Without the threat of punishment, there is no joy in flight.
|
||||
```
|
||||
|
||||
@ -217,7 +217,7 @@ The preceding blockquote will render as follows in the Hugo docs:
|
||||
|
||||
However, you can add a quick and easy `<cite>` element (added on the client via JavaScript) by separating your main blockquote and the citation with a hyphen with a single space on each side:
|
||||
|
||||
```
|
||||
```md
|
||||
> Without the threat of punishment, there is no joy in flight. - [Kobo Abe](https://en.wikipedia.org/wiki/Kobo_Abe)
|
||||
```
|
||||
|
||||
|
@ -35,7 +35,7 @@ more copies of *indent* according to the indentation nesting.
|
||||
## Jsonify options
|
||||
|
||||
indent ("")
|
||||
: Indendation to use.
|
||||
: Indentation to use.
|
||||
|
||||
prefix ("")
|
||||
: Indentation prefix.
|
||||
|
@ -25,6 +25,6 @@ aliases: []
|
||||
|
||||
This can be useful if you want to use [Gravatar](https://en.gravatar.com/) for generating a unique avatar:
|
||||
|
||||
```
|
||||
```html
|
||||
<img src="https://www.gravatar.com/avatar/{{ md5 "your@email.com" }}?s=100&d=identicon">
|
||||
```
|
||||
|
@ -27,7 +27,7 @@ copyright = "© 2015 Jane Doe. <a href=\"https://creativecommons.org/licenses/b
|
||||
|
||||
`{{ .Site.Copyright | safeHTML }}` in a template would then output:
|
||||
|
||||
```
|
||||
```html
|
||||
© 2015 Jane Doe. <a href="https://creativecommons.org/licenses/by/4.0/">Some rights reserved</a>.
|
||||
```
|
||||
|
||||
|
@ -22,7 +22,7 @@ aliases: []
|
||||
|
||||
Note that `upper` can be applied in your templates in more than one way:
|
||||
|
||||
```
|
||||
```go-html-template
|
||||
{{ upper "BatMan" }} → "BATMAN"
|
||||
{{ "BatMan" | upper }} → "BATMAN"
|
||||
```
|
||||
|
@ -19,13 +19,13 @@ aliases: []
|
||||
`urls.Parse` takes a url as input
|
||||
|
||||
|
||||
```
|
||||
```go-html-template
|
||||
{{ $url := urls.Parse "http://www.gohugo.io" }}
|
||||
```
|
||||
|
||||
and returns a [URL](https://godoc.org/net/url#URL) structure. The struct fields are accessed via the `.` notation:
|
||||
|
||||
```
|
||||
```go-html-template
|
||||
{{ $url.Scheme }} → "http"
|
||||
{{ $url.Host }} → "www.gohugo.io"
|
||||
```
|
||||
|
@ -70,7 +70,7 @@ There are some current limitations: For tables you can currently only apply it t
|
||||
|
||||
Note that attributes in [code fences](/content-management/syntax-highlighting/#highlighting-in-code-fences) must come after the opening tag, with any other highlighting processing instruction, e.g.:
|
||||
|
||||
````
|
||||
````txt
|
||||
```go {.myclass linenos=table,hl_lines=[8,"15-17"],linenostart=199}
|
||||
// ... code
|
||||
```
|
||||
|
@ -26,7 +26,7 @@ using the command-line `--config` switch.
|
||||
|
||||
Examples:
|
||||
|
||||
```
|
||||
```txt
|
||||
hugo --config debugconfig.toml
|
||||
hugo --config a.toml,b.toml,c.toml
|
||||
```
|
||||
@ -57,7 +57,7 @@ foo = "bar"
|
||||
- Files can be localized to become language specific.
|
||||
|
||||
|
||||
```
|
||||
```txt
|
||||
├── config
|
||||
│ ├── _default
|
||||
│ │ ├── config.toml
|
||||
@ -476,14 +476,14 @@ 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:
|
||||
```
|
||||
```txt
|
||||
cd ~/sites/yourhugosite
|
||||
hugo config | grep emoji
|
||||
```
|
||||
|
||||
which shows output like
|
||||
|
||||
```
|
||||
```txt
|
||||
enableemoji: true
|
||||
```
|
||||
{{% /note %}}
|
||||
@ -623,7 +623,7 @@ In addition to the 3 config options already mentioned, configuration key-values
|
||||
|
||||
For example, the following command will effectively set a website's title on Unix-like systems:
|
||||
|
||||
```
|
||||
```txt
|
||||
$ env HUGO_TITLE="Some Title" hugo
|
||||
```
|
||||
|
||||
|
@ -22,7 +22,7 @@ toc: true
|
||||
|
||||
Running the `hugo new site` generator from the command-line will create a directory structure with the following elements:
|
||||
|
||||
```
|
||||
```txt
|
||||
.
|
||||
├── archetypes
|
||||
├── config.toml
|
||||
|
@ -191,7 +191,7 @@ brew install hugo
|
||||
|
||||
If Homebrew is working properly, you should see something similar to the following:
|
||||
|
||||
```
|
||||
```txt
|
||||
==> Downloading https://homebrew.bintray.com/bottles/hugo-0.21.sierra.bottle.tar.gz
|
||||
######################################################################### 100.0%
|
||||
==> Pouring hugo-0.21.sierra.bottle.tar.gz
|
||||
@ -204,7 +204,7 @@ Replace `brew install hugo` with `brew install hugo --HEAD` if you want the abso
|
||||
|
||||
`brew` should have updated your path to include Hugo. You can confirm by opening a new terminal window and running a few commands:
|
||||
|
||||
```
|
||||
```txt
|
||||
$ # show the location of the hugo executable
|
||||
which hugo
|
||||
/usr/local/bin/hugo
|
||||
@ -246,7 +246,7 @@ All three locations will work for you. In the interest of brevity, this guide fo
|
||||
|
||||
Verify that the tarball wasn't corrupted during the download:
|
||||
|
||||
```
|
||||
```txt
|
||||
tar tvf ~/Downloads/hugo_X.Y_osx-64bit.tgz
|
||||
-rwxrwxrwx 0 0 0 0 Feb 22 04:02 hugo_X.Y_osx-64bit/hugo_X.Y_osx-64bit.tgz
|
||||
-rwxrwxrwx 0 0 0 0 Feb 22 03:24 hugo_X.Y_osx-64bit/README.md
|
||||
@ -257,7 +257,7 @@ The `.md` files are documentation for Hugo. The other file is the executable.
|
||||
|
||||
#### Step 4: Install Into Your `bin` Directory
|
||||
|
||||
```
|
||||
```txt
|
||||
# create the directory if needed
|
||||
mkdir -p ~/bin
|
||||
|
||||
@ -279,7 +279,7 @@ Hugo Static Site Generator v0.13 BuildDate: 2015-02-22T04:02:30-06:00
|
||||
|
||||
You may need to add your bin directory to your `PATH` environment variable. The `which` command will check for us. If it can find `hugo`, it will print the full path to it. Otherwise, it will not print anything.
|
||||
|
||||
```
|
||||
```txt
|
||||
# check if hugo is in the path
|
||||
which hugo
|
||||
/Users/USERNAME/bin/hugo
|
||||
@ -289,7 +289,7 @@ If `hugo` is not in your `PATH`:
|
||||
|
||||
1. Determine your default shell (zsh or bash).
|
||||
|
||||
```
|
||||
```bash
|
||||
echo $SHELL
|
||||
```
|
||||
|
||||
@ -297,19 +297,19 @@ If `hugo` is not in your `PATH`:
|
||||
|
||||
If your default shell is zsh:
|
||||
|
||||
```
|
||||
```zsh
|
||||
nano ~/.zprofile
|
||||
```
|
||||
|
||||
If your default shell is bash:
|
||||
|
||||
```
|
||||
```bash
|
||||
nano ~/.bash_profile
|
||||
```
|
||||
|
||||
3. Insert a line to add `$HOME/bin` to your existing `PATH`.
|
||||
|
||||
```
|
||||
```txt
|
||||
export PATH=$PATH:$HOME/bin
|
||||
```
|
||||
|
||||
@ -323,7 +323,7 @@ You've successfully installed Hugo.
|
||||
|
||||
If you want to compile Hugo yourself, you'll need to install Go (aka Golang). You can [install Go directly from the Go website](https://golang.org/dl/) or via Homebrew using the following command:
|
||||
|
||||
```
|
||||
```txt
|
||||
brew install go
|
||||
```
|
||||
|
||||
@ -331,7 +331,7 @@ brew install go
|
||||
|
||||
If you want to compile a specific version of Hugo, go to <https://github.com/gohugoio/hugo/releases> and download the source code for the version of your choice. If you want to compile Hugo with all the latest changes (which might include bugs), clone the Hugo repository:
|
||||
|
||||
```
|
||||
```txt
|
||||
git clone https://github.com/gohugoio/hugo
|
||||
```
|
||||
|
||||
@ -343,7 +343,7 @@ Cloning the Hugo repository directly means taking the good with the bad. By usin
|
||||
|
||||
Make the directory containing the source your working directory and then fetch Hugo's dependencies:
|
||||
|
||||
```
|
||||
```txt
|
||||
mkdir -p src/github.com/gohugoio
|
||||
ln -sf $(pwd) src/github.com/gohugoio/hugo
|
||||
|
||||
@ -354,7 +354,7 @@ This will fetch the absolute latest version of the dependencies. If Hugo fails t
|
||||
|
||||
Once you have properly configured your directory, you can compile Hugo using the following command:
|
||||
|
||||
```
|
||||
```txt
|
||||
go build -o hugo main.go
|
||||
```
|
||||
|
||||
@ -424,7 +424,7 @@ Run a few commands to verify that the executable is ready to run, and then build
|
||||
|
||||
At the prompt, type `hugo help` and press the <kbd>Enter</kbd> key. You should see output that starts with:
|
||||
|
||||
```
|
||||
```txt
|
||||
hugo is the main command, used to build your Hugo site.
|
||||
|
||||
Hugo is a Fast and Flexible Static Site Generator
|
||||
@ -437,7 +437,7 @@ If you do, then the installation is complete. If you don't, double-check the pat
|
||||
|
||||
At the prompt, change your directory to the `Sites` directory.
|
||||
|
||||
```
|
||||
```txt
|
||||
C:\Program Files> cd C:\Hugo\Sites
|
||||
C:\Hugo\Sites>
|
||||
```
|
||||
@ -446,13 +446,13 @@ C:\Hugo\Sites>
|
||||
|
||||
Run the command to generate a new site. I'm using `example.com` as the name of the site.
|
||||
|
||||
```
|
||||
```txt
|
||||
C:\Hugo\Sites> hugo new site example.com
|
||||
```
|
||||
|
||||
You should now have a directory at `C:\Hugo\Sites\example.com`. Change into that directory and list the contents. You should get output similar to the following:
|
||||
|
||||
```
|
||||
```txt
|
||||
C:\Hugo\Sites> cd example.com
|
||||
C:\Hugo\Sites\example.com> dir
|
||||
Directory of C:\hugo\sites\example.com
|
||||
@ -481,13 +481,13 @@ Directory of C:\hugo\sites\example.com
|
||||
|
||||
In any of the [Linux distributions that support snaps][snaps], you may install the "extended" Sass/SCSS version with this command:
|
||||
|
||||
```
|
||||
```txt
|
||||
snap install hugo --channel=extended
|
||||
```
|
||||
|
||||
To install the non-extended version without Sass/SCSS support:
|
||||
|
||||
```
|
||||
```txt
|
||||
snap install hugo
|
||||
```
|
||||
|
||||
@ -501,7 +501,7 @@ Hugo installed via Snap can write only inside the user’s `$HOME` directory---a
|
||||
|
||||
[@anthonyfok](https://github.com/anthonyfok) and friends in the [Debian Go Packaging Team](https://go-team.pages.debian.net/) maintains an official hugo [Debian package](https://packages.debian.org/hugo) which is shared with [Ubuntu](https://packages.ubuntu.com/hugo) and is installable via `apt-get`:
|
||||
|
||||
```
|
||||
```txt
|
||||
sudo apt-get install hugo
|
||||
```
|
||||
|
||||
@ -513,7 +513,7 @@ This option is not recommended because the Hugo in Linux package managers for De
|
||||
|
||||
You can also install Hugo from the Arch Linux [community](https://www.archlinux.org/packages/community/x86_64/hugo/) repository. Applies also to derivatives such as Manjaro.
|
||||
|
||||
```
|
||||
```txt
|
||||
sudo pacman -S hugo
|
||||
```
|
||||
|
||||
@ -521,7 +521,7 @@ sudo pacman -S hugo
|
||||
|
||||
Fedora maintains an [official package for Hugo](https://packages.fedoraproject.org/pkgs/hugo/hugo) which may be installed with:
|
||||
|
||||
```
|
||||
```txt
|
||||
sudo dnf install hugo
|
||||
```
|
||||
|
||||
@ -535,7 +535,7 @@ See the [related discussion in the Hugo forums][redhatforum].
|
||||
|
||||
openSUSE maintains an [official package](https://software.opensuse.org/package/hugo) for the Tumbleweed rolling release distribution, it may be installed with:
|
||||
|
||||
````
|
||||
````txt
|
||||
sudo zypper install hugo
|
||||
````
|
||||
|
||||
@ -543,7 +543,7 @@ sudo zypper install hugo
|
||||
|
||||
Solus includes Hugo in its package repository, it may be installed with:
|
||||
|
||||
```
|
||||
```txt
|
||||
sudo eopkg install hugo
|
||||
```
|
||||
|
||||
@ -551,7 +551,7 @@ sudo eopkg install hugo
|
||||
|
||||
OpenBSD provides a package for Hugo via `pkg_add`:
|
||||
|
||||
```
|
||||
```txt
|
||||
doas pkg_add hugo
|
||||
```
|
||||
|
||||
|
@ -85,7 +85,7 @@ echo theme = \"ananke\" >> config.toml
|
||||
|
||||
You can manually create content files (for example as `content/<CATEGORY>/<FILE>.<FORMAT>`) and provide metadata in them, however you can use the `new` command to do a few things for you (like add title and date):
|
||||
|
||||
```
|
||||
```txt
|
||||
hugo new posts/my-first-post.md
|
||||
```
|
||||
|
||||
@ -93,7 +93,7 @@ hugo new posts/my-first-post.md
|
||||
|
||||
Edit the newly created content file if you want, it will start with something like this:
|
||||
|
||||
```markdown
|
||||
```md
|
||||
---
|
||||
title: "My First Post"
|
||||
date: 2019-03-26T08:47:11+01:00
|
||||
@ -112,7 +112,7 @@ Now, start the Hugo server with [drafts](/getting-started/usage/#draft-future-an
|
||||
|
||||
{{< asciicast BvJBsF6egk9c163bMsObhuNXj >}}
|
||||
|
||||
```
|
||||
```txt
|
||||
▶ hugo server -D
|
||||
|
||||
| EN
|
||||
@ -148,7 +148,7 @@ Your new site already looks great, but you will want to tweak it a little before
|
||||
|
||||
Open up `config.toml` in a text editor:
|
||||
|
||||
```
|
||||
```toml
|
||||
baseURL = "https://example.org/"
|
||||
languageCode = "en-us"
|
||||
title = "My New Hugo Site"
|
||||
@ -169,7 +169,7 @@ For theme specific configuration options, see the [theme site](https://github.co
|
||||
|
||||
It is simple. Just call:
|
||||
|
||||
```
|
||||
```txt
|
||||
hugo -D
|
||||
```
|
||||
|
||||
|
@ -4,7 +4,6 @@ linktitle: Basic Usage
|
||||
description: Hugo's CLI is fully featured but simple to use, even for those who have very limited experience working from the command line.
|
||||
date: 2017-02-01
|
||||
publishdate: 2017-02-01
|
||||
lastmod: 2017-02-01
|
||||
categories: [getting started]
|
||||
keywords: [usage,livereload,command line,flags]
|
||||
menu:
|
||||
@ -13,7 +12,6 @@ menu:
|
||||
weight: 40
|
||||
weight: 40
|
||||
sections_weight: 40
|
||||
draft: false
|
||||
aliases: [/overview/usage/,/extras/livereload/,/doc/usage/,/usage/]
|
||||
toc: true
|
||||
---
|
||||
@ -24,13 +22,13 @@ The following is a description of the most common commands you will use while de
|
||||
|
||||
Once you have [installed Hugo][install], make sure it is in your `PATH`. You can test that Hugo has been installed correctly via the `help` command:
|
||||
|
||||
```
|
||||
```txt
|
||||
hugo help
|
||||
```
|
||||
|
||||
The output you see in your console should be similar to the following:
|
||||
|
||||
```
|
||||
```txt
|
||||
hugo is the main command, used to build your Hugo site.
|
||||
|
||||
Hugo is a Fast and Flexible Static Site Generator
|
||||
@ -112,7 +110,7 @@ This generates your website to the `public/` directory by default, although you
|
||||
|
||||
The command `hugo` renders your site into `public/` dir and is ready to be deployed to your web server:
|
||||
|
||||
```
|
||||
```txt
|
||||
hugo
|
||||
0 draft content
|
||||
0 future content
|
||||
@ -141,7 +139,7 @@ All three of these can be overridden during both local development *and* deploym
|
||||
|
||||
Hugo comes with [LiveReload](https://github.com/livereload/livereload-js) built in. There are no additional packages to install. A common way to use Hugo while developing a site is to have Hugo run a server with the `hugo server` command and watch for changes:
|
||||
|
||||
```
|
||||
```txt
|
||||
hugo server
|
||||
0 draft content
|
||||
0 future content
|
||||
@ -185,13 +183,13 @@ LiveReload works by injecting JavaScript into the pages Hugo generates. The scri
|
||||
|
||||
The following methods make it easy to disable LiveReload:
|
||||
|
||||
```
|
||||
```txt
|
||||
hugo server --watch=false
|
||||
```
|
||||
|
||||
Or...
|
||||
|
||||
```
|
||||
```txt
|
||||
hugo server --disableLiveReload
|
||||
```
|
||||
|
||||
|
@ -34,7 +34,7 @@ notesforauthors:
|
||||
|
||||
The spoiler is that you can even deploy your entire website from any compatible OS with no configuration. Using SFTP for example:
|
||||
|
||||
```
|
||||
```txt
|
||||
hugo --gc --minify
|
||||
rclone sync --interactive --sftp-host sftp.example.com --sftp-user www-data --sftp-ask-password public/ :sftp:www/
|
||||
```
|
||||
@ -49,7 +49,7 @@ For the next commands, we will assume you configured a remote you named ``hugo-w
|
||||
|
||||
The above 'spoiler' commands could become:
|
||||
|
||||
```
|
||||
```txt
|
||||
hugo --gc --minify
|
||||
rclone sync --interactive public/ hugo-www:www/
|
||||
```
|
||||
|
@ -27,7 +27,7 @@ notesforauthors:
|
||||
|
||||
The spoiler is that you can deploy your entire website with a command that looks like the following:
|
||||
|
||||
```
|
||||
```txt
|
||||
hugo && rsync -avz --delete public/ www-data@ftp.topologix.fr:~/www/
|
||||
```
|
||||
|
||||
@ -45,13 +45,13 @@ sudo apt-get install openssh-client
|
||||
|
||||
Then generate your ssh key. First, create the `.ssh` directory in your home directory if it doesn't exist:
|
||||
|
||||
```
|
||||
```txt
|
||||
~$ cd && mkdir .ssh & cd .ssh
|
||||
```
|
||||
|
||||
Next, execute this command to generate a new keypair called `rsa_id`:
|
||||
|
||||
```
|
||||
```txt
|
||||
~/.ssh/$ ssh-keygen -t rsa -q -C "For SSH" -f rsa_id
|
||||
```
|
||||
|
||||
@ -59,7 +59,7 @@ You'll be prompted for a passphrase, which is an extra layer of protection. Ente
|
||||
|
||||
To make logging in easier, add a definition for your web host to the file `~/.ssh/config` with the following command, replacing `HOST` with the IP address or hostname of your web host, and `USER` with the username you use to log in to your web host when transferring files:
|
||||
|
||||
```
|
||||
```txt
|
||||
~/.ssh/$ cat >> config <<EOF
|
||||
Host HOST
|
||||
Hostname HOST
|
||||
@ -71,13 +71,13 @@ EOF
|
||||
|
||||
Then copy your ssh public key to the remote server with the `ssh-copy-id` command:
|
||||
|
||||
```
|
||||
```txt
|
||||
~/.ssh/$ ssh-copy-id -i rsa_id.pub USER@HOST.com
|
||||
```
|
||||
|
||||
Now you can easily connect to the remote server:
|
||||
|
||||
```
|
||||
```txt
|
||||
~$ ssh user@host
|
||||
Enter passphrase for key '/home/mylogin/.ssh/rsa_id':
|
||||
```
|
||||
@ -88,7 +88,7 @@ Now that you can log in with your SSH key, let's create a script to automate dep
|
||||
|
||||
Create a new script called `deploy` the root of your Hugo tree:
|
||||
|
||||
```
|
||||
```txt
|
||||
~/websites/topologix.fr$ editor deploy
|
||||
```
|
||||
|
||||
@ -109,19 +109,19 @@ Note that `DIR` is the relative path from the remote user's home. If you have to
|
||||
|
||||
Save and close, and make the `deploy` file executable:
|
||||
|
||||
```
|
||||
```txt
|
||||
~/websites/topologix.fr$ chmod +x deploy
|
||||
```
|
||||
|
||||
Now you only have to enter the following command to deploy and update your website:
|
||||
|
||||
```
|
||||
```txt
|
||||
~/websites/topologix.fr$ ./deploy
|
||||
```
|
||||
|
||||
Your site builds and deploys:
|
||||
|
||||
```
|
||||
```txt
|
||||
Started building sites ...
|
||||
Built site for language en:
|
||||
0 draft content
|
||||
|
@ -26,20 +26,20 @@ aliases: []
|
||||
|
||||
Go to the [Firebase console][console] and create a new project (unless you already have a project). You will need to globally install `firebase-tools` (node.js):
|
||||
|
||||
```
|
||||
```txt
|
||||
npm install -g firebase-tools
|
||||
```
|
||||
|
||||
Log in to Firebase (setup on your local machine) using `firebase login`, which opens a browser where you can select your account. Use `firebase logout` in case you are already logged in but to the wrong account.
|
||||
|
||||
|
||||
```
|
||||
```txt
|
||||
firebase login
|
||||
```
|
||||
|
||||
In the root of your Hugo project, initialize the Firebase project with the `firebase init` command:
|
||||
|
||||
```
|
||||
```txt
|
||||
firebase init
|
||||
```
|
||||
|
||||
@ -55,7 +55,7 @@ From here:
|
||||
|
||||
To deploy your Hugo site, execute the `firebase deploy` command, and your site will be up in no time:
|
||||
|
||||
```
|
||||
```txt
|
||||
hugo && firebase deploy
|
||||
```
|
||||
|
||||
@ -63,7 +63,7 @@ hugo && firebase deploy
|
||||
|
||||
You can generate a deploy token using
|
||||
|
||||
```
|
||||
```txt
|
||||
firebase login:ci
|
||||
```
|
||||
|
||||
@ -75,7 +75,7 @@ This is a private secret and it should not appear in a public repository. Make s
|
||||
|
||||
You can then add a step in your build to do the deployment using the token:
|
||||
|
||||
```
|
||||
```txt
|
||||
firebase deploy --token $FIREBASE_DEPLOY_TOKEN
|
||||
```
|
||||
|
||||
|
@ -81,7 +81,7 @@ The Zone ID and API key are used to purge your zone – it’s not strictly need
|
||||
|
||||
Now it’s time to push the newly created repository to GitLab:
|
||||
|
||||
```
|
||||
```bash
|
||||
git remote add origin git@gitlab.com:youruser/ci-example.git
|
||||
git push -u origin master
|
||||
```
|
||||
|
@ -105,7 +105,7 @@ The [`git clone` method for installing themes][installthemes] is not supported b
|
||||
|
||||
A *better* approach is to install a theme as a proper git submodule. You can [read the GitHub documentation for submodules][ghsm] or those found on [Git's website][gitsm] for more information, but the command is similar to that of `git clone`:
|
||||
|
||||
```
|
||||
```txt
|
||||
cd themes
|
||||
git submodule add https://github.com/<THEMECREATOR>/<THEMENAME>
|
||||
```
|
||||
@ -114,7 +114,7 @@ It is recommended to only use stable versions of a theme (if it’s versioned) a
|
||||
|
||||
Switch to the theme's directory and list all available versions:
|
||||
|
||||
```
|
||||
```txt
|
||||
cd themes/<theme>
|
||||
git tag
|
||||
# exit with q
|
||||
@ -122,13 +122,13 @@ git tag
|
||||
|
||||
You can checkout a specific version as follows:
|
||||
|
||||
```
|
||||
```txt
|
||||
git checkout tags/<version-name>
|
||||
```
|
||||
|
||||
You can update a theme to the latest version by executing the following command in the *root* directory of your project:
|
||||
|
||||
```
|
||||
```txt
|
||||
git submodule update --rebase --remote
|
||||
```
|
||||
|
||||
|
@ -49,7 +49,7 @@ replacements {{< new-in "0.77.0" >}}
|
||||
|
||||
Note that the above terms maps directly to their counterparts in Go Modules. Some of these setting may be natural to set as OS environment variables. To set the proxy server to use, as an example:
|
||||
|
||||
```
|
||||
```txt
|
||||
env HUGO_MODULE_PROXY=https://proxy.example.org hugo
|
||||
```
|
||||
|
||||
|
@ -22,7 +22,7 @@ When using Hugo with [GitHub Pages](https://pages.github.com/), you can provide
|
||||
|
||||
In addition to the standard page variables, the 404 page has access to all site content accessible from `.Pages`.
|
||||
|
||||
```
|
||||
```txt
|
||||
▾ layouts/
|
||||
404.html
|
||||
```
|
||||
|
@ -108,7 +108,7 @@ Achievements:
|
||||
|
||||
You can use the following code to render the `Short Description` in your layout:
|
||||
|
||||
```
|
||||
```go-html-template
|
||||
<div>Short Description of {{.Site.Data.User0123.Name}}: <p>{{ index .Site.Data.User0123 "Short Description" | markdownify }}</p></div>
|
||||
```
|
||||
|
||||
@ -150,13 +150,13 @@ This will resolve internally to the following:
|
||||
|
||||
{{< new-in "0.84.0" >}} Both `getJSON` and `getCSV` takes an optional map as the last argument, e.g.:
|
||||
|
||||
```
|
||||
```go-html-template
|
||||
{{ $data := getJSON "https://example.org/api" (dict "Authorization" "Bearer abcd") }}
|
||||
```
|
||||
|
||||
If you need multiple values for the same header key, use a slice:
|
||||
|
||||
```
|
||||
```go-html-template
|
||||
{{ $data := getJSON "https://example.org/api" (dict "X-List" (slice "a" "b" "c")) }}
|
||||
```
|
||||
|
||||
|
@ -37,7 +37,7 @@ The [`readfile` function][readFile] reads a file from disk and converts it into
|
||||
|
||||
To use the `readFile` function in your templates, make sure the path is relative to your *Hugo project's root directory*:
|
||||
|
||||
```
|
||||
```go-html-template
|
||||
{{ readFile "/content/templates/local-file-templates" }}
|
||||
```
|
||||
|
||||
@ -45,7 +45,7 @@ To use the `readFile` function in your templates, make sure the path is relative
|
||||
|
||||
As `readFile` is a function, it is only available to you in your templates and not your content. However, we can create a simple [shortcode template][sct] that calls `readFile`, passes the first argument through the function, and then allows an optional second argument to send the file through the Markdown processor. The pattern for adding this shortcode to your content will be as follows:
|
||||
|
||||
```
|
||||
```go-html-template
|
||||
{{</* readfile file="/path/to/local/file.txt" markdown="true" */>}}
|
||||
```
|
||||
|
||||
|
@ -86,7 +86,7 @@ You also have the option to set the following in the front matter for a given pi
|
||||
|
||||
To add Disqus, include the following line in templates where you want your comments to appear:
|
||||
|
||||
```
|
||||
```go-html-template
|
||||
{{ template "_internal/disqus.html" . }}
|
||||
```
|
||||
|
||||
|
@ -59,7 +59,7 @@ It is important to note that all `_index.md` content files will render according
|
||||
|
||||
The following is an example of a typical Hugo project directory's content:
|
||||
|
||||
```
|
||||
```txt
|
||||
.
|
||||
...
|
||||
├── content
|
||||
|
@ -143,7 +143,7 @@ If you want to build custom navigation, you can do so using the `.Paginator` obj
|
||||
|
||||
The pages are built on the following form (`BLANK` means no value):
|
||||
|
||||
```
|
||||
```txt
|
||||
[SECTION/TAXONOMY/BLANK]/index.html
|
||||
[SECTION/TAXONOMY/BLANK]/page/1/index.html => redirect to [SECTION/TAXONOMY/BLANK]/index.html
|
||||
[SECTION/TAXONOMY/BLANK]/page/2/index.html
|
||||
|
@ -70,7 +70,7 @@ Examples:
|
||||
|
||||
The `.Site.GetPage` example that follows assumes the following project directory structure:
|
||||
|
||||
```
|
||||
```txt
|
||||
.
|
||||
└── content
|
||||
├── blog
|
||||
|
@ -36,7 +36,7 @@ To create a shortcode, place an HTML template in the `layouts/shortcodes` direct
|
||||
|
||||
You can organize your shortcodes in subfolders, e.g. in `layouts/shortcodes/boxes`. These shortcodes would then be accessible with their relative path, e.g:
|
||||
|
||||
```
|
||||
```go-html-template
|
||||
{{</* boxes/square */>}}
|
||||
```
|
||||
|
||||
@ -329,7 +329,7 @@ You also have an `img` shortcode with a single named `src` parameter that you wa
|
||||
|
||||
You can then call your shortcode in your content as follows:
|
||||
|
||||
```
|
||||
```go-html-template
|
||||
{{</* gallery class="content-gallery" */>}}
|
||||
{{</* img src="/images/one.jpg" */>}}
|
||||
{{</* img src="/images/two.jpg" */>}}
|
||||
|
@ -150,7 +150,7 @@ Weights of zero are thus treated specially: if two pages have unequal weights, a
|
||||
|
||||
Content can be assigned weight for each taxonomy that it's assigned to.
|
||||
|
||||
```
|
||||
```txt
|
||||
+++
|
||||
tags = [ "a", "b", "c" ]
|
||||
tags_weight = 22
|
||||
|
Loading…
x
Reference in New Issue
Block a user