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
|
|
|
|
|
2013-05-26 12:44:32 +02:00
|
|
|
|
Pelican currently runs best on Python 2.7.x; earlier versions of Python are
|
|
|
|
|
|
not supported. There is provisional support for Python 3.3, although there may
|
|
|
|
|
|
be rough edges, particularly with regards to optional 3rd-party components.
|
2013-04-11 19:23:34 -07:00
|
|
|
|
|
|
|
|
|
|
You can install Pelican via several different methods. The simplest is via
|
|
|
|
|
|
`pip <http://www.pip-installer.org/>`_::
|
2010-12-14 15:31:11 +00:00
|
|
|
|
|
|
|
|
|
|
$ pip install pelican
|
|
|
|
|
|
|
2013-04-16 19:45:46 -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
|
|
|
|
|
|
|
2013-04-11 19:23:34 -07:00
|
|
|
|
(Keep in mind that operating systems will often require you to prefix the above
|
|
|
|
|
|
commands with ``sudo`` in order to install Pelican system-wide.)
|
|
|
|
|
|
|
2012-06-11 12:27:01 -07:00
|
|
|
|
While the above is the simplest method, the recommended approach is to create
|
2013-04-16 19:45:46 -07:00
|
|
|
|
a virtual environment for Pelican via virtualenv_ before installing Pelican.
|
|
|
|
|
|
Assuming you have virtualenv_ installed, you can then open a new terminal
|
|
|
|
|
|
session and create a new virtual environment for Pelican::
|
2012-08-06 15:13:04 +03:00
|
|
|
|
|
2013-04-16 19:45:46 -07:00
|
|
|
|
$ virtualenv ~/virtualenvs/pelican
|
|
|
|
|
|
$ cd ~/virtualenvs/pelican
|
|
|
|
|
|
$ . bin/activate
|
2012-06-11 12:27:01 -07:00
|
|
|
|
|
|
|
|
|
|
Once the virtual environment has been created and activated, Pelican can be
|
2013-04-16 19:45:46 -07:00
|
|
|
|
be installed via ``pip install pelican`` as noted above. Alternatively, if
|
2012-09-10 20:48:13 -07:00
|
|
|
|
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-10-28 07:37:53 -07:00
|
|
|
|
If you want to use AsciiDoc you need to install it from `source
|
|
|
|
|
|
<http://www.methods.co.nz/asciidoc/INSTALL.html>`_ or use your operating
|
|
|
|
|
|
system's package manager.
|
|
|
|
|
|
|
2013-04-16 19:45:46 -07:00
|
|
|
|
Basic usage
|
|
|
|
|
|
-----------
|
|
|
|
|
|
|
|
|
|
|
|
Once Pelican is installed, you can use it to convert your Markdown or reST
|
|
|
|
|
|
content into HTML via the ``pelican`` command, specifying the path to your
|
|
|
|
|
|
content and (optionally) the path to your settings file::
|
|
|
|
|
|
|
|
|
|
|
|
$ pelican /path/to/your/content/ [-s path/to/your/settings.py]
|
|
|
|
|
|
|
|
|
|
|
|
The above command will generate your site and save it in the ``output/``
|
|
|
|
|
|
folder, using the default theme to produce a simple site. The default theme
|
|
|
|
|
|
consists of very simple HTML without styling and is provided so folks may use
|
|
|
|
|
|
it as a basis for creating their own themes.
|
|
|
|
|
|
|
|
|
|
|
|
You can also 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.
|
|
|
|
|
|
|
|
|
|
|
|
Pelican has other command-line switches available. Have a look at the help to
|
|
|
|
|
|
see all the options you can use::
|
|
|
|
|
|
|
|
|
|
|
|
$ pelican --help
|
|
|
|
|
|
|
2013-04-23 11:17:45 -07:00
|
|
|
|
Continue reading below for more detail, and check out the Pelican wiki's
|
|
|
|
|
|
`Tutorials <https://github.com/getpelican/pelican/wiki/Tutorials>`_ page for
|
|
|
|
|
|
links to community-published tutorials.
|
|
|
|
|
|
|
2013-04-16 19:45:46 -07:00
|
|
|
|
Viewing the generated files
|
|
|
|
|
|
---------------------------
|
|
|
|
|
|
|
|
|
|
|
|
The files generated by Pelican are static files, so you don't actually need
|
|
|
|
|
|
anything special to view them. You can either use your browser to open the
|
|
|
|
|
|
files on your disk::
|
|
|
|
|
|
|
|
|
|
|
|
firefox output/index.html
|
|
|
|
|
|
|
|
|
|
|
|
Or run a simple web server using Python::
|
|
|
|
|
|
|
|
|
|
|
|
cd output && python -m SimpleHTTPServer
|
|
|
|
|
|
|
2012-06-11 12:27:01 -07:00
|
|
|
|
Upgrading
|
|
|
|
|
|
---------
|
|
|
|
|
|
|
2012-08-06 06:11:54 -07:00
|
|
|
|
If you installed a stable Pelican release via ``pip`` or ``easy_install`` and
|
|
|
|
|
|
wish to upgrade to the latest stable release, you can do so by adding
|
|
|
|
|
|
``--upgrade`` to the relevant command. For pip, that would be::
|
2012-06-11 12:27:01 -07:00
|
|
|
|
|
|
|
|
|
|
$ 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
|
|
|
|
|
2013-04-16 19:45:46 -07:00
|
|
|
|
When Pelican is installed, the following dependent Python packages should be
|
|
|
|
|
|
automatically installed without any action on your part:
|
2010-12-14 15:31:11 +00:00
|
|
|
|
|
2012-12-25 23:59:53 +02:00
|
|
|
|
* `feedgenerator <http://pypi.python.org/pypi/feedgenerator>`_, to generate the
|
|
|
|
|
|
Atom feeds
|
|
|
|
|
|
* `jinja2 <http://pypi.python.org/pypi/Jinja2>`_, for templating support
|
|
|
|
|
|
* `pygments <http://pypi.python.org/pypi/Pygments>`_, for syntax highlighting
|
|
|
|
|
|
* `docutils <http://pypi.python.org/pypi/docutils>`_, for supporting
|
|
|
|
|
|
reStructuredText as an input format
|
|
|
|
|
|
* `pytz <http://pypi.python.org/pypi/pytz>`_, for timezone definitions
|
|
|
|
|
|
* `blinker <http://pypi.python.org/pypi/blinker>`_, an object-to-object and
|
|
|
|
|
|
broadcast signaling system
|
|
|
|
|
|
* `unidecode <http://pypi.python.org/pypi/Unidecode>`_, for ASCII
|
|
|
|
|
|
transliterations of Unicode text
|
2013-06-03 18:23:07 +03:00
|
|
|
|
* `six <http://pypi.python.org/pypi/six>`_, for Python 2 and 3 compatibility
|
|
|
|
|
|
utilities
|
|
|
|
|
|
* `MarkupSafe <http://pypi.python.org/pypi/MarkupSafe>`_, for a markup safe
|
|
|
|
|
|
string implementation
|
2010-12-14 15:31:11 +00:00
|
|
|
|
|
2013-04-16 19:45:46 -07:00
|
|
|
|
If you want the following optional packages, you will need to install them
|
|
|
|
|
|
manually via ``pip``:
|
2011-02-26 16:17:20 +00:00
|
|
|
|
|
2012-12-25 23:59:53 +02:00
|
|
|
|
* `markdown <http://pypi.python.org/pypi/Markdown>`_, for supporting Markdown as
|
|
|
|
|
|
an input format
|
|
|
|
|
|
* `typogrify <http://pypi.python.org/pypi/typogrify>`_, for typographical
|
|
|
|
|
|
enhancements
|
2010-12-14 15:31:11 +00:00
|
|
|
|
|
2013-04-16 19:45:46 -07:00
|
|
|
|
Kickstart your site
|
|
|
|
|
|
===================
|
2012-07-07 08:45:50 -07:00
|
|
|
|
|
2013-04-16 19:45:46 -07:00
|
|
|
|
Once Pelican has been installed, you can create a skeleton project via the
|
|
|
|
|
|
``pelican-quickstart`` command, which begins by asking some questions about
|
|
|
|
|
|
your site::
|
2012-07-07 08:45:50 -07:00
|
|
|
|
|
|
|
|
|
|
$ pelican-quickstart
|
|
|
|
|
|
|
2013-04-16 19:45:46 -07:00
|
|
|
|
Once you finish answering all the questions, your project will consist of the
|
|
|
|
|
|
following hierarchy (except for "pages", which you can optionally add yourself
|
|
|
|
|
|
if you plan to create non-chronological content)::
|
|
|
|
|
|
|
|
|
|
|
|
yourproject/
|
|
|
|
|
|
├── content
|
|
|
|
|
|
│ └── (pages)
|
|
|
|
|
|
├── output
|
|
|
|
|
|
├── develop_server.sh
|
|
|
|
|
|
├── Makefile
|
|
|
|
|
|
├── pelicanconf.py # Main settings file
|
|
|
|
|
|
└── publishconf.py # Settings to use when ready to publish
|
|
|
|
|
|
|
|
|
|
|
|
The next step is to begin to 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 written some content to generate, you can use the ``pelican``
|
|
|
|
|
|
command to generate your site, which will be placed in the output folder.
|
|
|
|
|
|
Alternatively, you can use automation tools that "wrap" the ``pelican`` command
|
|
|
|
|
|
to simplify the process of generating, previewing, and uploading your site. One
|
|
|
|
|
|
such tool is the ``Makefile`` that's automatically created for you when you use
|
|
|
|
|
|
``pelican-quickstart`` to create a skeleton project. To use ``make`` to
|
|
|
|
|
|
generate your site, run::
|
2012-07-07 08:45:50 -07:00
|
|
|
|
|
|
|
|
|
|
$ make html
|
|
|
|
|
|
|
|
|
|
|
|
If you'd prefer to have Pelican automatically regenerate your site every time a
|
2013-04-16 19:45:46 -07:00
|
|
|
|
change is detected (which is handy when testing locally), use the following
|
|
|
|
|
|
command instead::
|
2012-07-07 08:45:50 -07:00
|
|
|
|
|
|
|
|
|
|
$ make regenerate
|
|
|
|
|
|
|
2013-04-16 19:45:46 -07:00
|
|
|
|
To serve the generated site so it can be previewed in your browser at
|
2012-08-05 17:25:39 -07:00
|
|
|
|
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::
|
|
|
|
|
|
|
2012-08-08 09:29:04 -07:00
|
|
|
|
$ ./develop_server.sh 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.
|
|
|
|
|
|
|
2013-04-16 19:45:46 -07:00
|
|
|
|
Writing content using Pelican
|
|
|
|
|
|
=============================
|
|
|
|
|
|
|
|
|
|
|
|
Articles and pages
|
|
|
|
|
|
------------------
|
|
|
|
|
|
|
|
|
|
|
|
Pelican considers "articles" to be chronological content, such as posts on a
|
|
|
|
|
|
blog, and thus associated with a date.
|
|
|
|
|
|
|
|
|
|
|
|
The idea behind "pages" is that they are usually not temporal in nature and are
|
|
|
|
|
|
used for content that does not change very often (e.g., "About" or "Contact"
|
|
|
|
|
|
pages).
|
2011-02-09 21:29:07 +00:00
|
|
|
|
|
2012-03-06 06:13:17 -08:00
|
|
|
|
File metadata
|
2013-04-16 19:45:46 -07: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
|
|
|
|
|
2013-04-16 19:45:46 -07:00
|
|
|
|
If you are writing your content in reStructuredText format, you can provide
|
|
|
|
|
|
this metadata in text files via the 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
|
2012-11-24 13:18:49 +02:00
|
|
|
|
:slug: my-super-post
|
2010-12-14 15:31:11 +00:00
|
|
|
|
:author: Alexis Metaireau
|
2012-11-24 13:18:49 +02:00
|
|
|
|
:summary: Short version for index and feeds
|
2010-12-14 15:31:11 +00:00
|
|
|
|
|
2012-12-03 16:31:55 -08:00
|
|
|
|
Pelican implements an extension to reStructuredText to enable support for the
|
2012-07-18 18:22:31 +02:00
|
|
|
|
``abbr`` HTML tag. To use it, write something like this in your post::
|
|
|
|
|
|
|
|
|
|
|
|
This will be turned into :abbr:`HTML (HyperText Markup Language)`.
|
|
|
|
|
|
|
2013-04-17 21:14:52 -07:00
|
|
|
|
You can also use Markdown syntax (with a file ending in ``.md``,
|
|
|
|
|
|
``.markdown``, ``.mkd``, or ``.mdown``). Markdown generation requires that you
|
|
|
|
|
|
first explicitly install the ``Markdown`` package, which can be done via ``pip
|
|
|
|
|
|
install Markdown``. Metadata syntax for Markdown posts should follow this
|
|
|
|
|
|
pattern::
|
2010-12-14 15:31:11 +00:00
|
|
|
|
|
|
|
|
|
|
Title: My super title
|
2012-11-24 13:18:49 +02:00
|
|
|
|
Date: 2010-12-03 10:20
|
2013-04-16 19:45:46 -07:00
|
|
|
|
Category: Python
|
|
|
|
|
|
Tags: pelican, publishing
|
2012-03-06 06:13:17 -08:00
|
|
|
|
Slug: my-super-post
|
2012-11-24 13:18:49 +02:00
|
|
|
|
Author: Alexis Metaireau
|
|
|
|
|
|
Summary: Short version for index and feeds
|
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
|
|
|
|
|
2013-04-16 19:45:46 -07:00
|
|
|
|
Pelican can also process HTML files ending in ``.html`` and ``.htm``. Pelican
|
|
|
|
|
|
interprets the HTML in a very straightforward manner, reading metadata from
|
|
|
|
|
|
``meta`` tags, the title from the ``title`` tag, and the body out from the
|
2012-07-09 22:43:51 -04:00
|
|
|
|
``body`` tag::
|
|
|
|
|
|
|
|
|
|
|
|
<html>
|
|
|
|
|
|
<head>
|
|
|
|
|
|
<title>My super title</title>
|
|
|
|
|
|
<meta name="tags" contents="thats, awesome" />
|
|
|
|
|
|
<meta name="date" contents="2012-07-09 22:28" />
|
|
|
|
|
|
<meta name="category" contents="yeah" />
|
|
|
|
|
|
<meta name="author" contents="Alexis Métaireau" />
|
2013-01-28 22:25:15 -05:00
|
|
|
|
<meta name="summary" contents="Short version for index and feeds" />
|
2012-07-09 22:43:51 -04:00
|
|
|
|
</head>
|
|
|
|
|
|
<body>
|
|
|
|
|
|
This is the content of my super blog post.
|
|
|
|
|
|
</body>
|
|
|
|
|
|
</html>
|
|
|
|
|
|
|
2013-04-16 19:45:46 -07:00
|
|
|
|
With HTML, there is one simple exception to the standard metadata: ``tags`` can
|
|
|
|
|
|
be specified either via the ``tags`` metadata, as is standard in Pelican, or
|
|
|
|
|
|
via the ``keywords`` metadata, as is standard in HTML. The two can be used
|
|
|
|
|
|
interchangeably.
|
2012-07-09 22:43:51 -04:00
|
|
|
|
|
2013-04-16 19:45:46 -07:00
|
|
|
|
Note that, aside from the title, none of this article metadata is mandatory:
|
|
|
|
|
|
if the date is not specified and ``DEFAULT_DATE`` is set to ``fs``, Pelican
|
|
|
|
|
|
will rely on the file's "mtime" timestamp, and the category can be determined
|
|
|
|
|
|
by the directory in which the file resides. For example, a file located at
|
|
|
|
|
|
``python/foobar/myfoobar.rst`` will have a category of ``foobar``. If you would
|
|
|
|
|
|
like to organize your files in other ways where the name of the subfolder would
|
|
|
|
|
|
not be a good category name, you can set the setting ``USE_FOLDER_AS_CATEGORY``
|
|
|
|
|
|
to ``False``.
|
2013-02-09 19:43:32 -05:00
|
|
|
|
|
2013-04-16 19:45:46 -07:00
|
|
|
|
If you do not explicitly specify summary metadata for a given post, the
|
|
|
|
|
|
``SUMMARY_MAX_LENGTH`` setting can be used to specify how many words from the
|
|
|
|
|
|
beginning of an article are used as the summary.
|
2012-11-30 02:19:38 +01:00
|
|
|
|
|
2012-12-03 16:31:55 -08:00
|
|
|
|
You can also extract any metadata from the filename through a regular
|
2013-04-16 19:45:46 -07:00
|
|
|
|
expression to be set in the ``FILENAME_METADATA`` setting. All named groups
|
|
|
|
|
|
that are matched will be set in the metadata object. The default value for the
|
|
|
|
|
|
``FILENAME_METADATA`` setting will only extract the date from the filename. For
|
|
|
|
|
|
example, if you would like to extract both the date and the slug, you could set
|
|
|
|
|
|
something like: ``'(?P<date>\d{4}-\d{2}-\d{2})_(?P<slug>.*)'``
|
2012-11-30 02:19:38 +01:00
|
|
|
|
|
|
|
|
|
|
Please note that the metadata available inside your files takes precedence over
|
|
|
|
|
|
the metadata extracted from the filename.
|
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-12-03 16:31:55 -08:00
|
|
|
|
If you create a folder named ``pages`` inside the content folder, all the
|
2013-04-14 15:04:38 -07:00
|
|
|
|
files in it will be used to generate static pages, such as **About** or
|
|
|
|
|
|
**Contact** pages. (See example filesystem layout below.)
|
2010-12-14 15:31:11 +00:00
|
|
|
|
|
2013-04-14 15:04:38 -07:00
|
|
|
|
You can use the ``DISPLAY_PAGES_ON_MENU`` setting to control whether all those
|
|
|
|
|
|
pages are displayed in the primary navigation menu. (Default is ``True``.)
|
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.
|
|
|
|
|
|
|
2012-12-01 21:35:15 +01:00
|
|
|
|
Linking to internal content
|
|
|
|
|
|
---------------------------
|
|
|
|
|
|
|
2012-12-03 16:31:55 -08:00
|
|
|
|
From Pelican 3.1 onwards, it is now possible to specify intra-site links to
|
|
|
|
|
|
files in the *source content* hierarchy instead of files in the *generated*
|
|
|
|
|
|
hierarchy. This makes it easier to link from the current post to other posts
|
|
|
|
|
|
and images that may be sitting alongside the current post (instead of having
|
|
|
|
|
|
to determine where those resources will be placed after site generation).
|
2012-12-01 21:35:15 +01:00
|
|
|
|
|
2013-02-25 13:53:29 -05:00
|
|
|
|
To link to internal content (files in the ``content`` directory), use the
|
2013-03-10 20:15:37 -07:00
|
|
|
|
following syntax: ``|filename|path/to/file``::
|
2012-12-01 21:35:15 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
website/
|
|
|
|
|
|
├── content
|
|
|
|
|
|
│ ├── article1.rst
|
2013-04-14 15:04:38 -07:00
|
|
|
|
│ ├── cat/
|
|
|
|
|
|
│ │ └── article2.md
|
|
|
|
|
|
│ └── pages
|
2013-04-16 19:45:46 -07:00
|
|
|
|
│ └── about.md
|
2012-12-01 21:35:15 +01:00
|
|
|
|
└── pelican.conf.py
|
|
|
|
|
|
|
|
|
|
|
|
In this example, ``article1.rst`` could look like::
|
|
|
|
|
|
|
2013-03-10 11:28:54 +05:00
|
|
|
|
The first article
|
|
|
|
|
|
#################
|
|
|
|
|
|
|
|
|
|
|
|
:date: 2012-12-01 10:02
|
2012-12-01 21:35:15 +01:00
|
|
|
|
|
2012-12-03 16:31:55 -08:00
|
|
|
|
See below intra-site link examples in reStructuredText format.
|
2012-12-01 21:35:15 +01:00
|
|
|
|
|
2012-12-03 16:31:55 -08:00
|
|
|
|
`a link relative to content root <|filename|/cat/article2.md>`_
|
|
|
|
|
|
`a link relative to current file <|filename|cat/article2.md>`_
|
2012-12-01 21:35:15 +01:00
|
|
|
|
|
|
|
|
|
|
and ``article2.md``::
|
|
|
|
|
|
|
|
|
|
|
|
Title: The second article
|
2013-03-10 11:28:54 +05:00
|
|
|
|
Date: 2012-12-01 10:02
|
2012-12-01 21:35:15 +01:00
|
|
|
|
|
2012-12-03 16:31:55 -08:00
|
|
|
|
See below intra-site link examples in Markdown format.
|
2012-12-01 21:35:15 +01:00
|
|
|
|
|
2012-12-03 16:31:55 -08:00
|
|
|
|
[a link relative to content root](|filename|/article1.rst)
|
|
|
|
|
|
[a link relative to current file](|filename|../article1.rst)
|
2012-12-01 21:35:15 +01:00
|
|
|
|
|
2013-02-25 13:53:29 -05:00
|
|
|
|
Embedding non-article or non-page content is slightly different in that the
|
|
|
|
|
|
directories need to be specified in ``pelicanconf.py`` file. The ``images``
|
|
|
|
|
|
directory is configured for this by default but others will need to be added
|
2013-03-10 20:15:37 -07:00
|
|
|
|
manually::
|
2012-12-01 21:35:15 +01:00
|
|
|
|
|
2013-02-25 13:53:29 -05:00
|
|
|
|
content
|
|
|
|
|
|
├── images
|
|
|
|
|
|
│ └── han.jpg
|
|
|
|
|
|
└── misc
|
|
|
|
|
|
└── image-test.md
|
|
|
|
|
|
|
|
|
|
|
|
And ``image-test.md`` would include::
|
|
|
|
|
|
|
|
|
|
|
|

