mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
Getting Started documentation overhaul
This commit is contained in:
parent
8be7c0dbae
commit
bef5e4479e
1 changed files with 126 additions and 116 deletions
|
|
@ -14,7 +14,8 @@ You can install Pelican via several different methods. The simplest is via
|
||||||
|
|
||||||
$ pip install pelican
|
$ pip install pelican
|
||||||
|
|
||||||
If you don't have ``pip`` installed, an alternative method is ``easy_install``::
|
If you don't have ``pip`` installed, an alternative method is
|
||||||
|
``easy_install``::
|
||||||
|
|
||||||
$ easy_install pelican
|
$ easy_install pelican
|
||||||
|
|
||||||
|
|
@ -22,18 +23,16 @@ If you don't have ``pip`` installed, an alternative method is ``easy_install``::
|
||||||
commands with ``sudo`` in order to install Pelican system-wide.)
|
commands with ``sudo`` in order to install Pelican system-wide.)
|
||||||
|
|
||||||
While the above is the simplest method, the recommended approach is to create
|
While the above is the simplest method, the recommended approach is to create
|
||||||
a virtual environment for Pelican via virtualenv_ and virtualenvwrapper_ before
|
a virtual environment for Pelican via virtualenv_ before installing Pelican.
|
||||||
installing Pelican. Assuming you've followed the virtualenvwrapper
|
Assuming you have virtualenv_ installed, you can then open a new terminal
|
||||||
`installation <http://virtualenvwrapper.readthedocs.org/en/latest/install.html>`_
|
session and create a new virtual environment for Pelican::
|
||||||
and `shell configuration
|
|
||||||
<http://virtualenvwrapper.readthedocs.org/en/latest/install.html#shell-startup-file>`_
|
|
||||||
steps, you can then open a new terminal session and create a new virtual
|
|
||||||
environment for Pelican::
|
|
||||||
|
|
||||||
$ mkvirtualenv pelican
|
$ virtualenv ~/virtualenvs/pelican
|
||||||
|
$ cd ~/virtualenvs/pelican
|
||||||
|
$ . bin/activate
|
||||||
|
|
||||||
Once the virtual environment has been created and activated, Pelican can be
|
Once the virtual environment has been created and activated, Pelican can be
|
||||||
be installed via ``pip`` or ``easy_install`` as noted above. Alternatively, if
|
be installed via ``pip install pelican`` as noted above. Alternatively, if
|
||||||
you have the project source, you can install Pelican using the distutils
|
you have the project source, you can install Pelican using the distutils
|
||||||
method::
|
method::
|
||||||
|
|
||||||
|
|
@ -54,6 +53,42 @@ 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
|
<http://www.methods.co.nz/asciidoc/INSTALL.html>`_ or use your operating
|
||||||
system's package manager.
|
system's package manager.
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
Upgrading
|
Upgrading
|
||||||
---------
|
---------
|
||||||
|
|
||||||
|
|
@ -69,7 +104,8 @@ perform the same step to install the most recent version.
|
||||||
Dependencies
|
Dependencies
|
||||||
------------
|
------------
|
||||||
|
|
||||||
At this time, Pelican core is dependent on the following Python packages:
|
When Pelican is installed, the following dependent Python packages should be
|
||||||
|
automatically installed without any action on your part:
|
||||||
|
|
||||||
* `feedgenerator <http://pypi.python.org/pypi/feedgenerator>`_, to generate the
|
* `feedgenerator <http://pypi.python.org/pypi/feedgenerator>`_, to generate the
|
||||||
Atom feeds
|
Atom feeds
|
||||||
|
|
@ -83,53 +119,57 @@ At this time, Pelican core is dependent on the following Python packages:
|
||||||
* `unidecode <http://pypi.python.org/pypi/Unidecode>`_, for ASCII
|
* `unidecode <http://pypi.python.org/pypi/Unidecode>`_, for ASCII
|
||||||
transliterations of Unicode text
|
transliterations of Unicode text
|
||||||
|
|
||||||
Optionally:
|
If you want the following optional packages, you will need to install them
|
||||||
|
manually via ``pip``:
|
||||||
|
|
||||||
* `markdown <http://pypi.python.org/pypi/Markdown>`_, for supporting Markdown as
|
* `markdown <http://pypi.python.org/pypi/Markdown>`_, for supporting Markdown as
|
||||||
an input format
|
an input format
|
||||||
* `typogrify <http://pypi.python.org/pypi/typogrify>`_, for typographical
|
* `typogrify <http://pypi.python.org/pypi/typogrify>`_, for typographical
|
||||||
enhancements
|
enhancements
|
||||||
|
|
||||||
Kickstart a blog
|
Kickstart your site
|
||||||
================
|
===================
|
||||||
|
|
||||||
Following is a brief tutorial for those who want to get started right away.
|
Once Pelican has been installed, you can create a skeleton project via the
|
||||||
We're going to assume that virtualenv_ and virtualenvwrapper_ are installed and
|
``pelican-quickstart`` command, which begins by asking some questions about
|
||||||
configured; if you've installed Pelican outside of a virtual environment,
|
your site::
|
||||||
you can skip to the ``pelican-quickstart`` command. Let's first create a new
|
|
||||||
virtual environment and install Pelican into it::
|
|
||||||
|
|
||||||
$ 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
|
$ pelican-quickstart
|
||||||
|
|
||||||
Once you finish answering all the questions, you can begin adding content to the
|
Once you finish answering all the questions, your project will consist of the
|
||||||
*content* folder that has been created for you. (See *Writing articles using
|
following hierarchy (except for "pages", which you can optionally add yourself
|
||||||
Pelican* section below for more information about how to format your content.)
|
if you plan to create non-chronological content)::
|
||||||
Once you have some content to generate, you can convert it to HTML via the
|
|
||||||
following command::
|
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::
|
||||||
|
|
||||||
$ make html
|
$ make html
|
||||||
|
|
||||||
If you'd prefer to have Pelican automatically regenerate your site every time a
|
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
|
change is detected (which is handy when testing locally), use the following
|
||||||
instead::
|
command instead::
|
||||||
|
|
||||||
$ make regenerate
|
$ make regenerate
|
||||||
|
|
||||||
To serve the site so it can be previewed in your browser at
|
To serve the generated site so it can be previewed in your browser at
|
||||||
http://localhost:8000::
|
http://localhost:8000::
|
||||||
|
|
||||||
$ make serve
|
$ make serve
|
||||||
|
|
@ -153,18 +193,29 @@ use rsync over ssh::
|
||||||
|
|
||||||
That's it! Your site should now be live.
|
That's it! Your site should now be live.
|
||||||
|
|
||||||
Writing articles using Pelican
|
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).
|
||||||
|
|
||||||
File metadata
|
File metadata
|
||||||
--------------
|
-------------
|
||||||
|
|
||||||
Pelican tries to be smart enough to get the information it needs from the
|
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
|
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.
|
information you need to provide in the form of metadata inside your files.
|
||||||
|
|
||||||
You can provide this metadata in reStructuredText text files via the
|
If you are writing your content in reStructuredText format, you can provide
|
||||||
following syntax (give your file the ``.rst`` extension)::
|
this metadata in text files via the following syntax (give your file the
|
||||||
|
``.rst`` extension)::
|
||||||
|
|
||||||
My super title
|
My super title
|
||||||
##############
|
##############
|
||||||
|
|
@ -182,23 +233,23 @@ Pelican implements an extension to reStructuredText to enable support for the
|
||||||
This will be turned into :abbr:`HTML (HyperText Markup Language)`.
|
This will be turned into :abbr:`HTML (HyperText Markup Language)`.
|
||||||
|
|
||||||
You can also use Markdown syntax (with a file ending in ``.md``, ``.markdown``,
|
You can also use Markdown syntax (with a file ending in ``.md``, ``.markdown``,
|
||||||
or ``.mkd``). Markdown generation will not work until you explicitly install the
|
or ``.mkd``). Markdown generation requires that you first explicitly install
|
||||||
``Markdown`` package, which can be done via ``pip install Markdown``. Metadata
|
the ``Markdown`` package, which can be done via ``pip install Markdown``.
|
||||||
syntax for Markdown posts should follow this pattern::
|
Metadata syntax for Markdown posts should follow this pattern::
|
||||||
|
|
||||||
Title: My super title
|
Title: My super title
|
||||||
Date: 2010-12-03 10:20
|
Date: 2010-12-03 10:20
|
||||||
Tags: thats, awesome
|
Category: Python
|
||||||
Category: yeah
|
Tags: pelican, publishing
|
||||||
Slug: my-super-post
|
Slug: my-super-post
|
||||||
Author: Alexis Metaireau
|
Author: Alexis Metaireau
|
||||||
Summary: Short version for index and feeds
|
Summary: Short version for index and feeds
|
||||||
|
|
||||||
This is the content of my super blog post.
|
This is the content of my super blog post.
|
||||||
|
|
||||||
Lastly, you can use vanilla HTML (files ending in ``.htm`` and ``.html``). Pelican
|
Pelican can also process HTML files ending in ``.html`` and ``.htm``. Pelican
|
||||||
interprets the HTML in a very straightforward manner, reading meta data out
|
interprets the HTML in a very straightforward manner, reading metadata from
|
||||||
of ``meta`` tags, the title out of the ``title`` tag, and the body out of the
|
``meta`` tags, the title from the ``title`` tag, and the body out from the
|
||||||
``body`` tag::
|
``body`` tag::
|
||||||
|
|
||||||
<html>
|
<html>
|
||||||
|
|
@ -215,61 +266,34 @@ of ``meta`` tags, the title out of the ``title`` tag, and the body out of the
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
||||||
With HTML, there is one simple exception to the standard metadata.
|
With HTML, there is one simple exception to the standard metadata: ``tags`` can
|
||||||
``tags`` can be specified either with the ``tags`` metadata, as is standard in
|
be specified either via the ``tags`` metadata, as is standard in Pelican, or
|
||||||
Pelican, or with the ``keywords`` metadata, as is standard in HTML. The two can
|
via the ``keywords`` metadata, as is standard in HTML. The two can be used
|
||||||
be used interchangeably.
|
interchangeably.
|
||||||
|
|
||||||
Note that, aside from the title, none of this metadata is mandatory: if the date
|
Note that, aside from the title, none of this article metadata is mandatory:
|
||||||
is not specified and DEFAULT_DATE is 'fs', Pelican will rely on the file's
|
if the date is not specified and ``DEFAULT_DATE`` is set to ``fs``, Pelican
|
||||||
"mtime" timestamp, and the category can be determined by the directory in which
|
will rely on the file's "mtime" timestamp, and the category can be determined
|
||||||
the file resides. For example, a file located at ``python/foobar/myfoobar.rst``
|
by the directory in which the file resides. For example, a file located at
|
||||||
will have a category of ``foobar``. If you would like to organize your files in
|
``python/foobar/myfoobar.rst`` will have a category of ``foobar``. If you would
|
||||||
other ways where the name of the subfolder would not be a good category name,
|
like to organize your files in other ways where the name of the subfolder would
|
||||||
you can set the setting ``USE_FOLDER_AS_CATEGORY`` to ``False``.
|
not be a good category name, you can set the setting ``USE_FOLDER_AS_CATEGORY``
|
||||||
|
to ``False``.
|
||||||
|
|
||||||
If there is no summary metadata for a given post, the ``SUMMARY_MAX_LENGTH``
|
If you do not explicitly specify summary metadata for a given post, the
|
||||||
setting can be used to specify how many words from the beginning of an article
|
``SUMMARY_MAX_LENGTH`` setting can be used to specify how many words from the
|
||||||
are used as the summary. Summaries can also be specified inline with the body
|
beginning of an article are used as the summary.
|
||||||
using the :ref:`Summary Plugin <plugin-summary>`.
|
|
||||||
|
|
||||||
You can also extract any metadata from the filename through a regular
|
You can also extract any metadata from the filename through a regular
|
||||||
expression to be set in the ``FILENAME_METADATA`` setting.
|
expression to be set in the ``FILENAME_METADATA`` setting. All named groups
|
||||||
All named groups that are matched will be set in the metadata object. The
|
that are matched will be set in the metadata object. The default value for the
|
||||||
default value for the ``FILENAME_METADATA`` setting will only extract the date
|
``FILENAME_METADATA`` setting will only extract the date from the filename. For
|
||||||
from the filename. For example, if you would like to extract both the date and
|
example, if you would like to extract both the date and the slug, you could set
|
||||||
the slug, you could set something like:
|
something like: ``'(?P<date>\d{4}-\d{2}-\d{2})_(?P<slug>.*)'``
|
||||||
``'(?P<date>\d{4}-\d{2}-\d{2})_(?P<slug>.*)'``
|
|
||||||
|
|
||||||
Please note that the metadata available inside your files takes precedence over
|
Please note that the metadata available inside your files takes precedence over
|
||||||
the metadata extracted from the filename.
|
the metadata extracted from the filename.
|
||||||
|
|
||||||
Generate your blog
|
|
||||||
------------------
|
|
||||||
|
|
||||||
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::
|
|
||||||
|
|
||||||
$ pelican /path/to/your/content/ [-s path/to/your/settings.py]
|
|
||||||
|
|
||||||
The above command will generate your weblog and save it in the ``output/``
|
|
||||||
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.
|
|
||||||
|
|
||||||
Pelican has other command-line switches available. Have a look at the help to
|
|
||||||
see all the options you can use::
|
|
||||||
|
|
||||||
$ pelican --help
|
|
||||||
|
|
||||||
Auto-reload
|
|
||||||
-----------
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
Pages
|
Pages
|
||||||
-----
|
-----
|
||||||
|
|
||||||
|
|
@ -303,6 +327,7 @@ following syntax: ``|filename|path/to/file``::
|
||||||
│ ├── cat/
|
│ ├── cat/
|
||||||
│ │ └── article2.md
|
│ │ └── article2.md
|
||||||
│ └── pages
|
│ └── pages
|
||||||
|
│ └── about.md
|
||||||
└── pelican.conf.py
|
└── pelican.conf.py
|
||||||
|
|
||||||
In this example, ``article1.rst`` could look like::
|
In this example, ``article1.rst`` could look like::
|
||||||
|
|
@ -444,19 +469,4 @@ 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
|
metadata. That article will then be output to the ``drafts`` folder and not
|
||||||
listed on the index page nor on any category page.
|
listed on the index page nor on any category page.
|
||||||
|
|
||||||
Viewing the generated files
|
|
||||||
---------------------------
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
.. _virtualenv: http://www.virtualenv.org/
|
.. _virtualenv: http://www.virtualenv.org/
|
||||||
.. _virtualenvwrapper: http://www.doughellmann.com/projects/virtualenvwrapper/
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue