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
*[jinja2](/jinja2.html), a Python [template engine](/template-engines.html),
40
+
*[Jinja2](/jinja2.html), a Python [template engine](/template-engines.html),
41
41
version [2.9.6](https://github.com/pallets/jinja/releases/tag/2.9.6)
42
42
*[pip](https://pip.pypa.io/en/stable/) and
43
43
[virtualenv](https://virtualenv.pypa.io/en/latest/), which come
@@ -56,25 +56,36 @@ Use and abuse the source code as you like for your own applications.
56
56
57
57
58
58
## Install the Pelican and Markdown libraries
59
-
Start by creating a new virtual environment for your project.
59
+
Start by creating a new virtual environment for your project. My virtualenv
60
+
is named `staticsite` with the following command but you can name yours
61
+
whatever matches the project you are creating.
60
62
61
63
```bash
62
-
python3 -m venv
64
+
python3 -m venv staticsite
63
65
```
64
-
66
+
67
+
Activate the virtualenv.
68
+
69
+
```
70
+
source staticsite/bin/activate
71
+
```
72
+
73
+
When activated the virtualenv should prepend its name to your command prompt,
74
+
as shown in the following screenshot of my terminal.
75
+
65
76
<imgsrc="/img/170605-static-sites-pelican/activate-virtualenv.png"width="100%"class="technical-diagram img-rounded"style="border:1pxsolid#ccc"alt="Create and activate the Python virtual environment.">
66
77
67
78
Install the appropriate dependencies after your virtualenv is activated.
68
-
The text `(staticsite)` should be prepended to your command prompt. Install
69
-
the Pelican and Markdown Python libraries. Jinja2 will also be installed
70
-
because Pelican specifies it as a dependency.
79
+
Use the `pip` command to install Pelican and Markdown, which will also
80
+
install Jinja2 because Pelican specifies it as a dependency.
81
+
71
82
72
83
```bash
73
84
pip install pelican==3.7.1 markdown==2.6.8
74
85
```
75
86
76
-
Run the command and after everything is installed you should see output
77
-
similar to the following "Sucessfully installed" message.
87
+
Run the `pip`command and after everything is installed you should see output
88
+
similar to the following "Successfully installed" message.
artists as examples, but of course your site can contain whatever subjects
96
107
that you want.
97
108
109
+
Create a new directory for our static site project and change into the
110
+
directory.
111
+
112
+
```
113
+
mkdir retrosynth
114
+
cd retrosynth
115
+
```
116
+
117
+
Run the `pelican-quickstart` command within the new project directory.
118
+
98
119
```bash
99
120
(staticsite) $ pelican-quickstart
100
121
```
101
122
123
+
The quickstart script will rattle off a bunch of questions. Follow
124
+
along with the answers below or modify them for your own site name and
125
+
desired configuration.
126
+
102
127
```bash
103
-
(staticsite) $ pelican-quickstart
104
128
Welcome to pelican-quickstart v3.7.1.
105
129
106
130
This script will help you create a new Pelican-based website.
@@ -129,10 +153,54 @@ Done. Your new project is available at /Users/matt/devel/py/retrosynth
129
153
(staticsite) $
130
154
```
131
155
132
-
What did we just create using the Pelican quickstart script?
156
+
What did we just create using the Pelican quickstart script? Check out
157
+
the new files in the directory.
158
+
159
+
```bash
160
+
(staticsite) $ ls
161
+
Makefile develop_server.sh pelicanconf.py
162
+
content fabfile.py publishconf.py
163
+
```
164
+
165
+
The quickstart created five files and one new directory:
166
+
167
+
*`Makefile`: Make convenience tasks for common operations such as running a
168
+
development server, building a site and cleaning extraneous build files
169
+
*`develop_server.sh`
170
+
*`pelicanconf.py`
171
+
*`fabfile.py`
172
+
*`publishconf.py`
173
+
*`content`: location for your markup files, which should be stored under
174
+
`pages` and `posts` directories
175
+
176
+
We can use these files as the base for our new static site. Let's see what
177
+
it looks like by default by running it via the `devserver` task in the
178
+
Makefile.
179
+
180
+
```bash
181
+
make devserver
182
+
```
183
+
184
+
The Pelican development server will start serving up your site with a
185
+
daeman process. Go to [localhost:8000](http://localhost:8000) in your web
186
+
browser and you will see the first version of your static site.
187
+
188
+
<imgsrc="/img/170605-static-sites-pelican/default-style.png"width="100%"class="technical-diagram img-rounded"style="border:1pxsolid#ccc"alt="Default styling on the Pelican static site.">
189
+
190
+
It is up to you whether you want to use the development server or not
191
+
while creating your site. Every time I want to view my changes for
192
+
Full Stack Python I actually regenerate the site using my own Makefile that
193
+
wraps the `pelican` command. The `python -m http.server` command constantly
194
+
serves up each build's changes.
195
+
196
+
Alright, now that we have our starter files we can get to work creating
197
+
some initial content.
133
198
134
199
135
200
## Building the site
201
+
Pelican can accept both [Markdown](/markdown.html) and reStructureText
0 commit comments