logo

Pelican Setup - at Ease

So 04 August 2013 by Andreas Hüwel

Base Installation of Pelican

Shell is your friend? I’ll show howto create a blog with pelican, straightforward following pelican getting_started as suggested with python 2.7 - in an virtualenv.

Set up Python in Virtualenv

Sure you have virtualenv and pip installed? For Debian/Ubuntu:

> sudo apt-get install virtualenvwrapper python-virtualenv python-pip

> cd <PATH_TO_BLOG>
> virtualenv --no-site-packages pelican_blog_env
> cd pelican_blog_env/
> source bin/activate
> which python
   <PATH>/pelican_blog_env/bin/python

> python -V
   Python 2.7.3

Install Pelican

> pip install pelican
   ...
   =====================================================
   WARNING: The C extension could not be compiled, speedups are not enabled.
   Plain-Python installation succeeded.
   =====================================================
   Successfully installed pelican feedgenerator jinja2 pygments docutils pytz blinker unidecode six markupsafe
   Cleaning up...

> pip install Markdown 
> pip install typogrify
> cd ..
> tar -czf pelican_blog_env-fresh.tar.gz pelican_blog_env/

(I like having clean starting point / tarball, if I mess too much around.)

Build Sceleton

See also Generating Static Sites with Pelican It helped me figuring out what the coming questions ment. (And chapo! I never saw someone typing faster! *gg*)

> pelican-quickstart

Entering the Blog

> cd querbalken
> mkdir content/pages

The site you were asked for is the folder it creates for your blog. You can change settings later in configfiles… For me its not clear what happens with the url pelican-quickstart asked me. What with querbalken.net? Will it still stay local? Or will it try to link to my (yet) unexisting online site? Lets explore that later, sure I’ll figure that out, if needed at all…

The subfolder pages will hold the few static main pages, like my contact page MY-VERY-NAME.md. Other subfolders of contents are treated as categories. Like rant, tutorials, misc (default, if no subfolders exist). I will also have an image subfolder, too. Not sure where to place that best.

Then create first content in e.g. content/2013-08-03-readme1st.md and then do

 > make html
 > make serve

Open in browser localhost:8000 to see the result.

Here you can see what you can do:

 > make help

Tweaking Around

Author

Well, I am the only author for my blog, and thus can minimize some settings. As described in Running Pelican, I changed my pelicanconf.py

AUTHOR = u'MY VERY NAME'
AUTHOR_URL = 'pages/{slug}.html'
AUTHOR_SAVE_AS = ''

And created a first stub page in content/pages/MY-VERY-NAME.md. Seems to work.

Theming

Here is a nice theme gallery. For simplicity I just

> cd pelican_blog_env/
> git clone https://github.com/getpelican/pelican-themes.git
> rsync -a tuxlite_tbs MY_NICE_THEME

and did there few edits. Because the theme must be within PYTHONPATH, I created a symbolic link:

> cd pelican_blog_env/lib/python2.7/site-packages/pelican/themes/
> ln -s ../../../../../pelican-themes/MY_NICE_THEME ./MY_NICE_THEME

Folder Layout

When I look at that it currently looks like this: (See the external draft-content folder? My drafts currently not go online. )

Blog
|-- README.md
`-- pelican_blog_env/
    |-- bin/
    |-- include
    `-- lib/
        `-- python2.7/
                `-- site-packages/
                    `-- pelican/
                        `-- themes/
                            `-- MY_NICE_THEME/ (-> symlink to the other)
    |-- local/
    `-- pelican-themes/ 
        |-- MY_NICE_THEME/
    `-- querbalken/
        |-- Makefile
        |-- pelicanconf.py
        |-- develop_server.sh
        |-- publishconf.py
        `-- content/
            |-- 2013-08-03-readme1st.md
            `-- images/
                |-- mailto.jpg
            `-- pages/
                |-- MY-VERY-NAME.md
        `-- draft-content/
          |-- 2013-08-04-pelican-setup-at-ease.md
        |-- images_raw/
        |-- output/

Next Day: Remember to Enter Virtualenv

In case I ever will forget, here are those lines to activate my virtualenv.

> cd <PATH_TO_BLOG>
> virtualenv --no-site-packages pelican_blog_env
> cd pelican_blog_env/
> source bin/activate

Push FTP

Simple:

> make publish

Then all inside folder output goes up the web.

Make devserver vs make publish

O.K. now I also understand the difference:

make devserver reads from pelicanconf.py:

  SITEURL = 'http://localhost:8000'

That keeps all generated links local. This will be e.g. RSS / Atom Feed pointing to local xml files. (All links directly specified in markdown source will of course point where they point.)

make publish reads the url you specified (remember pelican-quickstart?) from publishconf.py:

  SITEURL = 'http://querbalken.net'

This makes all the generated links point to the online website.

Thats all ‘til now. Veery smooth and easy!

Sure, is work left and there are indeed some issues, e.g. with the theme. For example blockquoted code of my markdown has strange artifacts with color highlighting with this theme.

But, I already right now can place articles into web, just having static webspace.

Welcome suggestions…

Cherio!

Cheerios

Andreas Hüwel


Kommentare