Debian Codegraph @

docs/content/en/getting-started/quick-start.md

raw
1 ---
2 title: Quick start
3 description: Create your first Hugo project.
4 categories: []
5 keywords: []
6 params:
7 minVersion: v0.158.0
8 weight: 10
9 aliases: [/quickstart/,/overview/quickstart/]
10 ---
11
12 In this tutorial you will:
13
14 1. Create a project
15 1. Add content
16 1. Configure the project
17 1. Publish the project
18
19 ## Prerequisites
20
21 Before you begin this tutorial you must:
22
23 1. [Install Hugo][] (any edition, {{% param "minVersion" %}} or later)
24 1. [Install Git][]
25
26 You must also be comfortable working from the command line.
27
28 ## Create a project
29
30 Use these commands to create a new Hugo project.
31
32 ### Commands
33
34 > [!NOTE]
35 > **If you are a Windows user:**
36 >
37 > - Do not use the Command Prompt
38 > - Do not use Windows PowerShell
39 > - Run these commands from [PowerShell][] or a Linux terminal such as WSL or Git > Bash
40 >
41 > PowerShell and Windows PowerShell [are different applications][].
42
43 Verify that you have installed Hugo {{% param "minVersion" %}} or later.
44
45 ```sh
46 hugo version
47 ```
48
49 Run these commands to create a Hugo project with the [Ananke][] theme. The next section provides an explanation of each command.
50
51 ```sh
52 hugo new project quickstart
53 cd quickstart
54 git init
55 git submodule add https://github.com/gohugo-ananke/ananke themes/ananke
56 echo "theme = 'ananke'" >> hugo.toml
57 hugo server
58 ```
59
60 View your project at the URL displayed in your terminal. Press `Ctrl + C` to stop Hugo's development server.
61
62 ### Explanation of commands
63
64 Create the [project skeleton][] for your project in the `quickstart` directory.
65
66 ```sh
67 hugo new project quickstart
68 ```
69
70 Change the current directory to the root of your project.
71
72 ```sh
73 cd quickstart
74 ```
75
76 Initialize an empty Git repository in the current directory.
77
78 ```sh
79 git init
80 ```
81
82 Clone the [Ananke][] theme into the `themes` directory, adding it to your project as a [Git submodule][].
83
84 ```sh
85 git submodule add https://github.com/gohugo-ananke/ananke themes/ananke
86 ```
87
88 Append a line to your project configuration file, indicating the current theme.
89
90 ```sh
91 echo "theme = 'ananke'" >> hugo.toml
92 ```
93
94 Start Hugo's development server.
95
96 ```sh
97 hugo server
98 ```
99
100 Press `Ctrl + C` to stop Hugo's development server.
101
102 ## Add content
103
104 Add a new page to your project.
105
106 ```sh
107 hugo new content content/posts/my-first-post.md
108 ```
109
110 Hugo created the file in the `content/posts` directory. Open the file with your editor.
111
112 ```md
113 +++
114 title = 'My First Post'
115 date = 2024-01-14T07:07:07+01:00
116 draft = true
117 +++
118 ```
119
120 Notice the `draft` value in the [front matter][] is `true`. By default, Hugo does not publish draft content when you build the project. Learn more about [draft, future, and expired content][].
121
122 Add some [Markdown][] to the body of the post, but do not change the `draft` value.
123
124 ```md
125 +++
126 title = 'My First Post'
127 date = 2024-01-14T07:07:07+01:00
128 draft = true
129 +++
130 ## Introduction
131
132 This is **bold** text, and this is *emphasized* text.
133
134 Visit the [Hugo](https://gohugo.io) website!
135 ```
136
137 Save the file, then start Hugo's development server. You can run either of the following commands to include draft content.
138
139 ```sh
140 hugo server --buildDrafts
141 hugo server -D
142 ```
143
144 View your project at the URL displayed in your terminal. Keep the development server running as you continue to add and change content.
145
146 When satisfied with your new content, set the front matter `draft` parameter to `false`.
147
148 > [!NOTE]
149 > 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.
150
151 ## Configure the project
152
153 With your editor, open the [project configuration][] file in the root of your project directory:
154
155 ```toml {file="hugo.toml"}
156 baseURL = 'https://example.org/'
157 locale = 'en-us'
158 title = 'My New Hugo Project'
159 theme = 'ananke'
160 ```
161
162 Make the following changes:
163
164 1. Set the `baseURL` for your project. This value must begin with the protocol and end with a slash, as shown above.
165 1. Set the `locale` to your locale.
166 1. Set the `title` for your project.
167
168 Start Hugo's development server to see your changes, remembering to include draft content.
169
170 ```sh
171 hugo server -D
172 ```
173
174 > [!NOTE]
175 > Now that you have the Ananke theme installed, check out their [documentation][] and [demonstration site][] to learn how to configure and customize it.
176
177 ## Publish the project
178
179 In this step you will _publish_ your project, but you will not _deploy_ it.
180
181 When you publish your project, Hugo renders all build artifacts to the `public` directory in the root of your project. This includes the HTML files for every site, along with assets such as images, CSS, and JavaScript. The command is simple.
182
183 ```sh
184 hugo
185 ```
186
187 To learn how to _deploy_ your project, see the [host and deploy][] section.
188
189 ## Ask for help
190
191 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.
192
193 ## Other resources
194
195 For other resources to help you learn Hugo, including books and video tutorials, see the [external learning resources][] page.
196
197 [Ananke]: https://github.com/theNewDynamic/gohugo-theme-ananke
198 [Git submodule]: https://git-scm.com/book/en/v2/Git-Tools-Submodules
199 [Install Git]: https://git-scm.com/book/en/v2/Getting-Started-Installing-Git
200 [Install Hugo]: /installation/
201 [Markdown]: https://daringfireball.net/projects/markdown
202 [PowerShell]: https://learn.microsoft.com/en-us/powershell/scripting/install/installing-powershell-on-windows
203 [are different applications]: https://learn.microsoft.com/en-us/powershell/scripting/whats-new/differences-from-windows-powershell?view=powershell-7.3
204 [demonstration site]: https://ananke-theme.netlify.app/
205 [documentation]: https://ananke-documentation.netlify.app/
206 [draft, future, and expired content]: /getting-started/usage/#draft-future-and-expired-content
207 [external learning resources]: /getting-started/external-learning-resources/
208 [forum]: https://discourse.gohugo.io/
209 [front matter]: /content-management/front-matter/
210 [host and deploy]: /host-and-deploy/
211 [live testing tool]: https://spec.commonmark.org/dingus/
212 [project configuration]: /configuration/
213 [project skeleton]: /getting-started/directory-structure/#project-skeleton
214 [requesting help]: https://discourse.gohugo.io/t/requesting-help/9132
215 [specification]: https://spec.commonmark.org/