Skip to content

Commit 5a720cb

Browse files
committed
docs: fix order of events in zola overview (templates, server, content)
1 parent c20b336 commit 5a720cb

File tree

2 files changed

+92
-82
lines changed

2 files changed

+92
-82
lines changed

docs/content/documentation/getting-started/installation.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ jobs:
175175
steps:
176176
- uses: taiki-e/install-action@v2
177177
with:
178-
tool: zola@0.17.1
178+
tool: zola@0.19.1
179179
# ...
180180
```
181181

@@ -187,34 +187,34 @@ Zola is available on [the GitHub registry](https://github.com/getzola/zola/pkgs/
187187
It has no `latest` tag, you will need to specify a [specific version to pull](https://github.com/getzola/zola/pkgs/container/zola/versions).
188188

189189
```sh
190-
$ docker pull ghcr.io/getzola/zola:v0.17.1
190+
$ docker pull ghcr.io/getzola/zola:v0.19.1
191191
```
192192

193193
#### Build
194194

195195
```sh
196-
$ docker run -u "$(id -u):$(id -g)" -v $PWD:/app --workdir /app ghcr.io/getzola/zola:v0.17.1 build
196+
$ docker run -u "$(id -u):$(id -g)" -v $PWD:/app --workdir /app ghcr.io/getzola/zola:v0.19.1 build
197197
```
198198

199199
#### Serve
200200

201201
```sh
202-
$ docker run -u "$(id -u):$(id -g)" -v $PWD:/app --workdir /app -p 8080:8080 ghcr.io/getzola/zola:v0.17.1 serve --interface 0.0.0.0 --port 8080 --base-url localhost
202+
$ docker run -u "$(id -u):$(id -g)" -v $PWD:/app --workdir /app -p 8080:8080 ghcr.io/getzola/zola:v0.19.1 serve --interface 0.0.0.0 --port 8080 --base-url localhost
203203
```
204204

205205
You can now browse http://localhost:8080.
206206

207207
> To enable live browser reload, you may have to bind to port 1024. Zola searches for an open
208208
> port between 1024 and 9000 for live reload. The new docker command would be
209-
> `$ docker run -u "$(id -u):$(id -g)" -v $PWD:/app --workdir /app -p 8080:8080 -p 1024:1024 ghcr.io/getzola/zola:v0.17.1 serve --interface 0.0.0.0 --port 8080 --base-url localhost`
209+
> `$ docker run -u "$(id -u):$(id -g)" -v $PWD:/app --workdir /app -p 8080:8080 -p 1024:1024 ghcr.io/getzola/zola:v0.19.1 serve --interface 0.0.0.0 --port 8080 --base-url localhost`
210210
211211
#### Multi-stage build
212212

213213
Since there is no shell in the Zola docker image, if you want to use it from inside a Dockerfile, you have to use the
214214
exec form of `RUN`, like:
215215

216216
```Dockerfile
217-
FROM ghcr.io/getzola/zola:v0.17.1 as zola
217+
FROM ghcr.io/getzola/zola:v0.19.1 as zola
218218

219219
COPY . /project
220220
WORKDIR /project

docs/content/documentation/getting-started/overview.md

Lines changed: 86 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ Unlike some SSGs, Zola makes no assumptions regarding the structure of your site
1919

2020
### Initialize Site
2121

22-
> This overview is based on Zola 0.17.1.
22+
> This overview is based on Zola 0.19.1.
2323
2424
Please see the detailed [installation instructions for your platform](@/documentation/getting-started/installation.md). With Zola installed, let's initialize our site:
2525

26-
```bash
26+
```
2727
$ zola init myblog
2828
```
2929

@@ -38,7 +38,7 @@ You will be asked a few questions.
3838

3939
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:
4040

41-
```bash
41+
```
4242
├── config.toml
4343
├── content
4444
├── sass
@@ -66,28 +66,15 @@ For reference, by the **end** of this overview, our `myblog` directory will have
6666
└── themes/
6767
```
6868

69-
Let's start the Zola development server within the newly created `myblog` directory:
69+
Change directory into the newly-created `myblog` directory.
7070

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.
77-
-> Creating 0 pages (0 orphan) and 0 sections
78-
Done in 13ms.
79-
80-
Listening for changes in .../myblog/{config.toml,content,sass,static,templates}
81-
Press Ctrl+C to stop
82-
83-
Web server is available at http://127.0.0.1:1111
84-
```
71+
### Templates
8572

86-
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.
8774

88-
### Home Page
75+
#### Home Page Template
8976

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.
9178

9279
```html
9380
<!DOCTYPE html>
@@ -109,7 +96,7 @@ Let's make a home page. To do this, let's first create a `base.html` file inside
10996
</html>
11097
```
11198

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.
113100

114101
```html
115102
{% extends "base.html" %}
@@ -123,38 +110,9 @@ Now, let's create an `index.html` file inside the `templates` directory.
123110

124111
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.
125112

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
135114

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 for listing the Markdown files in 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.
158116

159117
```html
160118
{% extends "base.html" %}
@@ -164,34 +122,20 @@ Let's now create some more templates. In the `templates` directory, create a `bl
164122
{{ section.title }}
165123
</h1>
166124
<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.
126+
You need to use the paginator object -->
168127
{% for page in section.pages %}
169128
<li><a href="{{ page.permalink | safe }}">{{ page.title }}</a></li>
170129
{% endfor %}
171130
</ul>
172131
{% endblock content %}
173132
```
174133

175-
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 `&#x2F;`).
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 `&#x2F;`).
178135

179-
### Markdown Content
136+
#### Blog Post Template
180137

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.
195139

196140
```html
197141
{% extends "base.html" %}
@@ -207,7 +151,73 @@ We now need to make the `blog-page.html` template. In the `templates` directory,
207151

208152
> Note the `| safe` filter for `{{ page.content }}`.
209153
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:
211221

212222
```md
213223
+++
@@ -218,9 +228,9 @@ date = 2019-11-28
218228
This is my second blog post.
219229
```
220230

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.
222232

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:
224234

225235
```html
226236
{% extends "base.html" %}
@@ -229,7 +239,7 @@ The `index.html` file inside the `templates` directory should be:
229239
<h1 class="title">
230240
This is my blog made with Zola.
231241
</h1>
232-
<p>Click <a href="{{/* get_url(path='@/blog/_index.md') */}}">here</a> to see my posts.</p>
242+
<p><a href="{{/* get_url(path='@/blog/_index.md') */}}">Posts</a>.</p>
233243
{% endblock content %}
234244
```
235245

0 commit comments

Comments
 (0)