|
|
|
|
|
|
|
|
|
|
|
|
Any content can be linked in this way. What happens is that the ``images``
|
|
|
|
|
|
directory gets copied to ``output/static/`` upon publishing. This is
|
|
|
|
|
|
because ``images`` is in the ``settings["STATIC_PATHS"]`` list by default. If
|
|
|
|
|
|
you want to have another directory, say ``pdfs`` you would need to add the
|
|
|
|
|
|
following to ``pelicanconf.py``::
|
|
|
|
|
|
|
|
|
|
|
|
STATIC_PATHS = ['images', 'pdfs']
|
|
|
|
|
|
|
|
|
|
|
|
And then the ``pdfs`` directory would also be copied to ``output/static/``.
|
2012-12-01 21:35:15 +01:00
|
|
|
|
|
2011-06-17 19:26:28 +02:00
|
|
|
|
Importing an existing blog
|
|
|
|
|
|
--------------------------
|
|
|
|
|
|
|
2012-09-10 20:48:13 -07: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
|
|
|
|
|
2013-04-06 17:48:19 +01:00
|
|
|
|
If you do not want the original version of one specific article to be detected
|
|
|
|
|
|
by the ``DEFAULT_LANG`` setting, use the ``translation`` metadata to specify
|
|
|
|
|
|
which posts are translations::
|
|
|
|
|
|
|
|
|
|
|
|
Foobar is not dead
|
|
|
|
|
|
##################
|
|
|
|
|
|
|
|
|
|
|
|
:slug: foobar-is-not-dead
|
|
|
|
|
|
:lang: en
|
|
|
|
|
|
:translation: true
|
|
|
|
|
|
|
|
|
|
|
|
That's true, foobar is still alive!
|
|
|
|
|
|
|
2012-03-06 06:13:17 -08:00
|
|
|
|
Syntax highlighting
|
2012-12-03 16:31:55 -08:00
|
|
|
|
-------------------
|
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-12-03 16:31:55 -08:00
|
|
|
|
To do so, you have to use the following conventions inside your content files.
|
2012-04-01 13:54:20 +02:00
|
|
|
|
|
2012-12-03 16:31:55 -08:00
|
|
|
|
For reStructuredText, use the code-block directive::
|
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
|
|
|
|
|
2012-08-23 18:31:45 -07:00
|
|
|
|
<indented code block goes here>
|
2011-02-09 21:29:07 +00:00
|
|
|
|
|
2012-09-10 20:48:13 -07:00
|
|
|
|
For Markdown, include the language identifier just above the code block,
|
|
|
|
|
|
indenting both the identifier and code::
|
2011-02-09 21:29:07 +00:00
|
|
|
|
|
2012-10-25 14:37:05 +02:00
|
|
|
|
A block of text.
|
2011-02-09 21:29:07 +00:00
|
|
|
|
|
2012-08-23 18:31:45 -07:00
|
|
|
|
:::identifier
|
|
|
|
|
|
<code goes here>
|
2012-03-06 06:13:17 -08:00
|
|
|
|
|
2012-09-10 20:48:13 -07:00
|
|
|
|
The specified identifier (e.g. ``python``, ``ruby``) should be one that
|
2012-08-23 18:31:45 -07:00
|
|
|
|
appears on the `list of available lexers <http://pygments.org/docs/lexers/>`_.
|
2012-03-06 06:13:17 -08:00
|
|
|
|
|
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
|
|
|
|
|
2012-08-06 06:11:54 -07:00
|
|
|
|
.. _virtualenv: http://www.virtualenv.org/
|