mirror of
https://github.com/gohugoio/hugo.git
synced 2025-05-04 09:31:46 +03:00
Squashed 'docs/' content from commit fdea5430f
git-subtree-dir: docs git-subtree-split: fdea5430f89dfd849d39212abdf5ace0a4763e5a
This commit is contained in:
commit
b9bd35d72e
735 changed files with 38220 additions and 0 deletions
23
content/en/getting-started/_index.md
Normal file
23
content/en/getting-started/_index.md
Normal file
|
@ -0,0 +1,23 @@
|
|||
---
|
||||
title: Get Started
|
||||
linktitle: Get Started Overview
|
||||
description: Quick start and guides for installing Hugo on your preferred operating system.
|
||||
date: 2017-02-01
|
||||
publishdate: 2017-02-01
|
||||
lastmod: 2017-02-01
|
||||
categories: [getting started]
|
||||
keywords: [usage,docs]
|
||||
menu:
|
||||
docs:
|
||||
parent: "getting-started"
|
||||
weight: 1
|
||||
weight: 0001 #rem
|
||||
draft: false
|
||||
aliases: [/overview/introduction/]
|
||||
toc: false
|
||||
---
|
||||
|
||||
If this is your first time using Hugo and you've [already installed Hugo on your machine][installed], we recommend the [quick start][].
|
||||
|
||||
[installed]: /getting-started/installing/
|
||||
[quick start]: /getting-started/quick-start/
|
79
content/en/getting-started/code-toggle.md
Normal file
79
content/en/getting-started/code-toggle.md
Normal file
|
@ -0,0 +1,79 @@
|
|||
---
|
||||
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 example 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.
|
||||
|
||||
{{% note %}}
|
||||
The `code-toggler` shortcode is not an internal Hugo shortcode. This page's purpose is to test out a custom feature that we use throughout this site. See: https://github.com/gohugoio/gohugoioTheme/blob/master/layouts/shortcodes/code-toggle.html
|
||||
{{% /note %}}
|
||||
|
||||
## That Config Toggler
|
||||
|
||||
{{< code-toggle file="config">}}
|
||||
|
||||
baseURL: "https://yoursite.example.com/"
|
||||
title: "My Hugo Site"
|
||||
footnoteReturnLinkContents: "↩"
|
||||
permalinks:
|
||||
posts: /: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 >}}
|
522
content/en/getting-started/configuration.md
Normal file
522
content/en/getting-started/configuration.md
Normal file
|
@ -0,0 +1,522 @@
|
|||
---
|
||||
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
|
||||
---
|
||||
|
||||
|
||||
## Configuration File
|
||||
|
||||
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 %}}
|
||||
|
||||
{{< todo >}}TODO: distinct config.toml and others (the root object files){{< /todo >}}
|
||||
|
||||
## Configuration Directory
|
||||
|
||||
In addition to using a single site config file, one can use the `configDir` directory (default to `config/`) to maintain easier organization and environment specific settings.
|
||||
|
||||
- Each file represents a configuration root object, such as `Params`, `Menus`, `Languages` etc...
|
||||
- Each directory holds a group of files containing settings unique to an environment.
|
||||
- Files can be localized to become language specific.
|
||||
|
||||
|
||||
```
|
||||
├── config
|
||||
│ ├── _default
|
||||
│ │ ├── config.toml
|
||||
│ │ ├── languages.toml
|
||||
│ │ ├── menus.en.toml
|
||||
│ │ ├── menus.zh.toml
|
||||
│ │ └── params.toml
|
||||
│ ├── production
|
||||
│ │ ├── config.toml
|
||||
│ │ └── params.toml
|
||||
│ └── staging
|
||||
│ ├── config.toml
|
||||
│ └── params.toml
|
||||
```
|
||||
|
||||
Considering the structure above, when running `hugo --environment staging`, Hugo will use every settings from `config/_default` and merge `staging`'s on top of those.
|
||||
{{% note %}}
|
||||
Default environments are __development__ with `hugo serve` and __production__ with `hugo`.
|
||||
{{%/ 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). {{% module-mounts-note %}}
|
||||
|
||||
assetDir ("assets")
|
||||
: The directory where Hugo finds asset files used in [Hugo Pipes](/hugo-pipes/). {{% module-mounts-note %}}
|
||||
|
||||
baseURL
|
||||
: Hostname (and path) to the root, e.g. https://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.
|
||||
|
||||
caches
|
||||
: See [Configure File Caches](#configure-file-caches)
|
||||
|
||||
canonifyURLs (false)
|
||||
: Enable to turn relative URLs into absolute.
|
||||
|
||||
contentDir ("content")
|
||||
: The directory from where Hugo reads content files. {{% module-mounts-note %}}
|
||||
|
||||
dataDir ("data")
|
||||
: The directory from where Hugo reads data files. {{% module-mounts-note %}}
|
||||
|
||||
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/`.
|
||||
|
||||
disableAliases (false)
|
||||
: Will disable generation of alias redirects. Note that even if `disableAliases` is set, the aliases themselves are preserved on the page. The motivation with this is to be able to generate 301 redirects in an `.htaccess`, a Netlify `_redirects` file or similar using a custom output format.
|
||||
|
||||
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.
|
||||
|
||||
enableInlineShortcodes
|
||||
: Enable inline shortcode support. See [Inline Shortcodes](/templates/shortcode-templates/#inline-shortcodes).
|
||||
|
||||
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. It is used in the default [RSS template](/templates/rss/#configure-rss) and can be useful for [multi-lingual sites](/content-management/multilingual/#configure-multilingual-multihost).
|
||||
|
||||
languageName ("")
|
||||
: The site's language name.
|
||||
|
||||
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).
|
||||
|
||||
module
|
||||
: Module config see [Module Config](/hugo-modules/configuration/).
|
||||
|
||||
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 elements 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.
|
||||
|
||||
publishDir ("public")
|
||||
: The directory to where Hugo will write the final static site (the HTML files etc.).
|
||||
|
||||
pygmentsOptions ("")
|
||||
: A comma separated list of options for syntax highlighting. See the [Syntax Highlighting Options](/content-management/syntax-highlighting/#options) for the full list of available options.
|
||||
|
||||
pygmentsCodeFences (false)
|
||||
: Enables syntax highlighting in [code fences with a language tag](/content-management/syntax-highlighting/#highlight-in-code-fences) in markdown.
|
||||
|
||||
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.
|
||||
|
||||
pygmentsUseClassic (false)
|
||||
: Enable using Pygments instead of the much faster Chroma 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.
|
||||
|
||||
refLinksErrorLevel ("ERROR")
|
||||
: When using `ref` or `relref` to resolve page links and a link cannot resolved, it will be logged with this logg level. Valid values are `ERROR` (default) or `WARNING`. Any `ERROR` will fail the build (`exit -1`).
|
||||
|
||||
refLinksNotFoundURL
|
||||
: URL to be used as a placeholder when a page reference cannot be found in `ref` or `relref`. Is used as-is.
|
||||
|
||||
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")
|
||||
: A directory or a list of directories from where Hugo reads [static files][static-files]. {{% module-mounts-note %}}
|
||||
|
||||
summaryLength (70)
|
||||
: The length of text in words to show in a [`.Summary`](/content-management/summaries/#hugo-defined-automatic-summary-splitting).
|
||||
|
||||
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.
|
||||
|
||||
timeout (10000)
|
||||
: Timeout for generating page contents, in milliseconds (defaults to 10 seconds). *Note:* this is used to bail out of recursive content generation, if your pages are slow to generate (e.g., because they require large image processing or depend on remote contents) you might need to raise this limit.
|
||||
|
||||
title ("")
|
||||
: Site title.
|
||||
|
||||
titleCaseStyle ("AP")
|
||||
: See [Configure Title Case](#configure-title-case)
|
||||
|
||||
uglyURLs (false)
|
||||
: 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 %}}
|
||||
|
||||
## Configure Title Case
|
||||
|
||||
Set `titleCaseStyle` to specify the title style used by the [title](/functions/title/) template function and the automatic section titles in Hugo. It defaults to [AP Stylebook](https://www.apstylebook.com/) for title casing, but you can also set it to `Chicago` or `Go` (every word starts with a capital letter).
|
||||
|
||||
## Configuration Environment Variables
|
||||
|
||||
HUGO_NUMWORKERMULTIPLIER
|
||||
: Can be set to increase or reduce the number of workers used in parallel processing in Hugo. If not set, the number of logical CPUs will be used.
|
||||
|
||||
## 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.
|
||||
|
||||
|
||||
## Example Configuration
|
||||
|
||||
The following is a typical example of a configuration file. The values nested under `params:` will populate the [`.Site.Params`][] variable for use in [templates][]:
|
||||
|
||||
{{< code-toggle file="config">}}
|
||||
baseURL: "https://yoursite.example.com/"
|
||||
title: "My Hugo Site"
|
||||
footnoteReturnLinkContents: "↩"
|
||||
permalinks:
|
||||
posts: /:year/:month/:title/
|
||||
params:
|
||||
Subtitle: "Hugo is Absurdly Fast!"
|
||||
AuthorName: "Jon Doe"
|
||||
GitHubUser: "spf13"
|
||||
ListOfFoo:
|
||||
- "foo1"
|
||||
- "foo2"
|
||||
SidebarRecentLimit: 5
|
||||
{{< /code-toggle >}}
|
||||
|
||||
## 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.
|
||||
|
||||
To set config params, prefix the name with `HUGO_PARAMS_`
|
||||
{{% /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, `2018-02-22-mypage.md` will extract the date `2018-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/en/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-toggle file="config" >}}
|
||||
[blackfriday]
|
||||
angledQuotes = true
|
||||
fractions = false
|
||||
plainIDAnchors = true
|
||||
extensions = ["hardLineBreak"]
|
||||
{{< /code-toggle >}}
|
||||
|
||||
## 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.
|
||||
|
||||
## Configure File Caches
|
||||
|
||||
Since Hugo 0.52 you can configure more than just the `cacheDir`. This is the default configuration:
|
||||
|
||||
```toml
|
||||
[caches]
|
||||
[caches.getjson]
|
||||
dir = ":cacheDir/:project"
|
||||
maxAge = -1
|
||||
[caches.getcsv]
|
||||
dir = ":cacheDir/:project"
|
||||
maxAge = -1
|
||||
[caches.images]
|
||||
dir = ":resourceDir/_gen"
|
||||
maxAge = -1
|
||||
[caches.assets]
|
||||
dir = ":resourceDir/_gen"
|
||||
maxAge = -1
|
||||
[caches.modules]
|
||||
dir = ":cacheDir/modules"
|
||||
maxAge = -1
|
||||
```
|
||||
|
||||
You can override any of these cache setting in your own `config.toml`.
|
||||
|
||||
### The keywords explained
|
||||
|
||||
`:cacheDir`
|
||||
: This is the value of the `cacheDir` config option if set (can also be set via OS env variable `HUGO_CACHEDIR`). It will fall back to `/opt/build/cache/hugo_cache/` on Netlify, or a `hugo_cache` directory below the OS temp dir for the others. This means that if you run your builds on Netlify, all caches configured with `:cacheDir` will be saved and restored on the next build. For other CI vendors, please read their documentation. For an CircleCI example, see [this configuration](https://github.com/bep/hugo-sass-test/blob/6c3960a8f4b90e8938228688bc49bdcdd6b2d99e/.circleci/config.yml).
|
||||
|
||||
`:project`
|
||||
: The base directory name of the current Hugo project. This means that, in its default setting, every project will have separated file caches, which means that when you do `hugo --gc` you will not touch files related to other Hugo projects running on the same PC.
|
||||
|
||||
`:resourceDir`
|
||||
: This is the value of the `resourceDir` config option.
|
||||
|
||||
maxAge
|
||||
: This is the duration before a cache entry will be evicted, -1 means forever and 0 effectively turns that particular cache off. Uses Go's `time.Duration`, so valid values are `"10s"` (10 seconds), `"10m"` (10 minutes) and `"10h"` (10 hours).
|
||||
|
||||
dir
|
||||
: The absolute path to where the files for this cache will be stored. Allowed starting placeholders are `:cacheDir` and `:resourceDir` (see above).
|
||||
|
||||
## 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]: https://yaml.org/spec/
|
||||
[static-files]: /content-management/static-files/
|
93
content/en/getting-started/directory-structure.md
Normal file
93
content/en/getting-started/directory-structure.md
Normal file
|
@ -0,0 +1,93 @@
|
|||
---
|
||||
title: Directory Structure
|
||||
linktitle: Directory Structure
|
||||
description: Hugo's CLI scaffolds a project directory structure and then takes that single directory and uses it as the input to create a complete website.
|
||||
date: 2017-01-02
|
||||
publishdate: 2017-02-01
|
||||
lastmod: 2017-03-09
|
||||
categories: [getting started,fundamentals]
|
||||
keywords: [source, organization, directories]
|
||||
menu:
|
||||
docs:
|
||||
parent: "getting-started"
|
||||
weight: 50
|
||||
weight: 50
|
||||
sections_weight: 50
|
||||
draft: false
|
||||
aliases: [/overview/source-directory/]
|
||||
toc: true
|
||||
---
|
||||
|
||||
## New Site Scaffolding
|
||||
|
||||
{{< youtube sB0HLHjgQ7E >}}
|
||||
|
||||
Running the `hugo new site` generator from the command line will create a directory structure with the following elements:
|
||||
|
||||
```
|
||||
.
|
||||
├── archetypes
|
||||
├── config.toml
|
||||
├── content
|
||||
├── data
|
||||
├── layouts
|
||||
├── static
|
||||
└── themes
|
||||
```
|
||||
|
||||
|
||||
## Directory Structure Explained
|
||||
|
||||
The following is a high-level overview of each of the directories with links to each of their respective sections within the Hugo docs.
|
||||
|
||||
[`archetypes`](/content-management/archetypes/)
|
||||
: You can create new content files in Hugo using the `hugo new` command.
|
||||
By default, Hugo will create new content files with at least `date`, `title` (inferred from the file name), and `draft = true`. This saves time and promotes consistency for sites using multiple content types. You can create your own [archetypes][] with custom preconfigured front matter fields as well.
|
||||
|
||||
[`assets`][]
|
||||
: Stores all the files which need be processed by [Hugo Pipes]({{< ref "/hugo-pipes" >}}). Only the files whose `.Permalink` or `.RelPermalink` are used will be published to the `public` directory. Note: assets directory is not created by default.
|
||||
|
||||
[`config`](/getting-started/configuration/)
|
||||
: Hugo ships with a large number of [configuration directives](https://gohugo.io/getting-started/configuration/#all-variables-yaml).
|
||||
The [config directory](/getting-started/configuration/#configuration-directory) is where those directives are stored as JSON, YAML, or TOML files. Every root setting object can stand as its own file and structured by environments.
|
||||
Projects with minimal settings and no need for environment awareness can use a single `config.toml` file at its root.
|
||||
|
||||
Many sites may need little to no configuration, but Hugo ships with a large number of [configuration directives][] for more granular directions on how you want Hugo to build your website. Note: config directory is not created by default.
|
||||
|
||||
[`content`][]
|
||||
: All content for your website will live inside this directory. Each top-level folder in Hugo is considered a [content section][]. For example, if your site has three main sections---`blog`, `articles`, and `tutorials`---you will have three directories at `content/blog`, `content/articles`, and `content/tutorials`. Hugo uses sections to assign default [content types][].
|
||||
|
||||
[`data`](/templates/data-templates/)
|
||||
: This directory is used to store configuration files that can be
|
||||
used by Hugo when generating your website. You can write these files in YAML, JSON, or TOML format. In addition to the files you add to this folder, you can also create [data templates][] that pull from dynamic content.
|
||||
|
||||
[`layouts`][]
|
||||
: Stores templates in the form of `.html` files that specify how views of your content will be rendered into a static website. Templates include [list pages][lists], your [homepage][], [taxonomy templates][], [partials][], [single page templates][singles], and more.
|
||||
|
||||
[`static`][]
|
||||
: Stores all the static content: images, CSS, JavaScript, etc. When Hugo builds your site, all assets inside your static directory are copied over as-is. A good example of using the `static` folder is for [verifying site ownership on Google Search Console][searchconsole], where you want Hugo to copy over a complete HTML file without modifying its content.
|
||||
|
||||
{{% note %}}
|
||||
From **Hugo 0.31** you can have multiple static directories.
|
||||
{{% /note %}}
|
||||
|
||||
|
||||
[archetypes]: /content-management/archetypes/
|
||||
[configuration directives]: /getting-started/configuration/#all-variables-yaml
|
||||
[`content`]: /content-management/organization/
|
||||
[content section]: /content-management/sections/
|
||||
[content types]: /content-management/types/
|
||||
[data templates]: /templates/data-templates/
|
||||
[homepage]: /templates/homepage/
|
||||
[`layouts`]: /templates/
|
||||
[`static`]: /content-management/static-files/
|
||||
[lists]: /templates/list/
|
||||
[pagevars]: /variables/page/
|
||||
[partials]: /templates/partials/
|
||||
[searchconsole]: https://support.google.com/analytics/answer/1142414?hl=en
|
||||
[singles]: /templates/single-page-templates/
|
||||
[starters]: /tools/starter-kits/
|
||||
[taxonomies]: /content-management/taxonomies/
|
||||
[taxonomy templates]: /templates/taxonomy-templates/
|
||||
[types]: /content-management/types/
|
||||
[`assets`]: {{< ref "/hugo-pipes/introduction#asset-directory" >}}
|
528
content/en/getting-started/installing.md
Normal file
528
content/en/getting-started/installing.md
Normal file
|
@ -0,0 +1,528 @@
|
|||
---
|
||||
title: Install Hugo
|
||||
linktitle: Install Hugo
|
||||
description: Install Hugo on macOS, Windows, Linux, OpenBSD, FreeBSD, and on any machine where the Go compiler tool chain can run.
|
||||
date: 2016-11-01
|
||||
publishdate: 2016-11-01
|
||||
lastmod: 2018-01-02
|
||||
categories: [getting started,fundamentals]
|
||||
authors: ["Michael Henderson"]
|
||||
keywords: [install,pc,windows,linux,macos,binary,tarball]
|
||||
menu:
|
||||
docs:
|
||||
parent: "getting-started"
|
||||
weight: 30
|
||||
weight: 30
|
||||
sections_weight: 30
|
||||
draft: false
|
||||
aliases: [/tutorials/installing-on-windows/,/tutorials/installing-on-mac/,/overview/installing/,/getting-started/install,/install/]
|
||||
toc: true
|
||||
---
|
||||
|
||||
|
||||
{{% note %}}
|
||||
There is lots of talk about "Hugo being written in Go", but you don't need to install Go to enjoy Hugo. Just grab a precompiled binary!
|
||||
{{% /note %}}
|
||||
|
||||
Hugo is written in [Go](https://golang.org/) with support for multiple platforms. The latest release can be found at [Hugo Releases][releases].
|
||||
|
||||
Hugo currently provides pre-built binaries for the following:
|
||||
|
||||
* macOS (Darwin) for x64, i386, and ARM architectures
|
||||
* Windows
|
||||
* Linux
|
||||
* OpenBSD
|
||||
* FreeBSD
|
||||
|
||||
Hugo may also be compiled from source wherever the Go toolchain can run; e.g., on other operating systems such as DragonFly BSD, OpenBSD, Plan 9, Solaris, and others. See <https://golang.org/doc/install/source> for the full set of supported combinations of target operating systems and compilation architectures.
|
||||
|
||||
## Quick Install
|
||||
|
||||
### Binary (Cross-platform)
|
||||
|
||||
Download the appropriate version for your platform from [Hugo Releases][releases]. Once downloaded, the binary can be run from anywhere. You don't need to install it into a global location. This works well for shared hosts and other systems where you don't have a privileged account.
|
||||
|
||||
Ideally, you should install it somewhere in your `PATH` for easy use. `/usr/local/bin` is the most probable location.
|
||||
|
||||
### Homebrew (macOS)
|
||||
|
||||
If you are on macOS and using [Homebrew][brew], you can install Hugo with the following one-liner:
|
||||
|
||||
{{< code file="install-with-homebrew.sh" >}}
|
||||
brew install hugo
|
||||
{{< /code >}}
|
||||
|
||||
For more detailed explanations, read the installation guides that follow for installing on macOS and Windows.
|
||||
|
||||
### Linuxbrew (Linux)
|
||||
|
||||
If you are on Linux and using [Linuxbrew][linuxbrew], you can install Hugo with the following one-liner:
|
||||
|
||||
{{< code file="install-with-linuxbrew.sh" >}}
|
||||
brew install hugo
|
||||
{{< /code >}}
|
||||
|
||||
Installation guides for Linuxbrew are available on their [website][linuxbrew].
|
||||
|
||||
### Chocolatey (Windows)
|
||||
|
||||
If you are on a Windows machine and use [Chocolatey][] for package management, you can install Hugo with the following one-liner:
|
||||
|
||||
{{< code file="install-with-chocolatey.ps1" >}}
|
||||
choco install hugo -confirm
|
||||
{{< /code >}}
|
||||
|
||||
### Scoop (Windows)
|
||||
|
||||
If you are on a Windows machine and use [Scoop][] for package management, you can install Hugo with the following one-liner:
|
||||
|
||||
```bash
|
||||
scoop install hugo
|
||||
```
|
||||
|
||||
### Source
|
||||
|
||||
#### Prerequisite Tools
|
||||
|
||||
* [Git][installgit]
|
||||
* [Go (at least Go 1.11)](https://golang.org/dl/)
|
||||
|
||||
#### Fetch from GitHub
|
||||
|
||||
Since Hugo 0.48, Hugo uses the Go Modules support built into Go 1.11 to build. The easiest way to get started is to clone Hugo in a directory outside of the GOPATH, as in the following example:
|
||||
|
||||
{{< code file="from-gh.sh" >}}
|
||||
mkdir $HOME/src
|
||||
cd $HOME/src
|
||||
git clone https://github.com/gohugoio/hugo.git
|
||||
cd hugo
|
||||
go install --tags extended
|
||||
{{< /code >}}
|
||||
|
||||
Remove `--tags extended` if you do not want/need Sass/SCSS support.
|
||||
|
||||
{{% note %}}
|
||||
If you are a Windows user, substitute the `$HOME` environment variable above with `%USERPROFILE%`.
|
||||
{{% /note %}}
|
||||
|
||||
## macOS
|
||||
|
||||
### Assumptions
|
||||
|
||||
1. You know how to open the macOS terminal.
|
||||
2. You're running a modern 64-bit Mac.
|
||||
3. You will use `~/Sites` as the starting point for your site. (`~/Sites` is used for example purposes. If you are familiar enough with the command line and file system, you should have no issues following along with the instructions.)
|
||||
|
||||
### Pick Your Method
|
||||
|
||||
There are three ways to install Hugo on your Mac
|
||||
|
||||
1. The [Homebrew][brew] `brew` utility
|
||||
2. Distribution (i.e., tarball)
|
||||
3. Building from Source
|
||||
|
||||
There is no "best" way to install Hugo on your Mac. You should use the method that works best for your use case.
|
||||
|
||||
#### Pros and Cons
|
||||
|
||||
There are pros and cons to each of the aforementioned methods:
|
||||
|
||||
1. **Homebrew.** Homebrew is the simplest method and will require the least amount of work to maintain. The drawbacks aren't severe. The default package will be for the most recent release, so it will not have bug fixes until the next release (i.e., unless you install it with the `--HEAD` option). Hugo `brew` releases may lag a few days behind because it has to be coordinated with another team. Nevertheless, `brew` is the recommended installation method if you want to work from a stable, widely used source. Brew works well and is easy to update.
|
||||
|
||||
2. **Tarball.** Downloading and installing from the tarball is also easy, although it requires a few more command line skills than does Homebrew. Updates are easy as well: you just repeat the process with the new binary. This gives you the flexibility to have multiple versions on your computer. If you don't want to use `brew`, then the tarball/binary is a good choice.
|
||||
|
||||
3. **Building from Source.** Building from source is the most work. The advantage of building from source is that you don't have to wait for a release to add features or bug fixes. The disadvantage is that you need to spend more time managing the setup, which is manageable but requires more time than the preceding two options.
|
||||
|
||||
{{% note %}}
|
||||
Since building from source is appealing to more seasoned command line users, this guide will focus more on installing Hugo via Homebrew and Tarball.
|
||||
{{% /note %}}
|
||||
|
||||
### Install Hugo with Brew
|
||||
|
||||
{{< youtube WvhCGlLcrF8 >}}
|
||||
|
||||
#### Step 1: Install `brew` if you haven't already
|
||||
|
||||
Go to the `brew` website, <https://brew.sh/>, and follow the directions there. The most important step is the installation from the command line:
|
||||
|
||||
{{< code file="install-brew.sh" >}}
|
||||
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
|
||||
{{< /code >}}
|
||||
|
||||
#### Step 2: Run the `brew` Command to Install `hugo`
|
||||
|
||||
Installing Hugo using `brew` is as easy as the following:
|
||||
|
||||
{{< code file="install-brew.sh" >}}
|
||||
brew install hugo
|
||||
{{< /code >}}
|
||||
|
||||
If Homebrew is working properly, you should see something similar to the following:
|
||||
|
||||
```
|
||||
==> Downloading https://homebrew.bintray.com/bottles/hugo-0.21.sierra.bottle.tar.gz
|
||||
######################################################################### 100.0%
|
||||
==> Pouring hugo-0.21.sierra.bottle.tar.gz
|
||||
🍺 /usr/local/Cellar/hugo/0.21: 32 files, 17.4MB
|
||||
```
|
||||
|
||||
{{% note "Installing the Latest Hugo with Brew" %}}
|
||||
Replace `brew install hugo` with `brew install hugo --HEAD` if you want the absolute latest in-development version.
|
||||
{{% /note %}}
|
||||
|
||||
`brew` should have updated your path to include Hugo. You can confirm by opening a new terminal window and running a few commands:
|
||||
|
||||
```
|
||||
$ # show the location of the hugo executable
|
||||
which hugo
|
||||
/usr/local/bin/hugo
|
||||
|
||||
# show the installed version
|
||||
ls -l $( which hugo )
|
||||
lrwxr-xr-x 1 mdhender admin 30 Mar 28 22:19 /usr/local/bin/hugo -> ../Cellar/hugo/0.13_1/bin/hugo
|
||||
|
||||
# verify that hugo runs correctly
|
||||
hugo version
|
||||
Hugo Static Site Generator v0.13 BuildDate: 2015-03-09T21:34:47-05:00
|
||||
```
|
||||
|
||||
### Install Hugo from Tarball
|
||||
|
||||
#### Step 1: Decide on the location
|
||||
|
||||
When installing from the tarball, you have to decide if you're going to install the binary in `/usr/local/bin` or in your home directory. There are three camps on this:
|
||||
|
||||
1. Install it in `/usr/local/bin` so that all the users on your system have access to it. This is a good idea because it's a fairly standard place for executables. The downside is that you may need elevated privileges to put software into that location. Also, if there are multiple users on your system, they will all run the same version. Sometimes this can be an issue if you want to try out a new release.
|
||||
|
||||
2. Install it in `~/bin` so that only you can execute it. This is a good idea because it's easy to do, easy to maintain, and doesn't require elevated privileges. The downside is that only you can run Hugo. If there are other users on your site, they have to maintain their own copies. That can lead to people running different versions. Of course, this does make it easier for you to experiment with different releases.
|
||||
|
||||
3. Install it in your `Sites` directory. This is not a bad idea if you have only one site that you're building. It keeps every thing in a single place. If you want to try out new releases, you can make a copy of the entire site and update the Hugo executable.
|
||||
|
||||
All three locations will work for you. In the interest of brevity, this guide focuses on option #2.
|
||||
|
||||
#### Step 2: Download the Tarball
|
||||
|
||||
1. Open <https://github.com/gohugoio/hugo/releases> in your browser.
|
||||
|
||||
2. Find the current release by scrolling down and looking for the green tag that reads "Latest Release."
|
||||
|
||||
3. Download the current tarball for the Mac. The name will be something like `hugo_X.Y_osx-64bit.tgz`, where `X.YY` is the release number.
|
||||
|
||||
4. By default, the tarball will be saved to your `~/Downloads` directory. If you choose to use a different location, you'll need to change that in the following steps.
|
||||
|
||||
#### Step 3: Confirm your download
|
||||
|
||||
Verify that the tarball wasn't corrupted during the download:
|
||||
|
||||
```
|
||||
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
|
||||
-rwxrwxrwx 0 0 0 0 Jan 30 18:48 hugo_X.Y_osx-64bit/LICENSE.md
|
||||
```
|
||||
|
||||
The `.md` files are documentation for Hugo. The other file is the executable.
|
||||
|
||||
#### Step 4: Install Into Your `bin` Directory
|
||||
|
||||
```
|
||||
# create the directory if needed
|
||||
mkdir -p ~/bin
|
||||
|
||||
# make it the working directory
|
||||
cd ~/bin
|
||||
|
||||
# extract the tarball
|
||||
tar -xvzf ~/Downloads/hugo_X.Y_osx-64bit.tgz
|
||||
Archive: hugo_X.Y_osx-64bit.tgz
|
||||
x ./
|
||||
x ./hugo
|
||||
x ./LICENSE.md
|
||||
x ./README.md
|
||||
|
||||
# verify that it runs
|
||||
./hugo version
|
||||
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` 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.
|
||||
|
||||
```
|
||||
# check if hugo is in the path
|
||||
which hugo
|
||||
/Users/USERNAME/bin/hugo
|
||||
```
|
||||
|
||||
If `hugo` is not in your `PATH`, add it by updating your `~/.bash_profile` file. First, start up an editor:
|
||||
|
||||
```
|
||||
nano ~/.bash_profile
|
||||
```
|
||||
|
||||
Add a line to update your `PATH` variable:
|
||||
|
||||
```
|
||||
export PATH=$PATH:$HOME/bin
|
||||
```
|
||||
|
||||
Then save the file by pressing Control-X, then Y to save the file and return to the prompt.
|
||||
|
||||
Close the terminal and open a new terminal to pick up the changes to your profile. Verify your success by running the `which hugo` command again.
|
||||
|
||||
You've successfully installed Hugo.
|
||||
|
||||
### Build from Source on Mac
|
||||
|
||||
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:
|
||||
|
||||
```
|
||||
brew install go
|
||||
```
|
||||
|
||||
#### Step 1: Get the Source
|
||||
|
||||
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:
|
||||
|
||||
```
|
||||
git clone https://github.com/gohugoio/hugo
|
||||
```
|
||||
|
||||
{{% warning "Sometimes \"Latest\" = \"Bugs\""%}}
|
||||
Cloning the Hugo repository directly means taking the good with the bad. By using the bleeding-edge version of Hugo, you make your development susceptible to the latest features, as well as the latest bugs. Your feedback is appreciated. If you find a bug in the latest release, [please create an issue on GitHub](https://github.com/gohugoio/hugo/issues/new).
|
||||
{{% /warning %}}
|
||||
|
||||
#### Step 2: Compiling
|
||||
|
||||
Make the directory containing the source your working directory and then fetch Hugo's dependencies:
|
||||
|
||||
```
|
||||
mkdir -p src/github.com/gohugoio
|
||||
ln -sf $(pwd) src/github.com/gohugoio/hugo
|
||||
|
||||
# set the build path for Go
|
||||
export GOPATH=$(pwd)
|
||||
|
||||
go get
|
||||
```
|
||||
|
||||
This will fetch the absolute latest version of the dependencies. If Hugo fails to build, it may be the result of a dependency's author introducing a breaking change.
|
||||
|
||||
Once you have properly configured your directory, you can compile Hugo using the following command:
|
||||
|
||||
```
|
||||
go build -o hugo main.go
|
||||
```
|
||||
|
||||
Then place the `hugo` executable somewhere in your `$PATH`. You're now ready to start using Hugo.
|
||||
|
||||
## Windows
|
||||
|
||||
The following aims to be a complete guide to installing Hugo on your Windows PC.
|
||||
|
||||
{{< youtube G7umPCU-8xc >}}
|
||||
|
||||
### Assumptions
|
||||
|
||||
1. You will use `C:\Hugo\Sites` as the starting point for your new project.
|
||||
2. You will use `C:\Hugo\bin` to store executable files.
|
||||
|
||||
### Set up Your Directories
|
||||
|
||||
You'll need a place to store the Hugo executable, your [content][], and the generated Hugo website:
|
||||
|
||||
1. Open Windows Explorer.
|
||||
2. Create a new folder: `C:\Hugo`, assuming you want Hugo on your C drive, although this can go anywhere
|
||||
3. Create a subfolder in the Hugo folder: `C:\Hugo\bin`
|
||||
4. Create another subfolder in Hugo: `C:\Hugo\Sites`
|
||||
|
||||
### Technical Users
|
||||
|
||||
1. Download the latest zipped Hugo executable from [Hugo Releases][releases].
|
||||
2. Extract all contents to your `..\Hugo\bin` folder.
|
||||
3. In PowerShell or your preferred CLI, add the `hugo.exe` executable to your PATH by navigating to `C:\Hugo\bin` (or the location of your hugo.exe file) and use the command `set PATH=%PATH%;C:\Hugo\bin`. If the `hugo` command does not work after a reboot, you may have to run the command prompt as administrator.
|
||||
|
||||
### Less-technical Users
|
||||
|
||||
1. Go to the [Hugo Releases][releases] page.
|
||||
2. The latest release is announced on top. Scroll to the bottom of the release announcement to see the downloads. They're all ZIP files.
|
||||
3. Find the Windows files near the bottom (they're in alphabetical order, so Windows is last) – download either the 32-bit or 64-bit file depending on whether you have 32-bit or 64-bit Windows. (If you don't know, [see here](https://esupport.trendmicro.com/en-us/home/pages/technical-support/1038680.aspx).)
|
||||
4. Move the ZIP file into your `C:\Hugo\bin` folder.
|
||||
5. Double-click on the ZIP file and extract its contents. Be sure to extract the contents into the same `C:\Hugo\bin` folder – Windows will do this by default unless you tell it to extract somewhere else.
|
||||
6. You should now have three new files: The hugo executable (`hugo.exe`), `LICENSE`, and `README.md`.
|
||||
|
||||
Now you need to add Hugo to your Windows PATH settings:
|
||||
|
||||
#### For Windows 10 Users:
|
||||
|
||||
* Right click on the **Start** button.
|
||||
* Click on **System**.
|
||||
* Click on **Advanced System Settings** on the left.
|
||||
* Click on the **Environment Variables...** button on the bottom.
|
||||
* In the User variables section, find the row that starts with PATH (PATH will be all caps).
|
||||
* Double-click on **PATH**.
|
||||
* Click the **New...** button.
|
||||
* Type in the folder where `hugo.exe` was extracted, which is `C:\Hugo\bin` if you went by the instructions above. *The PATH entry should be the folder where Hugo lives and not the binary.* Press <kbd>Enter</kbd> when you're done typing.
|
||||
* Click OK at every window to exit.
|
||||
|
||||
{{% note "Path Editor in Windows 10"%}}
|
||||
The path editor in Windows 10 was added in the large [November 2015 Update](https://blogs.windows.com/windowsexperience/2015/11/12/first-major-update-for-windows-10-available-today/). You'll need to have that or a later update installed for the above steps to work. You can see what Windows 10 build you have by clicking on the <i class="fa fa-windows"></i> Start button → Settings → System → About. See [here](https://www.howtogeek.com/236195/how-to-find-out-which-build-and-version-of-windows-10-you-have/) for more.)
|
||||
{{% /note %}}
|
||||
|
||||
#### For Windows 7 and 8.x users:
|
||||
|
||||
Windows 7 and 8.1 do not include the easy path editor included in Windows 10, so non-technical users on those platforms are advised to install a free third-party path editor like [Windows Environment Variables Editor][Windows Environment Variables Editor] or [Path Editor](https://patheditor2.codeplex.com/).
|
||||
|
||||
### Verify the Executable
|
||||
|
||||
Run a few commands to verify that the executable is ready to run, and then build a sample site to get started.
|
||||
|
||||
#### 1. Open a Command Prompt
|
||||
|
||||
At the prompt, type `hugo help` and press the <kbd>Enter</kbd> key. You should see output that starts with:
|
||||
|
||||
```
|
||||
hugo is the main command, used to build your Hugo site.
|
||||
|
||||
Hugo is a Fast and Flexible Static Site Generator
|
||||
built with love by spf13 and friends in Go.
|
||||
|
||||
Complete documentation is available at https://gohugo.io/.
|
||||
```
|
||||
|
||||
If you do, then the installation is complete. If you don't, double-check the path that you placed the `hugo.exe` file in and that you typed that path correctly when you added it to your `PATH` variable. If you're still not getting the output, search the [Hugo discussion forum][forum] to see if others have already figured out our problem. If not, add a note---in the "Support" category---and be sure to include your command and the output.
|
||||
|
||||
At the prompt, change your directory to the `Sites` directory.
|
||||
|
||||
```
|
||||
C:\Program Files> cd C:\Hugo\Sites
|
||||
C:\Hugo\Sites>
|
||||
```
|
||||
|
||||
#### 2. Run the Command
|
||||
|
||||
Run the command to generate a new site. I'm using `example.com` as the name of the site.
|
||||
|
||||
```
|
||||
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:
|
||||
|
||||
```
|
||||
C:\Hugo\Sites> cd example.com
|
||||
C:\Hugo\Sites\example.com> dir
|
||||
Directory of C:\hugo\sites\example.com
|
||||
|
||||
04/13/2015 10:44 PM <DIR> .
|
||||
04/13/2015 10:44 PM <DIR> ..
|
||||
04/13/2015 10:44 PM <DIR> archetypes
|
||||
04/13/2015 10:44 PM 83 config.toml
|
||||
04/13/2015 10:44 PM <DIR> content
|
||||
04/13/2015 10:44 PM <DIR> data
|
||||
04/13/2015 10:44 PM <DIR> layouts
|
||||
04/13/2015 10:44 PM <DIR> static
|
||||
1 File(s) 83 bytes
|
||||
7 Dir(s) 6,273,331,200 bytes free
|
||||
```
|
||||
|
||||
### Troubleshoot Windows Installation
|
||||
|
||||
[@dhersam][] has created a nice video on common issues:
|
||||
|
||||
{{< youtube c8fJIRNChmU >}}
|
||||
|
||||
## Linux
|
||||
|
||||
### Snap Package
|
||||
|
||||
In any of the [Linux distributions that support snaps][snaps], you may install install the "extended" Sass/SCSS version with this command:
|
||||
|
||||
snap install hugo --channel=extended
|
||||
|
||||
To install the non-extended version without Sass/SCSS support:
|
||||
|
||||
snap install hugo
|
||||
|
||||
To switch between the two, use either `snap refresh hugo --channel=extended` or `snap refresh hugo --channel=stable`.
|
||||
|
||||
{{% note %}}
|
||||
Hugo installed via Snap can write only inside the user’s `$HOME` directory---and gvfs-mounted directories owned by the user---because of Snaps’ confinement and security model. More information is also available [in this related GitHub issue](https://github.com/gohugoio/hugo/issues/3143).
|
||||
{{% /note %}}
|
||||
|
||||
### Debian and Ubuntu
|
||||
|
||||
[@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`:
|
||||
|
||||
sudo apt-get install hugo
|
||||
|
||||
This installs the "extended" Sass/SCSS version.
|
||||
|
||||
### Arch Linux
|
||||
|
||||
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.
|
||||
|
||||
```
|
||||
sudo pacman -Syu hugo
|
||||
```
|
||||
|
||||
### Fedora, Red Hat and CentOS
|
||||
|
||||
Fedora maintains an [official package for Hugo](https://apps.fedoraproject.org/packages/hugo) which may be installed with:
|
||||
|
||||
sudo dnf install hugo
|
||||
|
||||
For the latest version, the Hugo package maintained by [@daftaupe](https://github.com/daftaupe) at Fedora Copr is recommended:
|
||||
|
||||
* <https://copr.fedorainfracloud.org/coprs/daftaupe/hugo/>
|
||||
|
||||
See the [related discussion in the Hugo forums][redhatforum].
|
||||
|
||||
### Solus
|
||||
|
||||
Solus includes Hugo in its package repository, it may be installed with:
|
||||
|
||||
```
|
||||
sudo eopkg install hugo
|
||||
```
|
||||
|
||||
## OpenBSD
|
||||
|
||||
OpenBSD provides a package for Hugo via `pkg_add`:
|
||||
|
||||
doas pkg_add hugo
|
||||
|
||||
|
||||
## Upgrade Hugo
|
||||
|
||||
Upgrading Hugo is as easy as downloading and replacing the executable you’ve placed in your `PATH` or run `brew upgrade hugo` if using Homebrew.
|
||||
|
||||
## Install Pygments (Optional)
|
||||
|
||||
The Hugo executable has one *optional* external dependency for source code highlighting ([Pygments][pygments]).
|
||||
|
||||
If you want to have source code highlighting using the [highlight shortcode][], you need to install the Python-based Pygments program. The procedure is outlined on the [Pygments homepage][pygments].
|
||||
|
||||
## Next Steps
|
||||
|
||||
Now that you've installed Hugo, read the [Quick Start guide][quickstart] and explore the rest of the documentation. If you have questions, ask the Hugo community directly by visiting the [Hugo Discussion Forum][forum].
|
||||
|
||||
[brew]: https://brew.sh/
|
||||
[Chocolatey]: https://chocolatey.org/
|
||||
[content]: /content-management/
|
||||
[@dhersam]: https://github.com/dhersam
|
||||
[forum]: https://discourse.gohugo.io
|
||||
[mage]: https://github.com/magefile/mage
|
||||
[dep]: https://github.com/golang/dep
|
||||
[highlight shortcode]: /content-management/shortcodes/#highlight
|
||||
[installgit]: https://git-scm.com/
|
||||
[installgo]: https://golang.org/dl/
|
||||
[linuxbrew]: https://linuxbrew.sh/
|
||||
[Path Editor]: https://patheditor2.codeplex.com/
|
||||
[pygments]: http://pygments.org
|
||||
[quickstart]: /getting-started/quick-start/
|
||||
[redhatforum]: https://discourse.gohugo.io/t/solved-fedora-copr-repository-out-of-service/2491
|
||||
[releases]: https://github.com/gohugoio/hugo/releases
|
||||
[Scoop]: https://scoop.sh/
|
||||
[snaps]: https://snapcraft.io/docs/installing-snapd
|
||||
[windowsarch]: https://esupport.trendmicro.com/en-us/home/pages/technical-support/1038680.aspx
|
||||
[Windows Environment Variables Editor]: http://eveditor.com/
|
186
content/en/getting-started/quick-start.md
Normal file
186
content/en/getting-started/quick-start.md
Normal file
|
@ -0,0 +1,186 @@
|
|||
---
|
||||
title: Quick Start
|
||||
linktitle: Quick Start
|
||||
description: Create a Hugo site using the beautiful Ananke theme.
|
||||
date: 2013-07-01
|
||||
publishdate: 2013-07-01
|
||||
categories: [getting started]
|
||||
keywords: [quick start,usage]
|
||||
authors: [Shekhar Gulati, Ryan Watters]
|
||||
menu:
|
||||
docs:
|
||||
parent: "getting-started"
|
||||
weight: 10
|
||||
weight: 10
|
||||
sections_weight: 10
|
||||
draft: false
|
||||
aliases: [/quickstart/,/overview/quickstart/]
|
||||
toc: true
|
||||
---
|
||||
|
||||
{{% note %}}
|
||||
This quick start uses `macOS` in the examples. For instructions about how to install Hugo on other operating systems, see [install](/getting-started/installing).
|
||||
|
||||
It is recommended to have [Git](https://git-scm.com/downloads) installed to run this tutorial.
|
||||
{{% /note %}}
|
||||
|
||||
|
||||
|
||||
## Step 1: Install Hugo
|
||||
|
||||
{{% note %}}
|
||||
`Homebrew`, a package manager for `macOS`, can be installed from [brew.sh](https://brew.sh/). See [install](/getting-started/installing) if you are running Windows etc.
|
||||
{{% /note %}}
|
||||
|
||||
```bash
|
||||
brew install hugo
|
||||
```
|
||||
|
||||
To verify your new install:
|
||||
|
||||
```bash
|
||||
hugo version
|
||||
```
|
||||
|
||||
|
||||
{{< asciicast ItACREbFgvJ0HjnSNeTknxWy9 >}}
|
||||
|
||||
|
||||
## Step 2: Create a New Site
|
||||
|
||||
```bash
|
||||
hugo new site quickstart
|
||||
```
|
||||
|
||||
The above will create a new Hugo site in a folder named `quickstart`.
|
||||
|
||||
{{< asciicast 3mf1JGaN0AX0Z7j5kLGl3hSh8 >}}
|
||||
|
||||
|
||||
## Step 3: Add a Theme
|
||||
|
||||
See [themes.gohugo.io](https://themes.gohugo.io/) for a list of themes to consider. This quickstart uses the beautiful [Ananke theme](https://themes.gohugo.io/gohugo-theme-ananke/).
|
||||
|
||||
```bash
|
||||
cd quickstart
|
||||
|
||||
# Download the theme
|
||||
git init
|
||||
git submodule add https://github.com/budparr/gohugo-theme-ananke.git themes/ananke
|
||||
# Note for non-git users:
|
||||
# - If you do not have git installed, you can download the archive of the latest
|
||||
# version of this theme from:
|
||||
# https://github.com/budparr/gohugo-theme-ananke/archive/master.zip
|
||||
# - Extract that .zip file to get a "gohugo-theme-ananke-master" directory.
|
||||
# - Rename that directory to "ananke", and move it into the "themes/" directory.
|
||||
# End of note for non-git users.
|
||||
|
||||
# Edit your config.toml configuration file
|
||||
# and add the Ananke theme.
|
||||
echo 'theme = "ananke"' >> config.toml
|
||||
```
|
||||
|
||||
|
||||
{{< asciicast 7naKerRYUGVPj8kiDmdh5k5h9 >}}
|
||||
|
||||
|
||||
## Step 4: Add Some Content
|
||||
|
||||
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 few things for you (like add title and date):
|
||||
|
||||
```
|
||||
hugo new posts/my-first-post.md
|
||||
```
|
||||
|
||||
{{< asciicast eUojYCfRTZvkEiqc52fUsJRBR >}}
|
||||
|
||||
Edit the newly created content file if you want, it will start with something like this:
|
||||
|
||||
```markdown
|
||||
---
|
||||
title: "My First Post"
|
||||
date: 2019-03-26T08:47:11+01:00
|
||||
draft: true
|
||||
---
|
||||
|
||||
```
|
||||
|
||||
|
||||
## Step 5: Start the Hugo server
|
||||
|
||||
Now, start the Hugo server with [drafts](/getting-started/usage/#draft-future-and-expired-content) enabled:
|
||||
|
||||
{{< asciicast BvJBsF6egk9c163bMsObhuNXj >}}
|
||||
|
||||
|
||||
|
||||
```
|
||||
▶ hugo server -D
|
||||
|
||||
| EN
|
||||
+------------------+----+
|
||||
Pages | 10
|
||||
Paginator pages | 0
|
||||
Non-page files | 0
|
||||
Static files | 3
|
||||
Processed images | 0
|
||||
Aliases | 1
|
||||
Sitemaps | 1
|
||||
Cleaned | 0
|
||||
|
||||
Total in 11 ms
|
||||
Watching for changes in /Users/bep/quickstart/{content,data,layouts,static,themes}
|
||||
Watching for config changes in /Users/bep/quickstart/config.toml
|
||||
Environment: "development"
|
||||
Serving pages from memory
|
||||
Running in Fast Render Mode. For full rebuilds on change: hugo server --disableFastRender
|
||||
Web Server is available at http://localhost:1313/ (bind address 127.0.0.1)
|
||||
Press Ctrl+C to stop
|
||||
```
|
||||
|
||||
|
||||
**Navigate to your new site at [http://localhost:1313/](http://localhost:1313/).**
|
||||
|
||||
Feel free to edit or add new content and simply refresh in browser to see changes quickly (You might need to force refresh in webbrowser, something like Ctrl-R usually works).
|
||||
|
||||
|
||||
## Step 6: Customize the Theme
|
||||
|
||||
Your new site already looks great, but you will want to tweak it a little before you release it to the public.
|
||||
|
||||
### Site Configuration
|
||||
|
||||
Open up `config.toml` in a text editor:
|
||||
|
||||
```
|
||||
baseURL = "https://example.org/"
|
||||
languageCode = "en-us"
|
||||
title = "My New Hugo Site"
|
||||
theme = "ananke"
|
||||
```
|
||||
|
||||
Replace the `title` above with something more personal. Also, if you already have a domain ready, set the `baseURL`. Note that this value is not needed when running the local development server.
|
||||
|
||||
{{% note %}}
|
||||
**Tip:** Make the changes to the site configuration or any other file in your site while the Hugo server is running, and you will see the changes in the browser right away, though you may need to [clear your cache](https://kb.iu.edu/d/ahic).
|
||||
{{% /note %}}
|
||||
|
||||
|
||||
For theme specific configuration options, see the [theme site](https://github.com/budparr/gohugo-theme-ananke).
|
||||
|
||||
**For further theme customization, see [Customize a Theme](/themes/customizing/).**
|
||||
|
||||
|
||||
### Step 7: Build static pages
|
||||
|
||||
It is simple. Just call:
|
||||
|
||||
```
|
||||
hugo
|
||||
```
|
||||
|
||||
Output will be in `./public/` directory by default (`-d`/`--destination` flag to change it, or set `publishdir` in the config file).
|
||||
|
||||
{{% note %}}
|
||||
Drafts do not get deployed; once you finish a post, update the header of the post to say `draft: false`. More info [here](/getting-started/usage/#draft-future-and-expired-content).
|
||||
{{% /note %}}
|
229
content/en/getting-started/usage.md
Normal file
229
content/en/getting-started/usage.md
Normal file
|
@ -0,0 +1,229 @@
|
|||
---
|
||||
title: Basic Usage
|
||||
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:
|
||||
docs:
|
||||
parent: "getting-started"
|
||||
weight: 40
|
||||
weight: 40
|
||||
sections_weight: 40
|
||||
draft: false
|
||||
aliases: [/overview/usage/,/extras/livereload/,/doc/usage/,/usage/]
|
||||
toc: true
|
||||
---
|
||||
|
||||
The following is a description of the most common commands you will use while developing your Hugo project. See the [Command Line Reference][commands] for a comprehensive view of Hugo's CLI.
|
||||
|
||||
## Test Installation
|
||||
|
||||
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:
|
||||
|
||||
```
|
||||
hugo help
|
||||
```
|
||||
|
||||
The output you see in your console should be similar to the following:
|
||||
|
||||
```
|
||||
hugo is the main command, used to build your Hugo site.
|
||||
|
||||
Hugo is a Fast and Flexible Static Site Generator
|
||||
built with love by spf13 and friends in Go.
|
||||
|
||||
Complete documentation is available at https://gohugo.io/.
|
||||
|
||||
Usage:
|
||||
hugo [flags]
|
||||
hugo [command]
|
||||
|
||||
Available Commands:
|
||||
check Contains some verification checks
|
||||
config Print the site configuration
|
||||
convert Convert your content to different formats
|
||||
env Print Hugo version and environment info
|
||||
gen A collection of several useful generators.
|
||||
help Help about any command
|
||||
import Import your site from others.
|
||||
list Listing out various types of content
|
||||
new Create new content for your site
|
||||
server A high performance webserver
|
||||
version Print the version number of Hugo
|
||||
|
||||
Flags:
|
||||
-b, --baseURL string hostname (and path) to the root, e.g. https://spf13.com/
|
||||
-D, --buildDrafts include content marked as draft
|
||||
-E, --buildExpired include expired content
|
||||
-F, --buildFuture include content with publishdate in the future
|
||||
--cacheDir string filesystem path to cache directory. Defaults: $TMPDIR/hugo_cache/
|
||||
--cleanDestinationDir remove files from destination not found in static directories
|
||||
--config string config file (default is path/config.yaml|json|toml)
|
||||
--configDir string config dir (default "config")
|
||||
-c, --contentDir string filesystem path to content directory
|
||||
--debug debug output
|
||||
-d, --destination string filesystem path to write files to
|
||||
--disableKinds strings disable different kind of pages (home, RSS etc.)
|
||||
--enableGitInfo add Git revision, date and author info to the pages
|
||||
-e, --environment string build environment
|
||||
--forceSyncStatic copy all files when static is changed.
|
||||
--gc enable to run some cleanup tasks (remove unused cache files) after the build
|
||||
-h, --help help for hugo
|
||||
--i18n-warnings print missing translations
|
||||
--ignoreCache ignores the cache directory
|
||||
-l, --layoutDir string filesystem path to layout directory
|
||||
--log enable Logging
|
||||
--logFile string log File path (if set, logging enabled automatically)
|
||||
--minify minify any supported output format (HTML, XML etc.)
|
||||
--noChmod don't sync permission mode of files
|
||||
--noTimes don't sync modification time of files
|
||||
--path-warnings print warnings on duplicate target paths etc.
|
||||
--quiet build in quiet mode
|
||||
--renderToMemory render to memory (only useful for benchmark testing)
|
||||
-s, --source string filesystem path to read files relative from
|
||||
--templateMetrics display metrics about template executions
|
||||
--templateMetricsHints calculate some improvement hints when combined with --templateMetrics
|
||||
-t, --theme strings themes to use (located in /themes/THEMENAME/)
|
||||
--themesDir string filesystem path to themes directory
|
||||
--trace file write trace to file (not useful in general)
|
||||
-v, --verbose verbose output
|
||||
--verboseLog verbose logging
|
||||
-w, --watch watch filesystem for changes and recreate as needed
|
||||
|
||||
Use "hugo [command] --help" for more information about a command.
|
||||
```
|
||||
|
||||
## The `hugo` Command
|
||||
|
||||
The most common usage is probably to run `hugo` with your current directory being the input directory.
|
||||
|
||||
This generates your website to the `public/` directory by default, although you can customize the output directory in your [site configuration][config] by changing the `publishDir` field.
|
||||
|
||||
The command `hugo` renders your site into `public/` dir and is ready to be deployed to your web server:
|
||||
|
||||
```
|
||||
hugo
|
||||
0 draft content
|
||||
0 future content
|
||||
99 pages created
|
||||
0 paginator pages created
|
||||
16 tags created
|
||||
0 groups created
|
||||
in 90 ms
|
||||
```
|
||||
|
||||
## Draft, Future, and Expired Content
|
||||
|
||||
Hugo allows you to set `draft`, `publishdate`, and even `expirydate` in your content's [front matter][]. By default, Hugo will not publish:
|
||||
|
||||
1. Content with a future `publishdate` value
|
||||
2. Content with `draft: true` status
|
||||
3. Content with a past `expirydate` value
|
||||
|
||||
All three of these can be overridden during both local development *and* deployment by adding the following flags to `hugo` and `hugo server`, respectively, or by changing the boolean values assigned to the fields of the same name (without `--`) in your [configuration][config]:
|
||||
|
||||
1. `--buildFuture`
|
||||
2. `--buildDrafts`
|
||||
3. `--buildExpired`
|
||||
|
||||
## LiveReload
|
||||
|
||||
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:
|
||||
|
||||
```
|
||||
hugo server
|
||||
0 draft content
|
||||
0 future content
|
||||
99 pages created
|
||||
0 paginator pages created
|
||||
16 tags created
|
||||
0 groups created
|
||||
in 120 ms
|
||||
Watching for changes in /Users/yourname/sites/yourhugosite/{data,content,layouts,static}
|
||||
Serving pages from /Users/yourname/sites/yourhugosite/public
|
||||
Web Server is available at http://localhost:1313/
|
||||
Press Ctrl+C to stop
|
||||
```
|
||||
|
||||
This will run a fully functioning web server while simultaneously watching your file system for additions, deletions, or changes within the following areas of your [project organization][dirs]:
|
||||
|
||||
* `/static/*`
|
||||
* `/content/*`
|
||||
* `/data/*`
|
||||
* `/i18n/*`
|
||||
* `/layouts/*`
|
||||
* `/themes/<CURRENT-THEME>/*`
|
||||
* `config`
|
||||
|
||||
Whenever you make changes, Hugo will simultaneously rebuild the site and continue to serve content. As soon as the build is finished, LiveReload tells the browser to silently reload the page.
|
||||
|
||||
Most Hugo builds are so fast that you may not notice the change unless looking directly at the site in your browser. This means that keeping the site open on a second monitor (or another half of your current monitor) allows you to see the most up-to-date version of your website without the need to leave your text editor.
|
||||
|
||||
{{% note "Closing `</body>` Tag"%}}
|
||||
Hugo injects the LiveReload `<script>` before the closing `</body>` in your templates and will therefore not work if this tag is not present..
|
||||
{{% /note %}}
|
||||
|
||||
### Disable LiveReload
|
||||
|
||||
LiveReload works by injecting JavaScript into the pages Hugo generates. The script creates a connection from the browser's web socket client to the Hugo web socket server.
|
||||
|
||||
LiveReload is awesome for development. However, some Hugo users may use `hugo server` in production to instantly display updated content. The following methods make it easy to disable LiveReload:
|
||||
|
||||
```
|
||||
hugo server --watch=false
|
||||
```
|
||||
|
||||
Or...
|
||||
|
||||
```
|
||||
hugo server --disableLiveReload
|
||||
```
|
||||
|
||||
The latter flag can be omitted by adding the following key-value to your `config.toml` or `config.yml` file, respectively:
|
||||
|
||||
```
|
||||
disableLiveReload = true
|
||||
```
|
||||
|
||||
```
|
||||
disableLiveReload: true
|
||||
```
|
||||
|
||||
## Deploy Your Website
|
||||
|
||||
After running `hugo server` for local web development, you need to do a final `hugo` run *without the `server` part of the command* to rebuild your site. You may then deploy your site by copying the `public/` directory to your production web server.
|
||||
|
||||
Since Hugo generates a static website, your site can be hosted *anywhere* using any web server. See [Hosting and Deployment][hosting] for methods for hosting and automating deployments contributed by the Hugo community.
|
||||
|
||||
{{% warning "Generated Files are **NOT** Removed on Site Build" %}}
|
||||
Running `hugo` *does not* remove generated files before building. This means that you should delete your `public/` directory (or the publish directory you specified via flag or configuration file) before running the `hugo` command. If you do not remove these files, you run the risk of the wrong files (e.g., drafts or future posts) being left in the generated site.
|
||||
{{% /warning %}}
|
||||
|
||||
### Dev vs Deploy Destinations
|
||||
|
||||
Hugo does not remove generated files before building. An easy workaround is to use different directories for development and production.
|
||||
|
||||
To start a server that builds draft content (helpful for editing), you can specify a different destination; e.g., a `dev/` directory:
|
||||
|
||||
```
|
||||
hugo server -wDs ~/Code/hugo/docs -d dev
|
||||
```
|
||||
|
||||
When the content is ready for publishing, use the default `public/` dir:
|
||||
|
||||
```
|
||||
hugo -s ~/Code/hugo/docs
|
||||
```
|
||||
|
||||
This prevents draft content from accidentally becoming available.
|
||||
|
||||
[commands]: /commands/
|
||||
[config]: /getting-started/configuration/
|
||||
[dirs]: /getting-started/directory-structure/
|
||||
[front matter]: /content-management/front-matter/
|
||||
[hosting]: /hosting-and-deployment/
|
||||
[install]: /getting-started/installing/
|
Loading…
Add table
Add a link
Reference in a new issue