2010-12-14 15:31:11 +00:00
|
|
|
Getting started
|
|
|
|
|
###############
|
|
|
|
|
|
2012-07-07 07:41:12 -07:00
|
|
|
Installing Pelican
|
|
|
|
|
==================
|
2010-12-14 15:31:11 +00:00
|
|
|
|
2012-07-07 08:45:50 -07:00
|
|
|
You're ready? Let's go! You can install Pelican via several different methods.
|
2012-06-11 12:27:01 -07:00
|
|
|
The simplest is via `pip <http://www.pip-installer.org/>`_::
|
2010-12-14 15:31:11 +00:00
|
|
|
|
|
|
|
|
$ pip install pelican
|
|
|
|
|
|
2012-07-07 07:41:12 -07:00
|
|
|
If you don't have ``pip`` installed, an alternative method is ``easy_install``::
|
2010-12-14 15:31:11 +00:00
|
|
|
|
2012-06-11 12:27:01 -07:00
|
|
|
$ easy_install pelican
|
|
|
|
|
|
|
|
|
|
While the above is the simplest method, the recommended approach is to create
|
|
|
|
|
a virtual environment for Pelican via `virtualenv <http://www.virtualenv.org/>`_
|
|
|
|
|
and `virtualenvwrapper <http://www.doughellmann.com/projects/virtualenvwrapper/>`_
|
|
|
|
|
before installing Pelican::
|
|
|
|
|
|
2012-07-07 07:41:12 -07:00
|
|
|
$ sudo pip install --upgrade virtualenv virtualenvwrapper
|
2012-08-06 15:13:04 +03:00
|
|
|
|
|
|
|
|
Note that virtualenvwrapper, being a shell hack, usually requires that a new shell
|
|
|
|
|
be started in order to be sourced. Continue -perhaps in a new shell::
|
|
|
|
|
|
2012-06-11 12:27:01 -07:00
|
|
|
$ mkvirtualenv pelican
|
2012-07-07 08:45:50 -07:00
|
|
|
$ pip install pelican
|
2012-06-11 12:27:01 -07:00
|
|
|
|
|
|
|
|
Once the virtual environment has been created and activated, Pelican can be
|
2012-07-07 07:41:12 -07:00
|
|
|
be installed via ``pip`` or ``easy_install`` as noted above. Alternatively, if
|
|
|
|
|
you have the project source, you can install Pelican using the distutils
|
2012-06-11 12:27:01 -07:00
|
|
|
method::
|
|
|
|
|
|
|
|
|
|
$ cd path-to-Pelican-source
|
2010-12-14 15:31:11 +00:00
|
|
|
$ python setup.py install
|
|
|
|
|
|
2012-06-11 12:27:01 -07:00
|
|
|
If you have Git installed and prefer to install the latest bleeding-edge
|
|
|
|
|
version of Pelican rather than a stable release, use the following command::
|
|
|
|
|
|
2012-07-27 00:27:08 +02:00
|
|
|
$ pip install -e git://github.com/getpelican/pelican#egg=pelican
|
2012-06-11 12:27:01 -07:00
|
|
|
|
2012-07-07 07:41:12 -07:00
|
|
|
If you plan on using Markdown as a markup format, you'll need to install the
|
|
|
|
|
Markdown library as well::
|
|
|
|
|
|
|
|
|
|
$ pip install Markdown
|
|
|
|
|
|
2012-06-11 12:27:01 -07:00
|
|
|
Upgrading
|
|
|
|
|
---------
|
|
|
|
|
|
|
|
|
|
If you installed a stable Pelican release via pip or easy_install and wish to
|
2012-07-01 10:52:39 -07:00
|
|
|
upgrade to the latest stable release, you can do so by adding ``--upgrade`` to
|
2012-06-11 12:27:01 -07:00
|
|
|
the relevant command. For pip, that would be::
|
|
|
|
|
|
|
|
|
|
$ pip install --upgrade pelican
|
|
|
|
|
|
|
|
|
|
If you installed Pelican via distutils or the bleeding-edge method, simply
|
|
|
|
|
perform the same step to install the most recent version.
|
|
|
|
|
|
2010-12-14 15:31:11 +00:00
|
|
|
Dependencies
|
2011-02-09 21:29:07 +00:00
|
|
|
------------
|
2010-12-14 15:31:11 +00:00
|
|
|
|
2012-03-06 06:13:17 -08:00
|
|
|
At this time, Pelican is dependent on the following Python packages:
|
2010-12-14 15:31:11 +00:00
|
|
|
|
2012-03-06 06:13:17 -08:00
|
|
|
* feedgenerator, to generate the Atom feeds
|
|
|
|
|
* jinja2, for templating support
|
2012-04-01 14:46:09 +02:00
|
|
|
* docutils, for supporting reStructuredText as an input format
|
2010-12-14 15:31:11 +00:00
|
|
|
|
2012-07-01 10:52:39 -07:00
|
|
|
If you're not using Python 2.7, you will also need the ``argparse`` package.
|
2010-12-14 15:31:11 +00:00
|
|
|
|
2011-02-26 16:17:20 +00:00
|
|
|
Optionally:
|
|
|
|
|
|
2012-03-06 06:13:17 -08:00
|
|
|
* pygments, for syntax highlighting
|
|
|
|
|
* Markdown, for supporting Markdown as an input format
|
2010-12-14 15:31:11 +00:00
|
|
|
|
2012-07-07 08:45:50 -07:00
|
|
|
Kickstart a blog
|
|
|
|
|
================
|
|
|
|
|
|
|
|
|
|
Following is a brief tutorial for those who want to get started right away.
|
|
|
|
|
We're going to assume Pelican was installed in a virtual environment via the
|
|
|
|
|
following steps (if you're not using a virtual environment for Pelican, you can
|
|
|
|
|
skip to the ``pelican-quickstart`` command)::
|
|
|
|
|
|
|
|
|
|
$ sudo pip install --upgrade virtualenv virtualenvwrapper
|
|
|
|
|
$ mkvirtualenv pelican
|
|
|
|
|
$ pip install pelican Markdown
|
|
|
|
|
|
|
|
|
|
Next we'll create a directory to house our site content and configuration files,
|
|
|
|
|
which can be located any place you prefer, and associate this new project with
|
|
|
|
|
the currently-active virtual environment::
|
|
|
|
|
|
|
|
|
|
$ mkdir ~/code/yoursitename
|
|
|
|
|
$ cd ~/code/yoursitename
|
|
|
|
|
$ setvirtualenvproject
|
|
|
|
|
|
|
|
|
|
Now we can run the ``pelican-quickstart`` command, which will ask some questions
|
|
|
|
|
about your site::
|
|
|
|
|
|
|
|
|
|
$ pelican-quickstart
|
|
|
|
|
|
|
|
|
|
Once you finish answering all the questions, you can begin adding content to the
|
|
|
|
|
*content* folder that has been created for you. (See *Writing articles using
|
|
|
|
|
Pelican* section below for more information about how to format your content.)
|
|
|
|
|
Once you have some content to generate, you can convert it to HTML via the
|
|
|
|
|
following command::
|
|
|
|
|
|
|
|
|
|
$ make html
|
|
|
|
|
|
|
|
|
|
If you'd prefer to have Pelican automatically regenerate your site every time a
|
|
|
|
|
change is detected (handy when testing locally), use the following command
|
|
|
|
|
instead::
|
|
|
|
|
|
|
|
|
|
$ make regenerate
|
|
|
|
|
|
2012-08-05 17:25:39 -07:00
|
|
|
To serve the site so it can be previewed in your browser at
|
|
|
|
|
http://localhost:8000::
|
2012-07-07 08:45:50 -07:00
|
|
|
|
|
|
|
|
$ make serve
|
|
|
|
|
|
2012-08-05 17:25:39 -07:00
|
|
|
Normally you would need to run ``make regenerate`` and ``make serve`` in two
|
|
|
|
|
separate terminal sessions, but you can run both at once via::
|
|
|
|
|
|
|
|
|
|
$ make devserver
|
|
|
|
|
|
|
|
|
|
The above command will simultaneously run Pelican in regeneration mode as well
|
|
|
|
|
as serve the output at http://localhost:8000. Once you are done testing your
|
|
|
|
|
changes, you should stop the development server via::
|
|
|
|
|
|
|
|
|
|
$ ./develop_server stop
|
2012-07-07 08:45:50 -07:00
|
|
|
|
|
|
|
|
When you're ready to publish your site, you can upload it via the method(s) you
|
|
|
|
|
chose during the ``pelican-quickstart`` questionnaire. For this example, we'll
|
|
|
|
|
use rsync over ssh::
|
|
|
|
|
|
|
|
|
|
$ make rsync_upload
|
|
|
|
|
|
|
|
|
|
That's it! Your site should now be live.
|
|
|
|
|
|
2012-03-06 06:13:17 -08:00
|
|
|
Writing articles using Pelican
|
2011-02-09 21:29:07 +00:00
|
|
|
==============================
|
|
|
|
|
|
2012-03-06 06:13:17 -08:00
|
|
|
File metadata
|
2011-02-09 21:29:07 +00:00
|
|
|
--------------
|
2010-12-14 15:31:11 +00:00
|
|
|
|
2012-03-06 06:13:17 -08:00
|
|
|
Pelican tries to be smart enough to get the information it needs from the
|
|
|
|
|
file system (for instance, about the category of your articles), but some
|
|
|
|
|
information you need to provide in the form of metadata inside your files.
|
2010-12-14 15:31:11 +00:00
|
|
|
|
2012-03-06 06:13:17 -08:00
|
|
|
You can provide this metadata in reStructuredText text files via the
|
2012-07-01 10:52:39 -07:00
|
|
|
following syntax (give your file the ``.rst`` extension)::
|
2010-12-14 15:31:11 +00:00
|
|
|
|
|
|
|
|
My super title
|
|
|
|
|
##############
|
|
|
|
|
|
|
|
|
|
:date: 2010-10-03 10:20
|
|
|
|
|
:tags: thats, awesome
|
|
|
|
|
:category: yeah
|
|
|
|
|
:author: Alexis Metaireau
|
|
|
|
|
|
2012-07-18 18:22:31 +02:00
|
|
|
Pelican implements an extension of reStructuredText to enable support for the
|
|
|
|
|
``abbr`` HTML tag. To use it, write something like this in your post::
|
|
|
|
|
|
|
|
|
|
This will be turned into :abbr:`HTML (HyperText Markup Language)`.
|
|
|
|
|
|
2012-07-01 10:52:39 -07:00
|
|
|
You can also use Markdown syntax (with a file ending in ``.md``).
|
|
|
|
|
Markdown generation will not work until you explicitly install the ``Markdown``
|
|
|
|
|
package, which can be done via ``pip install Markdown``. Metadata syntax for
|
2012-06-11 12:27:01 -07:00
|
|
|
Markdown posts should follow this pattern::
|
2010-12-14 15:31:11 +00:00
|
|
|
|
|
|
|
|
Date: 2010-12-03
|
|
|
|
|
Title: My super title
|
2012-03-06 06:13:17 -08:00
|
|
|
Tags: thats, awesome
|
|
|
|
|
Slug: my-super-post
|
2010-12-14 15:31:11 +00:00
|
|
|
|
2012-03-06 06:13:17 -08:00
|
|
|
This is the content of my super blog post.
|
2010-12-14 15:31:11 +00:00
|
|
|
|
2012-03-06 06:13:17 -08:00
|
|
|
Note that, aside from the title, none of this metadata is mandatory: if the date
|
|
|
|
|
is not specified, Pelican will rely on the file's "mtime" timestamp, and the
|
|
|
|
|
category can be determined by the directory in which the file resides. For
|
2012-07-01 10:52:39 -07:00
|
|
|
example, a file located at ``python/foobar/myfoobar.rst`` will have a category of
|
|
|
|
|
``foobar``.
|
2010-12-14 15:31:11 +00:00
|
|
|
|
|
|
|
|
Generate your blog
|
2011-02-09 21:29:07 +00:00
|
|
|
------------------
|
2010-12-14 15:31:11 +00:00
|
|
|
|
2012-07-07 07:41:12 -07:00
|
|
|
The ``make`` shortcut commands mentioned in the ``Kickstart a blog`` section
|
|
|
|
|
are mostly wrappers around the ``pelican`` command that generates the HTML from
|
|
|
|
|
the content. The ``pelican`` command can also be run directly::
|
2010-12-14 15:31:11 +00:00
|
|
|
|
2011-02-14 10:42:25 +00:00
|
|
|
$ pelican /path/to/your/content/ [-s path/to/your/settings.py]
|
2010-12-14 15:31:11 +00:00
|
|
|
|
2012-07-07 07:41:12 -07:00
|
|
|
The above command will generate your weblog and save it in the ``content/``
|
2012-07-07 08:45:50 -07:00
|
|
|
folder, using the default theme to produce a simple site. The default theme is
|
|
|
|
|
simple HTML without styling and is provided so folks may use it as a basis for
|
|
|
|
|
creating their own themes.
|
2010-12-14 15:31:11 +00:00
|
|
|
|
2012-07-07 07:41:12 -07:00
|
|
|
Pelican has other command-line switches available. Have a look at the help to
|
|
|
|
|
see all the options you can use::
|
2010-12-14 15:31:11 +00:00
|
|
|
|
|
|
|
|
$ pelican --help
|
|
|
|
|
|
2012-07-07 07:41:12 -07:00
|
|
|
Auto-reload
|
|
|
|
|
-----------
|
2011-08-11 23:34:53 +02:00
|
|
|
|
2012-07-07 07:41:12 -07:00
|
|
|
It's possible to tell Pelican to watch for your modifications, instead of
|
|
|
|
|
manually re-running it every time you want to see your changes. To enable this,
|
|
|
|
|
run the ``pelican`` command with the ``-r`` or ``--autoreload`` option.
|
2011-08-11 23:34:53 +02:00
|
|
|
|
2010-12-14 15:31:11 +00:00
|
|
|
Pages
|
2011-02-09 21:29:07 +00:00
|
|
|
-----
|
2010-12-14 15:31:11 +00:00
|
|
|
|
2012-07-01 10:52:39 -07:00
|
|
|
If you create a folder named ``pages``, all the files in it will be used to
|
2010-12-14 15:31:11 +00:00
|
|
|
generate static pages.
|
|
|
|
|
|
2012-07-01 10:52:39 -07:00
|
|
|
Then, use the ``DISPLAY_PAGES_ON_MENU`` setting, which will add all the pages to
|
2010-12-14 15:48:35 +00:00
|
|
|
the menu.
|
2010-12-20 22:50:54 +00:00
|
|
|
|
2012-06-26 19:26:43 -07:00
|
|
|
If you want to exclude any pages from being linked to or listed in the menu
|
2012-06-27 07:02:25 -07:00
|
|
|
then add a ``status: hidden`` attribute to its metadata. This is useful for
|
2012-06-26 19:26:43 -07:00
|
|
|
things like making error pages that fit the generated theme of your site.
|
|
|
|
|
|
2011-06-17 19:26:28 +02:00
|
|
|
Importing an existing blog
|
|
|
|
|
--------------------------
|
|
|
|
|
|
2012-03-06 06:13:17 -08:00
|
|
|
It is possible to import your blog from Dotclear, WordPress, and RSS feeds using
|
2011-08-11 23:34:53 +02:00
|
|
|
a simple script. See :ref:`import`.
|
2011-06-17 19:26:28 +02:00
|
|
|
|
2010-12-20 22:50:54 +00:00
|
|
|
Translations
|
2011-02-09 21:29:07 +00:00
|
|
|
------------
|
2010-12-20 22:50:54 +00:00
|
|
|
|
2012-07-01 10:52:39 -07:00
|
|
|
It is possible to translate articles. To do so, you need to add a ``lang`` meta
|
|
|
|
|
attribute to your articles/pages and set a ``DEFAULT_LANG`` setting (which is
|
2012-03-06 06:13:17 -08:00
|
|
|
English [en] by default). With those settings in place, only articles with the
|
|
|
|
|
default language will be listed, and each article will be accompanied by a list
|
|
|
|
|
of available translations for that article.
|
2011-01-06 02:33:14 +01:00
|
|
|
|
2012-03-06 06:13:17 -08:00
|
|
|
Pelican uses the article's URL "slug" to determine if two or more articles are
|
|
|
|
|
translations of one another. The slug can be set manually in the file's
|
|
|
|
|
metadata; if not set explicitly, Pelican will auto-generate the slug from the
|
|
|
|
|
title of the article.
|
2011-01-06 02:33:14 +01:00
|
|
|
|
2012-03-06 06:13:17 -08:00
|
|
|
Here is an example of two articles, one in English and the other in French.
|
2011-01-06 02:33:14 +01:00
|
|
|
|
2012-03-06 06:13:17 -08:00
|
|
|
The English article::
|
2011-01-06 02:33:14 +01:00
|
|
|
|
|
|
|
|
Foobar is not dead
|
|
|
|
|
##################
|
|
|
|
|
|
|
|
|
|
:slug: foobar-is-not-dead
|
|
|
|
|
:lang: en
|
|
|
|
|
|
2012-03-06 06:13:17 -08:00
|
|
|
That's true, foobar is still alive!
|
2011-01-06 02:33:14 +01:00
|
|
|
|
2012-03-06 06:13:17 -08:00
|
|
|
And the French version::
|
2011-01-06 02:33:14 +01:00
|
|
|
|
|
|
|
|
Foobar n'est pas mort !
|
|
|
|
|
#######################
|
|
|
|
|
|
|
|
|
|
:slug: foobar-is-not-dead
|
|
|
|
|
:lang: fr
|
|
|
|
|
|
|
|
|
|
Oui oui, foobar est toujours vivant !
|
|
|
|
|
|
2012-03-06 06:13:17 -08:00
|
|
|
Post content quality notwithstanding, you can see that only item in common
|
|
|
|
|
between the two articles is the slug, which is functioning here as an
|
|
|
|
|
identifier. If you'd rather not explicitly define the slug this way, you must
|
|
|
|
|
then instead ensure that the translated article titles are identical, since the
|
|
|
|
|
slug will be auto-generated from the article title.
|
2011-01-12 23:45:06 +01:00
|
|
|
|
2012-03-06 06:13:17 -08:00
|
|
|
Syntax highlighting
|
2011-02-09 21:29:07 +00:00
|
|
|
---------------------
|
|
|
|
|
|
2012-03-06 06:13:17 -08:00
|
|
|
Pelican is able to provide colorized syntax highlighting for your code blocks.
|
2012-04-01 13:54:20 +02:00
|
|
|
To do so, you have to use the following conventions (you need to put this in
|
|
|
|
|
your content files).
|
|
|
|
|
|
|
|
|
|
For RestructuredText::
|
2011-02-09 21:29:07 +00:00
|
|
|
|
2011-02-11 15:36:04 +01:00
|
|
|
.. code-block:: identifier
|
2011-06-03 18:26:27 +02:00
|
|
|
|
|
|
|
|
your code goes here
|
2011-02-09 21:29:07 +00:00
|
|
|
|
2012-04-01 13:54:20 +02:00
|
|
|
For Markdown, format your code blocks thusly::
|
2011-02-09 21:29:07 +00:00
|
|
|
|
2012-05-21 15:21:16 +02:00
|
|
|
:::identifier
|
2012-03-06 06:13:17 -08:00
|
|
|
your code goes here
|
|
|
|
|
|
|
|
|
|
The specified identifier should be one that appears on the
|
|
|
|
|
`list of available lexers <http://pygments.org/docs/lexers/>`_.
|
|
|
|
|
|
2011-05-08 14:58:57 +01:00
|
|
|
Publishing drafts
|
|
|
|
|
-----------------
|
|
|
|
|
|
2012-03-06 06:13:17 -08:00
|
|
|
If you want to publish an article as a draft (for friends to review before
|
|
|
|
|
publishing, for example), you can add a ``status: draft`` attribute to its
|
|
|
|
|
metadata. That article will then be output to the ``drafts`` folder and not
|
|
|
|
|
listed on the index page nor on any category page.
|
2011-08-17 10:38:48 +02:00
|
|
|
|
|
|
|
|
Viewing the generated files
|
|
|
|
|
---------------------------
|
|
|
|
|
|
2012-03-06 06:13:17 -08:00
|
|
|
The files generated by Pelican are static files, so you don't actually need
|
|
|
|
|
anything special to see what's happening with the generated files.
|
2011-08-17 10:38:48 +02:00
|
|
|
|
2012-03-06 06:13:17 -08:00
|
|
|
You can either use your browser to open the files on your disk::
|
2011-08-17 10:38:48 +02:00
|
|
|
|
|
|
|
|
$ firefox output/index.html
|
|
|
|
|
|
2012-03-06 06:13:17 -08:00
|
|
|
Or run a simple web server using Python::
|
2011-08-17 10:38:48 +02:00
|
|
|
|
|
|
|
|
cd output && python -m SimpleHTTPServer
|
2012-06-11 12:27:01 -07:00
|
|
|
|