hugo/content/en/getting-started/quick-start.md
Bjørn Erik Pedersen 41bc6f702a Squashed 'docs/' changes from 2201ac0e5..2c0125b52
2c0125b52 Remove .Site.Author
2cf8841b3 Update partialCached.md (#1924)
385487191 Update data-templates.md (#1926)
ce207e141 Remove redundant markdown and fix a few typos (#1936)
3687c2953 Make heading id linkable, take 2
45c79bea7 Make heading id linkable
b22079344 Delete duplicates the lines 557-569 and 570-582. (#1934)
0a90dc122 Rework the taxonomy variables page (#1935)
7f8979c50 Update theme
26e682a3a Update multilingual.md
d40e7693f Update postcss.md
375d75c01 Update postcss npm instructions (#1931)
63020094a Emphasize Window shell selection (#1930)
56824be2c Update configuration.md
b7b8f16b3 Docu 'Theme components': minor fix (#1929)
09dc81a05 Remove Docker from BSD page (#1927)
205fea204 netlify: Hugo 0.108.0
6abe49c28 Merge commit 'da670c38ee63a7fef25e2b9f42519232055b60dc'
12b59a4c5 docs: Add basic doc for wrapStandAloneImageWithinParagraph etc.
ba07bd970 dartsass: Add sourceMapIncludeSources option

git-subtree-dir: docs
git-subtree-split: 2c0125b5290494d49334606c451446ebd9df3c21
2022-12-20 11:04:41 +01:00

6.5 KiB
Raw Blame History

title linktitle description categories keywords menu weight toc aliases
Quick Start Quick Start Learn to create a Hugo site in minutes.
getting started
quick start
usage
docs
parent weight
getting-started 10
10 true
/quickstart/
/overview/quickstart/

In this tutorial you will:

  1. Create a site
  2. Add content
  3. Configure the site
  4. Publish the site

Prerequisites

Before you begin this tutorial you must:

  1. Install Hugo (the extended edition)
  2. Install Git

You must also be comfortable working from the command line.

Create a site

Commands

{{% note %}} If you are a Windows user, you must run these commands with PowerShell. You cannot use Windows Powershell, which is a different application, or the Command Prompt. You may also use a Linux shell if available.

{{% /note %}}

Run these commands to create a Hugo site with the Ananke theme. The next section provides an explanation of each command.

hugo new site quickstart
cd quickstart
git init
git submodule add https://github.com/theNewDynamic/gohugo-theme-ananke themes/ananke
echo "theme = 'ananke'" >> config.toml
hugo server

View your site at the URL displayed in your terminal. Press Ctrl + C to stop Hugo's development server.

Explanation of commands

Create the directory structure for your project in the quickstart directory.

hugo new site quickstart

Change the current directory to the root of your project.

cd quickstart

Initialize an empty Git repository in the current directory.

git init

Clone the Ananke theme into the themes directory, adding it to your project as a Git submodule.

git submodule add https://github.com/theNewDynamic/gohugo-theme-ananke themes/ananke

Append a line to the site configuration file, indicating the current theme.

echo "theme = 'ananke'" >> config.toml

Start Hugo's development server to view the site.

hugo server

Press Ctrl + C to stop Hugo's development server.

Add content

Add a new page to your site.

hugo new posts/my-first-post.md

Hugo created the file in the content/posts directory. Open the file with your editor.

---
title: "My First Post"
date: 2022-11-20T09:03:20-08:00
draft: true
---

Notice the draft value in the front matter is true. By default, Hugo does not publish draft content when you build the site. Learn more about draft, future, and expired content.

Add some markdown to the body of the post, but do not change the draft value.

---
title: "My First Post"
date: 2022-11-20T09:03:20-08:00
draft: true
---
## Introduction

This is **bold** text, and this is *emphasized* text.

Visit the [Hugo](https://gohugo.io) website!

Save the file, then start Hugos development server to view the site. You can run either of the following commands to include draft content.

hugo server --buildDrafts
hugo server -D

View your site at the URL displayed in your terminal. Keep the development server running as you continue to add and change content.

{{% note %}} Hugo's rendering engine conforms to the CommonMark specification for markdown. The CommonMark organization provides a useful live testing tool powered by the reference implementation.

{{% /note %}}

Configure the site

With your editor, open the site configuration file (config.toml) in the root of your project.

baseURL = 'http://example.org/'
languageCode = 'en-us'
title = 'My New Hugo Site'
theme = 'ananke'

Make the following changes:

  1. Set the baseURL for your production site. This value must begin with the protocol and end with a slash, as shown above.

  2. Set the languageCode to your language and region.

  3. Set the title for your production site.

Start Hugo's development server to see your changes, remembering to include draft content.

hugo server -D

{{% note %}} Most theme authors provide configuration guidelines and options. Make sure to visit your theme's repository or documentation site for details.

The New Dynamic, authors of the Ananke theme, provide documentation for configuration and usage. They also provide a demonstration site.

{{% /note %}}

Publish the site

In this step you will publish your site, but you will not deploy it.

When you publish your site, Hugo creates the entire static site in the public directory in the root of your project. This includes the HTML files, and assets such as images, CSS files, and JavaScript files.

When you publish your site, you typically do not want to include draft, future, or expired content. The command is simple.

hugo

To learn how to deploy your site, see the hosting and deployment section.

Ask for help

Hugo's forum is an active community of users and developers who answer questions, share knowledge, and provide examples. A quick search of over 20,000 topics will often answer your question. Please be sure to read about requesting help before asking your first question.

Other resources

For other resources to help you learn Hugo, including books and video tutorials, see the external learning resources page.