2019-10-21 04:22:28 -04:00
---
2023-07-29 05:15:54 -04:00
title: Quick start
2022-12-02 03:19:23 -05:00
description: Learn to create a Hugo site in minutes.
2019-10-21 04:22:28 -04:00
categories: [getting started]
keywords: [quick start,usage]
menu:
docs:
2022-12-02 03:19:23 -05:00
parent: getting-started
2023-07-29 05:15:54 -04:00
weight: 20
weight: 20
2019-10-21 04:22:28 -04:00
toc: true
2022-12-02 03:19:23 -05:00
aliases: [/quickstart/,/overview/quickstart/]
2019-10-21 04:22:28 -04:00
---
2022-12-02 03:19:23 -05:00
In this tutorial you will:
2019-10-21 04:22:28 -04:00
2022-12-02 03:19:23 -05:00
1. Create a site
2. Add content
3. Configure the site
4. Publish the site
2019-12-15 04:35:09 -05:00
2022-12-02 03:19:23 -05:00
## Prerequisites
2019-10-21 04:22:28 -04:00
2022-12-02 03:19:23 -05:00
Before you begin this tutorial you must:
2019-10-21 04:22:28 -04:00
2023-05-27 10:59:59 -04:00
1. [Install Hugo] (extended edition, v0.112.0 or later)
2022-12-02 03:19:23 -05:00
1. [Install Git]
2022-11-17 10:14:29 -05:00
2022-12-02 03:19:23 -05:00
You must also be comfortable working from the command line.
2019-10-21 04:22:28 -04:00
2022-12-02 03:19:23 -05:00
## Create a site
### Commands
2022-12-20 05:04:41 -05:00
{{% note %}}
2023-03-01 05:56:07 -05:00
**If you are a Windows user:**
- Do not use the Command Prompt
- Do not use Windows PowerShell
- Run these commands from [PowerShell] or a Linux terminal such as WSL or Git Bash
2023-07-29 05:15:54 -04:00
PowerShell and Windows PowerShell [are different applications].
2019-10-21 04:22:28 -04:00
2022-12-20 05:04:41 -05:00
[PowerShell]: https://learn.microsoft.com/en-us/powershell/scripting/install/installing-powershell-on-windows
2023-07-29 05:15:54 -04:00
[are different applications]: https://learn.microsoft.com/en-us/powershell/scripting/whats-new/differences-from-windows-powershell?view=powershell-7.3
2022-12-20 05:04:41 -05:00
{{% /note %}}
Run these commands to create a Hugo site with the [Ananke] theme. The next section provides an explanation of each command.
2019-10-21 04:22:28 -04:00
2022-12-02 03:19:23 -05:00
```text
hugo new site quickstart
cd quickstart
git init
2023-07-29 05:15:54 -04:00
git submodule add https://github.com/theNewDynamic/gohugo-theme-ananke.git themes/ananke
2023-05-27 10:59:59 -04:00
echo "theme = 'ananke'" >> hugo.toml
2022-12-02 03:19:23 -05:00
hugo server
2019-10-21 04:22:28 -04:00
```
2022-12-02 03:19:23 -05:00
View your site at the URL displayed in your terminal. Press `Ctrl + C` to stop Hugo's development server.
2022-11-17 10:14:29 -05:00
2022-12-02 03:19:23 -05:00
### Explanation of commands
2019-10-21 04:22:28 -04:00
2022-12-02 03:19:23 -05:00
Create the [directory structure] for your project in the `quickstart` directory.
2019-10-21 04:22:28 -04:00
2022-12-02 03:19:23 -05:00
```text
2019-10-21 04:22:28 -04:00
hugo new site quickstart
```
2022-12-02 03:19:23 -05:00
Change the current directory to the root of your project.
2019-10-21 04:22:28 -04:00
2022-12-02 03:19:23 -05:00
```text
cd quickstart
```
2019-10-21 04:22:28 -04:00
2022-12-02 03:19:23 -05:00
Initialize an empty Git repository in the current directory.
2019-10-21 04:22:28 -04:00
2022-12-02 03:19:23 -05:00
```text
git init
```
2019-10-21 04:22:28 -04:00
2022-12-02 03:19:23 -05:00
Clone the [Ananke] theme into the `themes` directory, adding it to your project as a [Git submodule].
2020-01-05 05:13:09 -05:00
2022-12-02 03:19:23 -05:00
```text
2023-07-29 05:15:54 -04:00
git submodule add https://github.com/theNewDynamic/gohugo-theme-ananke.git themes/ananke
2019-10-21 04:22:28 -04:00
```
2022-12-02 03:19:23 -05:00
Append a line to the site configuration file, indicating the current theme.
2019-10-21 04:22:28 -04:00
2022-12-02 03:19:23 -05:00
```text
2023-05-27 10:59:59 -04:00
echo "theme = 'ananke'" >> hugo.toml
2020-01-05 05:13:09 -05:00
```
2022-12-02 03:19:23 -05:00
Start Hugo's development server to view the site.
2019-10-21 04:22:28 -04:00
2022-12-02 03:19:23 -05:00
```text
hugo server
```
Press `Ctrl + C` to stop Hugo's development server.
## Add content
2019-10-21 04:22:28 -04:00
2022-12-02 03:19:23 -05:00
Add a new page to your site.
2019-10-21 04:22:28 -04:00
2022-12-02 03:19:23 -05:00
```text
2019-10-21 04:22:28 -04:00
hugo new posts/my-first-post.md
```
2022-12-02 03:19:23 -05:00
Hugo created the file in the `content/posts` directory. Open the file with your editor.
```text
---
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.
2019-10-21 04:22:28 -04:00
2022-12-02 03:19:23 -05:00
[markdown]: https://commonmark.org/help/
2019-10-21 04:22:28 -04:00
2022-12-02 03:19:23 -05:00
```text
2019-10-21 04:22:28 -04:00
---
title: "My First Post"
2022-12-02 03:19:23 -05:00
date: 2022-11-20T09:03:20-08:00
2019-10-21 04:22:28 -04:00
draft: true
---
2022-12-02 03:19:23 -05:00
## Introduction
2019-10-21 04:22:28 -04:00
2022-12-02 03:19:23 -05:00
This is **bold** text, and this is *emphasized* text.
Visit the [Hugo ](https://gohugo.io ) website!
```
Save the file, then start Hugo’ s development server to view the site. You can run either of the following commands to include draft content.
```text
hugo server --buildDrafts
hugo server -D
2019-10-21 04:22:28 -04:00
```
2022-12-02 03:19:23 -05:00
View your site at the URL displayed in your terminal. Keep the development server running as you continue to add and change content.
2020-09-07 15:37:51 -04:00
{{% note %}}
2022-12-02 03:19:23 -05:00
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.
[live testing tool]: https://spec.commonmark.org/dingus/
[specification]: https://spec.commonmark.org/
2020-09-07 15:37:51 -04:00
{{% /note %}}
2022-12-02 03:19:23 -05:00
## Configure the site
2019-10-21 04:22:28 -04:00
2023-05-27 10:59:59 -04:00
With your editor, open the [site configuration] file (`hugo.toml`) in the root of your project.
2019-10-21 04:22:28 -04:00
2022-12-02 03:19:23 -05:00
```text
baseURL = 'http://example.org/'
languageCode = 'en-us'
title = 'My New Hugo Site'
theme = 'ananke'
```
2019-10-21 04:22:28 -04:00
2022-12-02 03:19:23 -05:00
Make the following changes:
2019-10-21 04:22:28 -04:00
2022-12-02 03:19:23 -05:00
1. Set the `baseURL` for your production site. This value must begin with the protocol and end with a slash, as shown above.
2019-10-21 04:22:28 -04:00
2022-12-02 03:19:23 -05:00
2. Set the `languageCode` to your language and region.
2019-10-21 04:22:28 -04:00
2022-12-02 03:19:23 -05:00
3. Set the `title` for your production site.
2019-10-21 04:22:28 -04:00
2022-12-02 03:19:23 -05:00
Start Hugo's development server to see your changes, remembering to include draft content.
2019-10-21 04:22:28 -04:00
2022-12-02 03:19:23 -05:00
```text
hugo server -D
```
2019-10-21 04:22:28 -04:00
{{% note %}}
2022-12-02 03:19:23 -05:00
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].
[demonstration site]: https://gohugo-ananke-theme-demo.netlify.app/
[documentation]: https://github.com/theNewDynamic/gohugo-theme-ananke#readme
[The New Dynamic]: https://www.thenewdynamic.com/
2019-10-21 04:22:28 -04:00
{{% /note %}}
2022-12-02 03:19:23 -05:00
## Publish the site
2019-10-21 04:22:28 -04:00
2022-12-02 03:19:23 -05:00
In this step you will _publish_ your site, but you will not _deploy_ it.
2019-10-21 04:22:28 -04:00
2022-12-02 03:19:23 -05:00
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.
2019-10-21 04:22:28 -04:00
2022-12-02 03:19:23 -05:00
When you publish your site, you typically do _not_ want to include [draft, future, or expired content]. The command is simple.
2019-10-21 04:22:28 -04:00
2022-12-02 03:19:23 -05:00
```text
hugo
2019-10-21 04:22:28 -04:00
```
2022-12-02 03:19:23 -05:00
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 ](/getting-started/external-learning-resources/ ) page.
[Ananke]: https://github.com/theNewDynamic/gohugo-theme-ananke
[directory structure]: /getting-started/directory-structure
[draft, future, and expired content]: /getting-started/usage/#draft-future-and-expired-content
[draft, future, or expired content]: /getting-started/usage/#draft-future-and-expired-content
[external learning resources]:/getting-started/external-learning-resources/
[forum]: https://discourse.gohugo.io/
[forum]: https://discourse.gohugo.io/
[front matter]: /content-management/front-matter
[Git submodule]: https://git-scm.com/book/en/v2/Git-Tools-Submodules
[hosting and deployment]: /hosting-and-deployment/
[Install Git]: https://git-scm.com/book/en/v2/Getting-Started-Installing-Git
[Install Hugo]: /installation/
[Requesting Help]: https://discourse.gohugo.io/t/requesting-help/9132
[Requesting Help]: https://discourse.gohugo.io/t/requesting-help/9132
[site configuration]: /getting-started/configuration/