Skip to content

Commit 577f935

Browse files
committed
still working on next post :/
1 parent 31aaf11 commit 577f935

File tree

1 file changed

+56
-23
lines changed

1 file changed

+56
-23
lines changed

content/posts/170605-static-sites-pelican.markdown

Lines changed: 56 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@ site is pre-generated before deployment and a web server simply responds
1919
with existing files rather than executing any code on the server during
2020
the HTTP request-response cycle.
2121

22-
In this tutorial you will learn how to create a basic static site that you
23-
can further customize and expand with your own design and content.
22+
In this tutorial you will learn how to create a
23+
[basic static website](/static-site-generator.html) that you can further
24+
customize and expand with your own design and content.
2425

2526

2627
## Our Tools
@@ -164,12 +165,19 @@ content fabfile.py publishconf.py
164165

165166
The quickstart created five files and one new directory:
166167

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`
168+
* `Makefile`: `make` command convenience tasks for common operations such as
169+
running a development server, building a site and cleaning extraneous
170+
build files
171+
* `fabfile.py`: A Fabric file that has some of the same types of commands
172+
as the `Makefile`. Fabric is a wonderful code library but for now I
173+
recommend skipping the Fabric file because unfortunately Fabric does not
174+
yet support Python 3.
175+
* `develop_server.sh`: shell script for running the development server
176+
* `pelicanconf.py`: settings file for your Pelican project. If you are used
177+
to earlier versions of Pelican this file was instead named `settings.py`
178+
* `publishconf.py`: another (optional) settings file that can be considered
179+
as a "production" settings file when you move past the development phase
180+
and want to deploy your site
173181
* `content`: location for your markup files, which should be stored under
174182
`pages` and `posts` directories
175183

@@ -187,6 +195,28 @@ browser and you will see the first version of your static site.
187195

188196
<img src="/img/170605-static-sites-pelican/default-style.png" width="100%" class="technical-diagram img-rounded" style="border:1px solid #ccc" alt="Default styling on the Pelican static site.">
189197

198+
If you want to kill the development server, Pelican creates a file named
199+
`pelican.pid` under your project directory with the development server's
200+
process ID.
201+
202+
```
203+
(staticsite) $ cat pelican.pid
204+
1365
205+
```
206+
207+
Use the `ps` and `grep` commands to view the process then stop the process
208+
with the `kill` command as follows. Remember that your process ID will almost
209+
definitely be different from the `1365` ID for my process.
210+
211+
```
212+
(staticsite) $ ps -A | grep 1365
213+
1365 ttys003 0:01.43 /Library/Frameworks/Python.framework/Versions/3.6/Resources/Python.app/Contents/MacOS/Python /Users/matt/Envs/staticsite/bin/pelican --debug --autoreload -r /Users/matt/devel/py/retrosynth/content -o /Users/matt/devel/py/retrosynth/output -s /Users/matt/devel/py/retrosynth/pelicanconf.py
214+
1411 ttys003 0:00.00 grep 1365
215+
(staticsite) $ kill 1365
216+
(staticsite) $ ps -A | grep 1365
217+
1413 ttys003 0:00.00 grep 1365
218+
```
219+
190220
It is up to you whether you want to use the development server or not
191221
while creating your site. Every time I want to view my changes for
192222
Full Stack Python I actually regenerate the site using my own Makefile that
@@ -197,10 +227,15 @@ Alright, now that we have our starter files we can get to work creating
197227
some initial content.
198228

199229

200-
## Building the site
230+
## Write Some Content
201231
Pelican can accept both [Markdown](/markdown.html) and reStructureText
202232
markup files as input.
203233

234+
Create a new subdirectory under the `content` named `posts`.
235+
236+
237+
We used the `make devserver` command earlier, but what other commands are
238+
available to us?
204239

205240

206241
```bash
@@ -239,15 +274,7 @@ WARNING: No valid files found in content.
239274
Done: Processed 0 articles, 0 drafts, 0 pages and 0 hidden pages in 0.07 seconds.
240275
```
241276

242-
243-
## Serve the site
244-
A major issue with Fabric is that it is
245-
[still only compatible with Python 2.x](https://github.com/fabric/fabric/issues/1017).
246-
Python 3 support is supposed to come in Fabric 2, but that has not yet
247-
been released.
248-
249-
Therefore I recommend skipping the Fabric file and running commands
250-
directly with Python 3.
277+
We can serve up the generated site using Python's built-in HTTP server
251278

252279
```
253280
python -m http.server
@@ -261,16 +288,17 @@ application bound to port 8000.
261288
python -m http.server 8005
262289
```
263290

264-
## Create Content
291+
Note that if you are using Python 2 the equivalent HTTP server command is
292+
`python -m SimpleHTTPServer`.
265293

266294

267295

268-
## Edit Configuration
296+
## Edit the Configuration
269297
Change the time zone to your zone. Wikipedia has
270298
[a handy look up table of valid time zones values](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones).
271299

272300

273-
## Modify the Theme
301+
## Modify the Site Theme
274302

275303

276304

@@ -280,9 +308,14 @@ You just generated your first [Pelican](/pelican.html) static website using
280308
make additional modifications to the Jinja2 templates, build new pages and
281309
add more content via Markdown files.
282310

283-
Looking to get even more advanced with Pelican? Check out the open source
311+
Do you want to deploy your new static website to GitHub Pages or an S3 bucket?
312+
That's a story for another Full Stack Python tutorial...
313+
314+
Looking to build a far more complicated static site with Pelican? Check
315+
out the open source
284316
[Full Stack Python code](https://github.com/mattmakai/fullstackpython.com)
285-
to see how a fairly large 100+ pages and 100,000+ words site can be built.
317+
to see how a reasonably large 100+ pages and 100,000+ words site is
318+
structured.
286319

287320
Questions? Let me know via
288321
[a GitHub issue ticket on the Full Stack Python repository](https://github.com/mattmakai/fullstackpython.com/issues),

0 commit comments

Comments
 (0)