diff options
Diffstat (limited to 'docs/content/en/getting-started')
-rw-r--r-- | docs/content/en/getting-started/_index.md | 23 | ||||
-rw-r--r-- | docs/content/en/getting-started/code-toggle.md | 75 | ||||
-rw-r--r-- | docs/content/en/getting-started/configuration.md | 404 | ||||
-rw-r--r-- | docs/content/en/getting-started/directory-structure.md | 89 | ||||
-rw-r--r-- | docs/content/en/getting-started/installing.md | 502 | ||||
-rw-r--r-- | docs/content/en/getting-started/quick-start.md | 140 | ||||
-rw-r--r-- | docs/content/en/getting-started/usage.md | 230 |
7 files changed, 1463 insertions, 0 deletions
diff --git a/docs/content/en/getting-started/_index.md b/docs/content/en/getting-started/_index.md new file mode 100644 index 000000000..478d1eaa6 --- /dev/null +++ b/docs/content/en/getting-started/_index.md @@ -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/ diff --git a/docs/content/en/getting-started/code-toggle.md b/docs/content/en/getting-started/code-toggle.md new file mode 100644 index 000000000..3e6b7da0d --- /dev/null +++ b/docs/content/en/getting-started/code-toggle.md @@ -0,0 +1,75 @@ +--- +title: Code Toggle +description: Code Toggle tryout and showcase. +date: 2018-03-16 +categories: [getting started,fundamentals] +keywords: [configuration,toml,yaml,json] +weight: 60 +sections_weight: 60 +draft: false +toc: true +--- + +## The Config Toggler! + +This is an exemple for the Config Toggle shortcode. +Its purpose is to let users choose a Config language by clicking on its corresponding tab. Upon doing so, every Code toggler on the page will be switched to the target language. Also, target language will be saved in user's `localStorage` so when they go to a different pages, Code Toggler display their last "toggled" config language. + +## That Config Toggler + +{{< code-toggle file="config">}} + +baseURL: "https://yoursite.example.com/" +title: "My Hugo Site" +footnoteReturnLinkContents: "↩" +permalinks: + post: /:year/:month/:title/ +params: + Subtitle: "Hugo is Absurdly Fast!" + AuthorName: "Jon Doe" + GitHubUser: "spf13" + ListOfFoo: + - "foo1" + - "foo2" + SidebarRecentLimit: 5 +{{< /code-toggle >}} + +## Another Config Toggler! + +{{< code-toggle file="theme">}} + +# theme.toml template for a Hugo theme + +name = "Hugo Theme" +license = "MIT" +licenselink = "https://github.com/budparr/gohugo.io/blob/master/LICENSE.md" +description = "" +homepage = "https://github.com/budparr/gohugo.io" +tags = ["website"] +features = ["", ""] +min_version = 0.18 + +[author] + name = "Bud Parr" + homepage = "https://github.com/budparr" + +{{< /code-toggle >}} + +## Two regular code blocks + +{{< code file="bf-config.toml" >}} +[blackfriday] + angledQuotes = true + fractions = false + plainIDAnchors = true + extensions = ["hardLineBreak"] +{{< /code >}} + +{{< code file="bf-config.yml" >}} +blackfriday: + angledQuotes: true + fractions: false + plainIDAnchors: true + extensions: + - hardLineBreak +{{< /code >}} diff --git a/docs/content/en/getting-started/configuration.md b/docs/content/en/getting-started/configuration.md new file mode 100644 index 000000000..518e4a2cc --- /dev/null +++ b/docs/content/en/getting-started/configuration.md @@ -0,0 +1,404 @@ +--- +title: Configure Hugo +linktitle: Configuration +description: How to configure your Hugo site. +date: 2013-07-01 +publishdate: 2017-01-02 +lastmod: 2017-03-05 +categories: [getting started,fundamentals] +keywords: [configuration,toml,yaml,json] +menu: + docs: + parent: "getting-started" + weight: 60 +weight: 60 +sections_weight: 60 +draft: false +aliases: [/overview/source-directory/,/overview/configuration/] +toc: true +--- + +Hugo uses the `config.toml`, `config.yaml`, or `config.json` (if found in the +site root) as the default site config file. + +The user can choose to override that default with one or more site config files +using the command line `--config` switch. + +Examples: + +``` +hugo --config debugconfig.toml +hugo --config a.toml,b.toml,c.toml +``` + +{{% note %}} +Multiple site config files can be specified as a comma-separated string to the `--config` switch. +{{% /note %}} + +## All Configuration Settings + +The following is the full list of Hugo-defined variables with their default +value in parentheses. Users may choose to override those values in their site +config file(s). + +archetypeDir ("archetypes") +: The directory where Hugo finds archetype files (content templates). + +baseURL +: Hostname (and path) to the root, e.g. http://bep.is/ + +blackfriday +: See [Configure Blackfriday](/getting-started/configuration/#configure-blackfriday) + +buildDrafts (false) +: Include drafts when building. + +buildExpired (false) +: Include content already expired. + +buildFuture (false) +: Include content with publishdate in the future. + +canonifyURLs (false) +: Enable to turn relative URLs into absolute. + +contentDir ("content") +: The directory from where Hugo reads content files. + +dataDir ("data") +: The directory from where Hugo reads data files. + +defaultContentLanguage ("en") +: Content without language indicator will default to this language. + +defaultContentLanguageInSubdir (false) +: Render the default content language in subdir, e.g. `content/en/`. The site root `/` will then redirect to `/en/`. + +disableHugoGeneratorInject (false) +: Hugo will, by default, inject a generator meta tag in the HTML head on the _home page only_. You can turn it off, but we would really appreciate if you don't, as this is a good way to watch Hugo's popularity on the rise. + +disableKinds ([]) +: Enable disabling of all pages of the specified *Kinds*. Allowed values in this list: `"page"`, `"home"`, `"section"`, `"taxonomy"`, `"taxonomyTerm"`, `"RSS"`, `"sitemap"`, `"robotsTXT"`, `"404"`. + +disableLiveReload (false) +: Disable automatic live reloading of browser window. + +disablePathToLower (false) +: Do not convert the url/path to lowercase. + +enableEmoji (false) +: Enable Emoji emoticons support for page content; see the [Emoji Cheat Sheet](https://www.webpagefx.com/tools/emoji-cheat-sheet/). + +enableGitInfo (false) +: Enable `.GitInfo` object for each page (if the Hugo site is versioned by Git). This will then update the `Lastmod` parameter for each page using the last git commit date for that content file. + +enableMissingTranslationPlaceholders (false) +: Show a placeholder instead of the default value or an empty string if a translation is missing. + +enableRobotsTXT (false) +: Enable generation of `robots.txt` file. + +frontmatter + +: See [Front matter Configuration](#configure-front-matter). + +footnoteAnchorPrefix ("") +: Prefix for footnote anchors. + +footnoteReturnLinkContents ("") +: Text to display for footnote return links. + +googleAnalytics ("") +: Google Analytics tracking ID. + +hasCJKLanguage (false) +: If true, auto-detect Chinese/Japanese/Korean Languages in the content. This will make `.Summary` and `.WordCount` behave correctly for CJK languages. + +imaging +: See [Image Processing Config](/content-management/image-processing/#image-processing-config). + +languages +: See [Configure Languages](/content-management/multilingual/#configure-languages). + +languageCode ("") +: The site's language code. + +disableLanguages +: See [Disable a Language](/content-management/multilingual/#disable-a-language) + +layoutDir ("layouts") +: The directory from where Hugo reads layouts (templates). + +log (false) +: Enable logging. + +logFile ("") +: Log File path (if set, logging enabled automatically). + +menu +: See [Add Non-content Entries to a Menu](/content-management/menus/#add-non-content-entries-to-a-menu). + +metaDataFormat ("toml") +: Front matter meta-data format. Valid values: `"toml"`, `"yaml"`, or `"json"`. + +newContentEditor ("") +: The editor to use when creating new content. + +noChmod (false) +: Don't sync permission mode of files. + +noTimes (false) +: Don't sync modification time of files. + +paginate (10) +: Default number of pages per page in [pagination](/templates/pagination/). + +paginatePath ("page") +: The path element used during pagination (https://example.com/page/2). + +permalinks +: See [Content Management](/content-management/urls/#permalinks). + +pluralizeListTitles (true) +: Pluralize titles in lists. + +preserveTaxonomyNames (false) +: Preserve special characters in taxonomy names ("Gérard Depardieu" vs "Gerard Depardieu"). + +publishDir ("public") +: The directory to where Hugo will write the final static site (the HTML files etc.). + +pygmentsCodeFencesGuessSyntax (false) +: Enable syntax guessing for code fences without specified language. + +pygmentsStyle ("monokai") +: Color-theme or style for syntax highlighting. See [Pygments Color Themes](https://help.farbox.com/pygments.html). + +pygmentsUseClasses (false) +: Enable using external CSS for syntax highlighting. + +related +: See [Related Content](/content-management/related/#configure-related-content). + +relativeURLs (false) +: Enable this to make all relative URLs relative to content root. Note that this does not affect absolute URLs. + +rssLimit (unlimited) +: Maximum number of items in the RSS feed. + +sectionPagesMenu ("") +: See ["Section Menu for Lazy Bloggers"](/templates/menu-templates/#section-menu-for-lazy-bloggers). + +sitemap +: Default [sitemap configuration](/templates/sitemap-template/#configure-sitemap-xml). + +staticDir ("static") +: Relative directory from where Hugo reads static files. + +stepAnalysis (false) +: Display memory and timing of different steps of the program. + +summaryLength (70) +: The length of text to show in a [`.Summary`](/content-management/summaries/#hugo-defined-automatic-summary-splitting). + +taxonomies +: See [Configure Taxonomies](/content-management/taxonomies#configure-taxonomies). + +theme ("") +: Theme to use (located by default in `/themes/THEMENAME/`). + +themesDir ("themes") +: The directory where Hugo reads the themes from. + +title ("") +: Site title. + +uglyURLs (false) +: When enabled, creates URL of the form `/filename.html` instead of `/filename/`. + +verbose (false) +: Enable verbose output. + +verboseLog (false) +: Enable verbose logging. + +watch (false) +: Watch filesystem for changes and recreate as needed. + +{{% note %}} +If you are developing your site on a \*nix machine, here is a handy shortcut for finding a configuration option from the command line: +``` +cd ~/sites/yourhugosite +hugo config | grep emoji +``` + +which shows output like + +``` +enableemoji: true +``` +{{% /note %}} + +## Configuration Lookup Order + +Similar to the template [lookup order][], Hugo has a default set of rules for searching for a configuration file in the root of your website's source directory as a default behavior: + +1. `./config.toml` +2. `./config.yaml` +3. `./config.json` + +In your `config` file, you can direct Hugo as to how you want your website rendered, control your website's menus, and arbitrarily define site-wide parameters specific to your project. + + +## 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: + post: /: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. +{{% /note %}} + +{{< todo >}} +Test and document setting params via JSON env var. +{{< /todo >}} + +## Ignore Files When Rendering + +The following statement inside `./config.toml` will cause Hugo to ignore files ending with `.foo` and `.boo` when rendering: + +``` +ignoreFiles = [ "\\.foo$", "\\.boo$" ] +``` + +The above is a list of regular expressions. Note that the backslash (`\`) character is escaped in this example to keep TOML happy. + +## Configure Front Matter + +### Configure Dates + +Dates are important in Hugo, and you can configure how Hugo assigns dates to your content pages. You do this by adding a `frontmatter` section to your `config.toml`. + + +The default configuration is: + +```toml +[frontmatter] +date = ["date","publishDate", "lastmod"] +lastmod = [":git" "lastmod", "date","publishDate"] +publishDate = ["publishDate", "date"] +expiryDate = ["expiryDate"] +``` + +If you, as an example, have a non-standard date parameter in some of your content, you can override the setting for `date`: + + ```toml +[frontmatter] +date = [ "myDate", ":default"] +``` + +The `:default` is a shortcut to the default settings. The above will set `.Date` to the date value in `myDate` if present, if not we will look in `date`,`publishDate`, `lastmod` and pick the first valid date. + +In the list to the right, values starting with ":" are date handlers with a special meaning (see below). The others are just names of date parameters (case insensitive) in your front matter configuration. Also note that Hugo have some built-in aliases to the above: `lastmod` => `modified`, `publishDate` => `pubdate`, `published` and `expiryDate` => `unpublishdate`. With that, as an example, using `pubDate` as a date in front matter, will, by default, be assigned to `.PublishDate`. + +The special date handlers are: + + +`:fileModTime` +: Fetches the date from the content file's last modification timestamp. + +An example: + + ```toml +[frontmatter] +lastmod = ["lastmod" ,":fileModTime", ":default"] +``` + + +The above will try first to extract the value for `.Lastmod` starting with the `lastmod` front matter parameter, then the content file's modification timestamp. The last, `:default` should not be needed here, but Hugo will finally look for a valid date in `:git`, `date` and then `publishDate`. + + +`:filename` +: Fetches the date from the content file's filename. For example, `218-02-22-mypage.md` will extract the date `218-02-22`. Also, if `slug` is not set, `mypage` will be used as the value for `.Slug`. + +An example: + +```toml +[frontmatter] +date = [":filename", ":default"] +``` + +The above will try first to extract the value for `.Date` from the filename, then it will look in front matter parameters `date`, `publishDate` and lastly `lastmod`. + + +`:git` +: This is the Git author date for the last revision of this content file. This will only be set if `--enableGitInfo` is set or `enableGitInfo = true` is set in site config. + +## Configure Blackfriday + +[Blackfriday](https://github.com/russross/blackfriday) is Hugo's built-in Markdown rendering engine. + +Hugo typically configures Blackfriday with sane default values that should fit most use cases reasonably well. + +However, if you have specific needs with respect to Markdown, Hugo exposes some of its Blackfriday behavior options for you to alter. The following table lists these Hugo options, paired with the corresponding flags from Blackfriday's source code ( [html.go](https://github.com/russross/blackfriday/blob/master/html.go) and [markdown.go](https://github.com/russross/blackfriday/blob/master/markdown.go)). + +{{< readfile file="/content/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. + +## Configuration Format Specs + +* [TOML Spec][toml] +* [YAML Spec][yaml] +* [JSON Spec][json] + +[`.Site.Params`]: /variables/site/ +[directory structure]: /getting-started/directory-structure +[json]: https://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf "Specification for JSON, JavaScript Object Notation" +[lookup order]: /templates/lookup-order/ +[Output Formats]: /templates/output-formats/ +[templates]: /templates/ +[toml]: https://github.com/toml-lang/toml +[yaml]: http://yaml.org/spec/ diff --git a/docs/content/en/getting-started/directory-structure.md b/docs/content/en/getting-started/directory-structure.md new file mode 100644 index 000000000..ebfe6646a --- /dev/null +++ b/docs/content/en/getting-started/directory-structure.md @@ -0,0 +1,89 @@ +--- +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. + +[`config.toml`](/getting-started/configuration/) +: Every Hugo project should have a configuration file in TOML, YAML, or JSON format at the 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. + +[`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 for your future website: 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 %}} + +{{% note %}} +Hugo does not currently ship with an asset pipeline ([#3207](https://github.com/gohugoio/hugo/issues/3207)). You can solicit support from the community in the [Hugo forums](https://discourse.gohugo.io) or check out a few of the [Hugo starter kits](/tools/starter-kits/) for examples of how Hugo developers are managing static assets. +{{% /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/ diff --git a/docs/content/en/getting-started/installing.md b/docs/content/en/getting-started/installing.md new file mode 100644 index 000000000..bf0bde50d --- /dev/null +++ b/docs/content/en/getting-started/installing.md @@ -0,0 +1,502 @@ +--- +title: Install Hugo +linktitle: Install Hugo +description: Install Hugo on macOS, Windows, Linux, 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 +* FreeBSD + +Hugo may also be compiled from source wherever the Go compiler tool chain 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. + +### 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 >}} + +### Source + +#### Prerequisite Tools + +* [Git][installgit] +* [Go (latest or previous version)][installgo] + +#### Vendored Dependencies + +Hugo uses [dep][] to vendor dependencies, but we don't commit the vendored packages themselves to the Hugo git repository. Therefore, a simple `go get` is *not* supported because the command is not vendor aware. + +The simplest way is to use [mage][] (a Make alternative for Go projects.) + +#### Fetch from GitHub + +{{< code file="from-gh.sh" >}} +go get github.com/magefile/mage +go get -d github.com/gohugoio/hugo +cd ${GOPATH:-$HOME/go}/src/github.com/gohugoio/hugo +mage vendor +mage install +{{< /code >}} + +{{% 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. The `hugo` executable will be named as `hugo_hugo-version_platform_arch.exe`. Rename the executable to `hugo.exe` for ease of use. +4. 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: hugo executable (e.g. `hugo_0.18_windows_amd64.exe`), `license.md`, and `readme.md`. (You can delete the ZIP download now.) Rename that hugo executable (`hugo_hugo-version_platform_arch.exe`) to `hugo.exe` for ease of use. + +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]: + +``` +snap install hugo +``` + +### Debian and Ubuntu + +Debian and Ubuntu provide a `hugo` version via `apt-get`: + +``` +sudo apt-get install hugo +``` + +#### Pros + +* Native Debian/Ubuntu package maintained by Debian Developers +* Pre-installed bash completion script and `man` pages + +#### Cons + +* Might not be the latest version, especially if you are using an older, stable version (e.g., Ubuntu 16.04 LTS). Until backports and PPA are available, you may consider installing the Hugo snap package to get the latest version of Hugo. + +{{% note %}} +Hugo-as-a-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). Use ```sudo apt-get install hugo --classic``` to disable the default security model if you want hugo to be able to have write access in other paths besides the user’s `$HOME` directory. +{{% /note %}} + +### Arch Linux + +You can also install Hugo from the Arch Linux [community](https://www.archlinux.org/packages/community/x86_64/hugo/) repository. Applies also for derivatives such as Manjaro. + +``` +sudo pacman -Sy hugo +``` + +### Fedora + +Fedora provides a package for Hugo. The installation is done with the command : + +``` +sudo dnf install hugo +``` + +### CentOS, and Red Hat + +* <https://copr.fedorainfracloud.org/coprs/daftaupe/hugo/> + +See the [related discussion in the Hugo forums][redhatforum]. + +## 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]: http://git-scm.com/ +[installgo]: https://golang.org/dl/ +[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 +[snaps]: http://snapcraft.io/docs/core/install +[windowsarch]: https://esupport.trendmicro.com/en-us/home/pages/technical-support/1038680.aspx +[Windows Environment Variables Editor]: http://eveditor.com/ diff --git a/docs/content/en/getting-started/quick-start.md b/docs/content/en/getting-started/quick-start.md new file mode 100644 index 000000000..59a8513c8 --- /dev/null +++ b/docs/content/en/getting-started/quick-start.md @@ -0,0 +1,140 @@ +--- +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). + +You also need [Git installed](https://git-scm.com/downloads) 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 HDlKrUrbfT7yiWsbd6QoxzRTN >}} + + +## 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 1PH9A2fs14Dnyarx5v8OMYQer >}} + + +## 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;\ +git init;\ +git submodule add https://github.com/budparr/gohugo-theme-ananke.git themes/ananke;\ + +# Edit your config.toml configuration file +# and add the Ananke theme. +echo 'theme = "ananke"' >> config.toml +``` + + +{{< asciicast WJM2LEZQs8VRhNeuZ5NiGPp9I >}} + +## Step 4: Add Some Content + +``` +hugo new posts/my-first-post.md +``` + + +Edit the newly created content file if you want. Now, start the Hugo server with [drafts](/getting-started/usage/#draft-future-and-expired-content) enabled: + +``` +▶ hugo server -D + +Started building sites ... +Built site for language en: +1 of 1 draft rendered +0 future content +0 expired content +1 regular pages created +8 other pages created +0 non-page files copied +1 paginator pages created +0 categories created +0 tags created +total in 18 ms +Watching for changes in /Users/bep/sites/quickstart/{data,content,layouts,static,themes} +Serving pages from memory +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/).** + + + +## Step 5: 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. +{{% /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/).** + +## Recapitulation + +{{< asciicast pWp4uvyAkdWgQllD9RCfeBL5k >}} diff --git a/docs/content/en/getting-started/usage.md b/docs/content/en/getting-started/usage.md new file mode 100644 index 000000000..2ad2910f8 --- /dev/null +++ b/docs/content/en/getting-started/usage.md @@ -0,0 +1,230 @@ +--- +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 http://gohugo.io/. + +Usage: + hugo [flags] + hugo [command] + +Available Commands: + benchmark Benchmark Hugo by building a site a number of times. + 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. http://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/ + --canonifyURLs (deprecated) if true, all relative URLs will be canonicalized using baseURL + --cleanDestinationDir remove files from destination not found in static directories + --config string config file (default is path/config.yaml|json|toml) + -c, --contentDir string filesystem path to content directory + --debug debug output + -d, --destination string filesystem path to write files to + --disableKinds stringSlice disable different kind of pages (home, RSS etc.) + --enableGitInfo add Git revision, date and author info to the pages + --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) + --noChmod don't sync permission mode of files + --noTimes don't sync modification time of files + --pluralizeListTitles (deprecated) pluralize titles in lists using inflect (default true) + --preserveTaxonomyNames (deprecated) preserve taxonomy names as written ("Gérard Depardieu" vs "gerard-depardieu") + --quiet build in quiet mode + --renderToMemory render to memory (only useful for benchmark testing) + -s, --source string filesystem path to read files relative from + --stepAnalysis display memory and timing of different steps of the program + --templateMetrics display metrics about template executions + --templateMetricsHints calculate some improvement hints when combined with --templateMetrics + -t, --theme string theme to use (located in /themes/THEMENAME/) + --themesDir string filesystem path to themes directory + --uglyURLs (deprecated) if true, use /filename.html instead of /filename/ + -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 site Hugo renders into `public/` 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/ |