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