You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/content/documentation/getting-started/installation.md
+6-6Lines changed: 6 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -175,7 +175,7 @@ jobs:
175
175
steps:
176
176
- uses: taiki-e/install-action@v2
177
177
with:
178
-
tool: zola@0.17.1
178
+
tool: zola@0.19.1
179
179
# ...
180
180
```
181
181
@@ -187,34 +187,34 @@ Zola is available on [the GitHub registry](https://github.com/getzola/zola/pkgs/
187
187
It has no `latest` tag, you will need to specify a [specific version to pull](https://github.com/getzola/zola/pkgs/container/zola/versions).
Copy file name to clipboardExpand all lines: docs/content/documentation/getting-started/overview.md
+86-76Lines changed: 86 additions & 76 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,11 +19,11 @@ Unlike some SSGs, Zola makes no assumptions regarding the structure of your site
19
19
20
20
### Initialize Site
21
21
22
-
> This overview is based on Zola 0.17.1.
22
+
> This overview is based on Zola 0.19.1.
23
23
24
24
Please see the detailed [installation instructions for your platform](@/documentation/getting-started/installation.md). With Zola installed, let's initialize our site:
25
25
26
-
```bash
26
+
```
27
27
$ zola init myblog
28
28
```
29
29
@@ -38,7 +38,7 @@ You will be asked a few questions.
38
38
39
39
For our blog, let's accept the default values (i.e., press Enter for each question). We now have a `myblog` directory with the following structure:
40
40
41
-
```bash
41
+
```
42
42
├── config.toml
43
43
├── content
44
44
├── sass
@@ -66,28 +66,15 @@ For reference, by the **end** of this overview, our `myblog` directory will have
66
66
└── themes/
67
67
```
68
68
69
-
Let's start the Zola development server within the newlycreated `myblog` directory:
69
+
Change directory into the newly-created `myblog` directory.
70
70
71
-
```bash
72
-
$ cd myblog
73
-
$ zola serve
74
-
Building site...
75
-
Checking all internal links with anchors.
76
-
> Successfully checked 0 internal link(s) with anchors.
If you point your web browser to <http://127.0.0.1:1111>, you should see a "Welcome to Zola" message.
73
+
We'll first create some templates to describe the structure of our site.
87
74
88
-
### Home Page
75
+
####Home Page Template
89
76
90
-
Let's make a home page. To do this, let's first create a `base.html`file inside the `templates` directory. This step will make more sense as we move through this overview.
77
+
Let's make a template for a home page. Create `templates/base.html`with the following content. This step will make more sense as we move through this overview.
91
78
92
79
```html
93
80
<!DOCTYPE html>
@@ -109,7 +96,7 @@ Let's make a home page. To do this, let's first create a `base.html` file inside
109
96
</html>
110
97
```
111
98
112
-
Now, let's create an `index.html` file inside the `templates` directory.
99
+
Now, let's create `templates/index.html`with the following content.
113
100
114
101
```html
115
102
{% extends "base.html" %}
@@ -123,38 +110,9 @@ Now, let's create an `index.html` file inside the `templates` directory.
123
110
124
111
This tells Zola that `index.html` extends our `base.html` file and replaces the block called "content" with the text between the `{% block content %}` and `{% endblock content %}` tags.
125
112
126
-
### Content Directory
127
-
128
-
Now let's add some content. We'll start by making a `blog` subdirectory in the `content` directory and creating an `_index.md` file inside it. This file tells Zola that `blog` is a [section](@/documentation/content/section.md), which is how content is categorized in Zola.
129
-
130
-
```bash
131
-
├── content
132
-
│ └── blog
133
-
│ └── _index.md
134
-
```
113
+
#### Blog Template
135
114
136
-
In the `_index.md` file, we'll set the following variables in [TOML](https://github.com/toml-lang/toml) format:
137
-
138
-
```md
139
-
+++
140
-
title = "List of blog posts"
141
-
sort_by = "date"
142
-
template = "blog.html"
143
-
page_template = "blog-page.html"
144
-
+++
145
-
```
146
-
147
-
> Note that although no variables are mandatory, the opening and closing `+++` are required.
148
-
149
-
**sort_by = "date"* tells Zola to use the date to order our section pages (more on pages below).
150
-
**template = "blog.html"* tells Zola to use `blog.html`in the `templates` directory as the template forlisting the Markdown filesin this section.
151
-
**page_template = "blog-page.html"* tells Zola to use `blog-page.html`in the `templates` directory as the template for individual Markdown files.
152
-
153
-
For a full list of section variables, please see the [section](@/documentation/content/section.md) documentation. We will use *title = "List of blog posts"*in a template (see below).
154
-
155
-
### Templates
156
-
157
-
Let's now create some more templates. In the `templates` directory, create a `blog.html` file with the following contents:
115
+
To create a template for a page that lists all blog posts, create `templates/blog.html` with the following content.
158
116
159
117
```html
160
118
{% extends "base.html" %}
@@ -164,34 +122,20 @@ Let's now create some more templates. In the `templates` directory, create a `bl
164
122
{{ section.title }}
165
123
</h1>
166
124
<ul>
167
-
<!-- If you are using pagination, section.pages will be empty. You need to use the paginator object -->
125
+
<!-- If you are using pagination, section.pages will be empty.
As done by `index.html`, `blog.html` extends `base.html`, but this time we want to list the blog posts. The *title* we set in the `_index.md` file above is available to us as `{{ section.title }}`. In the list below the title, we loop through all the pages in our section (`blog` directory) and output the page title and URL using `{{ page.title }}` and `{{ page.permalink | safe }}`, respectively. We use the `| safe` filter because the permalink doesn't need to be HTML escaped (escaping would cause `/` to render as `/`).
176
-
177
-
If you go to <http://127.0.0.1:1111/blog/>, you will see the section page for`blog`. The list is empty because we don't have any blog posts. Let's fix that now.
134
+
As done by `index.html`, `blog.html` extends `base.html`, but in this template we want to list the blog posts. Here we also see expressions such as `{{ section.[...] }}` and `{{ page.[...] }}` which will be replaced with values from our [content](#content) when zola combines content with this template to render a page. In the list below the header, we loop through all the pages in our section (`blog` directory; more on this when we create content) and output each page title and URL using `{{ page.title }}` and `{{ page.permalink | safe }}`, respectively. We use the `| safe` filter because the permalink doesn't need to be HTML escaped (escaping would cause `/` to render as `/`).
178
135
179
-
### Markdown Content
136
+
#### Blog Post Template
180
137
181
-
In the `blog` directory, create a file called `first.md` with the following contents:
182
-
183
-
```md
184
-
+++
185
-
title = "My first post"
186
-
date = 2019-11-27
187
-
+++
188
-
189
-
This is my first blog post.
190
-
```
191
-
192
-
The *title* and *date* will be available to us in the `blog-page.html` template as `{{ page.title }}` and `{{ page.date }}`, respectively. All text below the closing `+++` will be available to us as `{{ page.content }}`.
193
-
194
-
We now need to make the `blog-page.html` template. In the `templates` directory, create this file with the contents:
138
+
We have templates describing our home page and a page that lists all blog posts. Let's now create a template for an individual blog post. Create `templates/blog-page.html` with the following content.
195
139
196
140
```html
197
141
{% extends "base.html" %}
@@ -207,7 +151,73 @@ We now need to make the `blog-page.html` template. In the `templates` directory,
207
151
208
152
> Note the `| safe` filter for `{{ page.content }}`.
209
153
210
-
This should start to look familiar. If you now go back to our blog list page at <http://127.0.0.1:1111/blog/>, you should see our lonely post. Let's add another. In the `content/blog` directory, let's create the file `second.md` with the contents:
154
+
### Zola Live Reloading
155
+
156
+
Now that we've outlined our site's structure, let's start the Zola development server in the `myblog` directory.
157
+
158
+
```
159
+
$ zola serve
160
+
Building site...
161
+
Checking all internal links with anchors.
162
+
> Successfully checked 0 internal link(s) with anchors.
163
+
-> Creating 0 pages (0 orphan) and 0 sections
164
+
Done in 13ms.
165
+
166
+
Web server is available at http://127.0.0.1:1111
167
+
168
+
Listening for changes in .../myblog/{config.toml,content,sass,static,templates}
169
+
Press Ctrl+C to stop
170
+
```
171
+
172
+
If you point your web browser to <http://127.0.0.1:1111>, you will see a message saying, "This is my blog made with Zola."
173
+
174
+
If you go to <http://127.0.0.1:1111/blog/>, you will currently get a 404 which we will fix next.
175
+
176
+
### Content
177
+
178
+
We'll now create some content that Zola will use to generate site pages based on our templates.
179
+
180
+
#### Sections
181
+
182
+
We'll start by creating `content/blog/_index.md`. This file tells Zola that `blog` is a [section](@/documentation/content/section.md), which is how content is categorized in Zola. In the `_index.md` file, we'll set the following variables in [TOML](https://github.com/toml-lang/toml) format:
183
+
184
+
```md
185
+
+++
186
+
title = "List of blog posts"
187
+
sort_by = "date"
188
+
template = "blog.html"
189
+
page_template = "blog-page.html"
190
+
+++
191
+
```
192
+
193
+
> Note that although no variables are mandatory, the opening and closing `+++` are required.
194
+
195
+
**sort_by = "date"* tells Zola to use the date to order our section pages (more on pages below).
196
+
**template = "blog.html"* tells Zola to use `templates/blog.html` as the template for listing the Markdown files in this section.
197
+
**page_template = "blog-page.html"* tells Zola to use `templates/blog-page.html` as the template for individual Markdown files.
198
+
199
+
For a full list of section variables, please see the [section](@/documentation/content/section.md) documentation.
200
+
201
+
The value of our `title` variable here is available to templates such as `blog.html` as `{{ section.title }}`.
202
+
203
+
If you now go to <http://127.0.0.1:1111/blog/>, you will see an empty list of posts.
204
+
205
+
#### Markdown
206
+
207
+
We'll now create some blog posts. Create `content/blog/first.md` with the following content.
208
+
209
+
```md
210
+
+++
211
+
title = "My first post"
212
+
date = 2019-11-27
213
+
+++
214
+
215
+
This is my first blog post.
216
+
```
217
+
218
+
The *title* and *date* will be available to us in the `blog-page.html` template as `{{ page.title }}` and `{{ page.date }}`, respectively. All text below the closing `+++` will be available to templates as `{{ page.content }}`.
219
+
220
+
If you now go back to our blog list page at <http://127.0.0.1:1111/blog/>, you should see our lonely post. Let's add another. Create `content/blog/second.md` with the contents:
211
221
212
222
```md
213
223
+++
@@ -218,9 +228,9 @@ date = 2019-11-28
218
228
This is my second blog post.
219
229
```
220
230
221
-
Back at <http://127.0.0.1:1111/blog/>, our second post shows up on top of the list because it's newer than the first post and we had set *sort_by = "date"* in our `_index.md` file. As a final step, let's modify our home page to link to our blog posts.
231
+
Back at <http://127.0.0.1:1111/blog/>, our second post shows up on top of the list because it's newer than the first post and we had set *sort_by = "date"* in our `_index.md` file.
222
232
223
-
The `index.html`file inside the `templates` directory should be:
233
+
As a final step, let's modify `templates/index.html`(our home page) to link to our list of blog posts:
224
234
225
235
```html
226
236
{% extends "base.html" %}
@@ -229,7 +239,7 @@ The `index.html` file inside the `templates` directory should be:
229
239
<h1class="title">
230
240
This is my blog made with Zola.
231
241
</h1>
232
-
<p>Click <a href="{{/* get_url(path='@/blog/_index.md') */}}">here</a> to see my posts.</p>
0 commit comments