git clone https://github.com/getpelican/pelican.git
cd pelican
python setup.py install
pelican-quickstart (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)
as3:~/pelican# pelican-quickstart
Welcome to pelican-quickstart v3.3.1.dev.
This script will help you create a new Pelican-based website.
Please answer the following questions so this script can generate the files
needed by Pelican.
> Where do you want to create your new web site? [.] ./pelican-site
> What will be the title of this web site? ym's pelican blog
> Who will be the author of this web site? ym
> What will be the default language of this web site? [en]
> Do you want to specify a URL prefix? e.g., http://example.com (Y/n) y
> What is your URL prefix? (see above example; no trailing slash) http://plc.brite.biz
> Do you want to enable article pagination? (Y/n) y
> How many articles per page do you want? [10]
> Do you want to generate a Fabfile/Makefile to automate generation and publishing? (Y/n) y
> Do you want an auto-reload & simpleHTTP script to assist with theme and site development? (Y/n)
y
> Do you want to upload your website using FTP? (y/N) n
> Do you want to upload your website using SSH? (y/N) y
> What is the hostname of your SSH server? [localhost] as3.brite.biz
> What is the port of your SSH server? [xx]
> What is your username on that server? [root]
> Where do you want to put your web site on that server? [/var/www] /var/www/pelican
> Do you want to upload your website using Dropbox? (y/N) n
> Do you want to upload your website using S3? (y/N) n
> Do you want to upload your website using Rackspace Cloud Files? (y/N) n
Done. Your new project is available at /root/pelican/pelican-site
as3:~/pelican# cd /root/pelican/pelican-site
as3:~/pelican/pelican-site# ls
content fabfile.py output publishconf.py
develop_server.sh Makefile pelicanconf.py
as3:~/pelican/pelican-site# cd content
as3:~/pelican/pelican-site/content# pip install markdown
as3:~/pelican/pelican-site/content# nano my-super-post.md
格式如下:
Title: 我的超级帖子
Date: 2010-12-03 10:20
Category: Python
Tags: pelican, publishing
Slug: my-super-post
Author: ym
Summary: Short version for index and feeds (此行不要删除)
This is the content of my super blog post. (此处写正文或html code)
然后:
as3:~/pelican/pelican-site/content# cd ..
as3:~/pelican/pelican-site# pelican content (这个就是生成/更新静态网站的命令)
as3:~/pelican/pelican-site# cd output
as3:~/pelican/pelican-site/output# ls
archives.html categories.html fengyuwuzu.html tag test2.html
author category index.html tags.html theme
authors.html chinese-economy.html my-super-post.html test1.html
as3:~/pelican/pelican-site/output# Rwebserver 65208 &
可见~/pelican/pelican-site/output/就是静态网站的根目录。可绑定域名到该目录。
演示站点:http://plc.brite.biz,http://as3.brite.biz:65208/
项目地址:https://github.com/getpelican/pelican
使用指南: http://docs.getpelican.com/en/3.3.0/getting_started.html
此程序还支持从其他博客程序导入内容:http://docs.getpelican.com/en/3.3.0/importer.html#import
我是在python2.7环境下搭建成功的。在python2.6环境下不行。
----------------------------------------------
migrate wordpress blog to static site:pelican
I have just finished migrating my long-neglected blog from a self-hosted Wordpress installation on my own VPS to a static site hosted on the Amazon S3 storage service using its website hosting feature.
This post captures the main steps involved, in case anyone else is interested in doing the same thing.
However, I have never been very happy relying on the PHP-based Wordpress app due to the frequent security updates it requires and my gut-level distrust of PHP itself. I know it well enough not to trust it, especially when my blog can lie neglected for months at a time when I'm busy. It made me nervous knowing I could be one tardy security-update away from a hacked site and server.
Besides, this blog is small enough that any powerful blogging system is overkill for my needs.
But even a simple blog like this is far too complex to hand-code all the HTML and other files necessary to show do things like display a post, list all posts, provide RSS/Atom syndication feeds for blog reader software, provide sitemap XML files for Google, etc. etc. So I need a middle ground: a static site generator.
At this stage it's worth saying explicitly that using static site generators, while "simpler" from a web-server point of view, requires much more knowledge about how web sites work and how to host them. As the rest of this post will make clear, generating and hosting your own static site is an involved and deeply nerdy process best suited to people who are web programmers, or interested in becoming one.
I chose Pelican for my blog because:
After installation I ran the
Be warned though: the generated scripts have their own copies of configuration settings you choose while running the quickstart, so if you subsequently change your Pelican configuration files and run these scripts your config changes will have no effect. I found this annoying enough that I ended up removing the helper scripts and use the explicit Pelican commands instead.
Unfortunately I found the conversion process was imperfect so I needed to look closely at many of the post files to check for quirks and then fix these issues across all posts.
I also decided to use Tag instead of Category groupings for my posts, which I should have done from the very beginning in Wordpress, but changing this was straight-forward with some global find-and-replace changes in the markdown files.
If you wish to allow comments on your static site you will need to use a javascript-based commenting system, such as the one provided by Disqus.
I am using Disqus on the now-static site, as you will see if you view or leave comments below. It was quite easy to set this up: I created an account on the service, added my site details, and set the
Because I also wanted to keep the comments from my existing Wordpress blog site I also exported these comments by:
You can now look directly at the generated files in the
In my case I wanted the new static site to replace the original Wordpress one without breaking all the links, because Cool URIs don't change. To do this I configured Pelican very carefully to generate URL paths matching the datestamp + slug format I used in Wordpress, for example:
I also customised where RSS/Atom feeds are saved, whether pages are displayed,
and other things. Check out the Pelican documentation to see what you can do.
It was pretty easy to do this by following the Pelican theming documentation and stealing ideas and code snippets from the example themes available in Pelican Themes Github repository.
One particularly cool thing I will mention is how to use the excellent Solarized colour themes for code snippets, so at least that part of my blog isn't ugly. Generate the necessary CSS files like so:
You can then add these CSS files to your template to get solarized code
highlighting in your posts.
Note: I found I had to set the overall background colour to get things to look right, here's what I did:
To use the plugins I added the pelican-plugins codebase to my project directory:
Then configured Pelican to find and use the relevant plugins:
With it's relatively recently-added support for website hosting, the Amazon S3 storage service made an attractive choice. It's pretty simple, extremely reliable, fairly priced, and I'm very familiar with it.
The process for setting this up was made a bit complex because I had some extra requirements:
In my case the
The necessary steps are covered in detail in Amazon's website hosting instructions, but in brief here's what I did to set up the domain-to-bucket mappings:
Once you are happy that the Route 53 settings are correct, set up (or switch over) the nameservers at your domain name registrar to point to the Delegation Set endpoints you noted above.
Before long, your domain names should resolve to the appropriate S3 buckets and your static site should be available.
from http://jamesmurty.com/2013/05/23/migrate-wordpress-blog-to-static-site/
----------------------------------------
install pelican static blog
I always recommend using
Once you have set up your virtual environment, the cool part begins. Just run the
That's going to create the project layout, putting each blogpost markdown file in the
And well, of course you want to check how the blog is looking like:
First of all, I wanted to set DISQUS as external comment system:
I also wanted to arrange the post urls by date, for handling
I activated the feeds for all the posts, categories and tags:
I also had some static pages that were not going to be generated by
Pelican, so it has to know that we want to parse them as well:
Finally, I decided to implement my own theme, using Twitter Bootstrap. Pelican will check in different places for a folder match, and then it will parse the content from that theme folder:
A way of doing this, is to create a folder with your theme name, as it is defined in the
I copied simple theme template files into my
Now, you are on your own. You should keep in mind that there are several template variables that you have to use, but that's it.
However, I found several problems when I wanted to display the blog archives by year and month, and Pelican's documentation is not really clear about that subject. Using Jinja2
Save the file, run
from http://thesoftjaguar.com/posts/2013/04/06/pelican-static-blog/
-----------------------
https://github.com/jhamon/jhamon.github.com
------------------------------
Then:
Point the
By default the
FROM https://github.com/DandyDev/pelican-bootstrap3
---------------------------
一个基于python3.3.x+pelican的静态博客程序
cd pelican
python setup.py install
pelican-quickstart (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)
as3:~/pelican# pelican-quickstart
Welcome to pelican-quickstart v3.3.1.dev.
This script will help you create a new Pelican-based website.
Please answer the following questions so this script can generate the files
needed by Pelican.
> Where do you want to create your new web site? [.] ./pelican-site
> What will be the title of this web site? ym's pelican blog
> Who will be the author of this web site? ym
> What will be the default language of this web site? [en]
> Do you want to specify a URL prefix? e.g., http://example.com (Y/n) y
> What is your URL prefix? (see above example; no trailing slash) http://plc.brite.biz
> Do you want to enable article pagination? (Y/n) y
> How many articles per page do you want? [10]
> Do you want to generate a Fabfile/Makefile to automate generation and publishing? (Y/n) y
> Do you want an auto-reload & simpleHTTP script to assist with theme and site development? (Y/n)
y
> Do you want to upload your website using FTP? (y/N) n
> Do you want to upload your website using SSH? (y/N) y
> What is the hostname of your SSH server? [localhost] as3.brite.biz
> What is the port of your SSH server? [xx]
> What is your username on that server? [root]
> Where do you want to put your web site on that server? [/var/www] /var/www/pelican
> Do you want to upload your website using Dropbox? (y/N) n
> Do you want to upload your website using S3? (y/N) n
> Do you want to upload your website using Rackspace Cloud Files? (y/N) n
Done. Your new project is available at /root/pelican/pelican-site
as3:~/pelican# cd /root/pelican/pelican-site
as3:~/pelican/pelican-site# ls
content fabfile.py output publishconf.py
develop_server.sh Makefile pelicanconf.py
as3:~/pelican/pelican-site# cd content
as3:~/pelican/pelican-site/content# pip install markdown
as3:~/pelican/pelican-site/content# nano my-super-post.md
格式如下:
Title: 我的超级帖子
Date: 2010-12-03 10:20
Category: Python
Tags: pelican, publishing
Slug: my-super-post
Author: ym
Summary: Short version for index and feeds (此行不要删除)
This is the content of my super blog post. (此处写正文或html code)
然后:
as3:~/pelican/pelican-site/content# cd ..
as3:~/pelican/pelican-site# pelican content (这个就是生成/更新静态网站的命令)
as3:~/pelican/pelican-site# cd output
as3:~/pelican/pelican-site/output# ls
archives.html categories.html fengyuwuzu.html tag test2.html
author category index.html tags.html theme
authors.html chinese-economy.html my-super-post.html test1.html
as3:~/pelican/pelican-site/output# Rwebserver 65208 &
可见~/pelican/pelican-site/output/就是静态网站的根目录。可绑定域名到该目录。
演示站点:http://plc.brite.biz,http://as3.brite.biz:65208/
项目地址:https://github.com/getpelican/pelican
使用指南: http://docs.getpelican.com/en/3.3.0/getting_started.html
此程序还支持从其他博客程序导入内容:http://docs.getpelican.com/en/3.3.0/importer.html#import
我是在python2.7环境下搭建成功的。在python2.6环境下不行。
----------------------------------------------
migrate wordpress blog to static site:pelican
I have just finished migrating my long-neglected blog from a self-hosted Wordpress installation on my own VPS to a static site hosted on the Amazon S3 storage service using its website hosting feature.
This post captures the main steps involved, in case anyone else is interested in doing the same thing.
Why Migrate from Wordpress?
My blog has run well enough on a self-hosted Wordpress set-up for years, first at a cheap site hosting company (where performance was terrible) then on my own Linode VPS server (where performance has been great).However, I have never been very happy relying on the PHP-based Wordpress app due to the frequent security updates it requires and my gut-level distrust of PHP itself. I know it well enough not to trust it, especially when my blog can lie neglected for months at a time when I'm busy. It made me nervous knowing I could be one tardy security-update away from a hacked site and server.
Besides, this blog is small enough that any powerful blogging system is overkill for my needs.
Static Site Generation
Because my blog is simple, it is a perfect candidate to be served as a static site instead of a dynamically-generated one. Instead of Wordpress and PHP code running on my server to generate HTML pages when someone lands on a page, why not just serve HTML pages directly? This is about as simple as it can get.But even a simple blog like this is far too complex to hand-code all the HTML and other files necessary to show do things like display a post, list all posts, provide RSS/Atom syndication feeds for blog reader software, provide sitemap XML files for Google, etc. etc. So I need a middle ground: a static site generator.
At this stage it's worth saying explicitly that using static site generators, while "simpler" from a web-server point of view, requires much more knowledge about how web sites work and how to host them. As the rest of this post will make clear, generating and hosting your own static site is an involved and deeply nerdy process best suited to people who are web programmers, or interested in becoming one.
Pelican
There are roughly fourteen bazillion site generator projects around, with the number growing constantly.I chose Pelican for my blog because:
- It seems relatively well-established and mature in the field.
- It allows posts to be written in Markdown (or other human-friendly markup languages)
- It's written in Python, a language I like and that I can easily hack on if I want to contribute fixes or improvements to the project.
- It has plugins that do things like generating sitemap files and other niceties that would be tedious to build myself.
# Pelican pre 3.3 code version, with slug and pages import improvements
pip install -e git+git@github.com:jmurty/pelican.git@675d6c81#egg=pelican-dev
# Markdown for migrating and authoring posts in this markup language
pip install Markdown==2.3.1
# BeautifulSoup is required to migrate Wordpress posts
pip install BeautifulSoup
pelican-quickstart
command to create initial
configuration files and some helper scripts.Be warned though: the generated scripts have their own copies of configuration settings you choose while running the quickstart, so if you subsequently change your Pelican configuration files and run these scripts your config changes will have no effect. I found this annoying enough that I ended up removing the helper scripts and use the explicit Pelican commands instead.
Migrate Data from Wordpress
Migrate Your Posts
Migrating my existing Wordpress blog posts was only somewhat difficult and fiddly, to be honest it was easier than I expected:- Manually install the additional Pandoc universal document converter tool per the Pelican Import documentation.
- Export and download your Wordpress posts and comments
as an XML file. I saved this file as
site.wordpress.xml
-
Run the
pelican-import
command to convert the Wordpress posts into Markdown-formatted files written to thecontent
directory:
pelican-import --wpfile --dir-page \ --output content -markup markdown \ site.wordpress.xml
Title
and
Slug
capture important information about the original posts.Unfortunately I found the conversion process was imperfect so I needed to look closely at many of the post files to check for quirks and then fix these issues across all posts.
I also decided to use Tag instead of Category groupings for my posts, which I should have done from the very beginning in Wordpress, but changing this was straight-forward with some global find-and-replace changes in the markdown files.
Migrate Your Comments
One drawback of static sites is that there is no way to do server-side processing of comments submitted by site visitors. At least, not without defeating the point of making your site static in the first place.If you wish to allow comments on your static site you will need to use a javascript-based commenting system, such as the one provided by Disqus.
I am using Disqus on the now-static site, as you will see if you view or leave comments below. It was quite easy to set this up: I created an account on the service, added my site details, and set the
DISQUS_SITENAME
setting in
Pelican's publishconf.py
configuration file.Because I also wanted to keep the comments from my existing Wordpress blog site I also exported these comments by:
- installing the Disqus Comment System plugin on my Wordpress site.
- configuring my new Disqus site account in the plugin
- exporting the comments from Wordpress to Disqus via the Export Comments button.
- monitoring progress of the export on the Disqus dashboard.
Generate the Static Site HTML
Now that your content is in place you can generate a static site to check how it all looks. Here is the command to convert the markdown files incontent/
to static files to the html/
directory:# Add --debug flag to see exactly what is happening
pelican content/ -o html -s pelicanconf.py --delete-output-directory
html/
directory, or
run Pelican in server mode so you can view your blog in a web browser at
http://localhost:8000/ using the develop_server.sh
helper
script generated by the "quickstart" process, or with the following explicit
commands:# Run Python's built-in web server on html/ as a background job
cd html/
python -m SimpleHTTPServer &
Customise the Generated Site Layout
Once you can view the generated site in a browser you can customise a number of things in yourpelicanconf.py
configuration file to make the site work
exactly the way you want.In my case I wanted the new static site to replace the original Wordpress one without breaking all the links, because Cool URIs don't change. To do this I configured Pelican very carefully to generate URL paths matching the datestamp + slug format I used in Wordpress, for example:
# Post/Article URL links have clean paths with date stamp + slug ...
ARTICLE_URL = '{date:%Y}/{date:%m}/{date:%d}/{slug}/'
# ... while the file is index.html to be auto-served from the dir location
ARTICLE_SAVE_AS = '{date:%Y}/{date:%m}/{date:%d}/{slug}/index.html'
Theme
I created my own theme for the blog. You can tell because it's very simple, and very ugly (I'm no designer).It was pretty easy to do this by following the Pelican theming documentation and stealing ideas and code snippets from the example themes available in Pelican Themes Github repository.
One particularly cool thing I will mention is how to use the excellent Solarized colour themes for code snippets, so at least that part of my blog isn't ugly. Generate the necessary CSS files like so:
# Install Pygments and solarized style
pip install Pygments pygments-style-solarized
# Generate CSS files of light and dark solarized colours
pygmentize -S solarizeddark -f html > solarizeddark.css
pygmentize -S solarizedlight -f html > solarizedlight.css
Note: I found I had to set the overall background colour to get things to look right, here's what I did:
/* Add this line to the top of solarizedlight.css */
pre { background: #fdf6e3; }
/* Add this line to the top of solarizeddark.css */
pre { background: #002b36 }
Pelican Plugins
The final Pelican-related tweaks I made were to add some existing plugins to do useful work like generate asitemap.xml
file and make extra information
available to help with site navigation, such as lists of next/previous and
related posts.To use the plugins I added the pelican-plugins codebase to my project directory:
git submodule add https://github.com/getpelican/pelican-plugins
git submodule update --init
PLUGIN_PATH = 'pelican-plugins'
PLUGINS = ['sitemap', 'neighbors', 'related_posts']
SITEMAP = {
'format': 'xml',
'changefreqs': {
'pages': 'daily',
}
}
Site Hosting with Amazon S3 in Website Hosting Mode
With a static blog site instead of a dynamic one, it was no longer necessary to host it on my VPS server. By moving the site entirely to a static-file-serving platform I could free up my VPS to the testing-ground I had originally intended.With it's relatively recently-added support for website hosting, the Amazon S3 storage service made an attractive choice. It's pretty simple, extremely reliable, fairly priced, and I'm very familiar with it.
The process for setting this up was made a bit complex because I had some extra requirements:
- My blog should be accessible at both the jamesmurty.com root domain and the www.jamesmurty.com subdomain.
- The old RSS feed endpoint at http://www.jamesmurty.com/feed/ shouldn't change, so that subscribers continue receiving my blog posts (like this one).
Generate Site for Publishing
By default the Pelican quickstart process produces two configuration files,pelicanconf.py
and publishconf.py
. The former stores most of your settings
and is intended for use when developing or testing your site, while the latter
contains settings useful only for the published site.In my case the
publishconf.py
file has two extra settings:- Relative URLs are disabled, to ensure in-post links work properly when read in an RSS feed reader.
- Disqus is configured to handle comments.
-s
switch to the pelican command. For example:pelican content/ -o html -s publishconf.py --debug
Set Up S3 Buckets
Here are the steps I took to set up S3 hosting (using the S3 console website):- Create S3 bucket names corresponding to my site's domain names:
jamesmurty.com
andwww.jamesmurty.com
- Upload the generated site files in the
html/
directory to the bucketjamesmurty.com
. I used my Synchronize application, but any S3-compatible file copying program will do. - Visit the bucket's exact Endpoint URL as shown in the Static Website Hosting properties area to make sure everything looks and works properly.
www.jamesmurty.com
root domain bucket to redirect requests
to the authoritative jamesmurty.com
bucket:- Edit the bucket Properties and open the Static Website Hosting section.
- Select Redirect all requests to another host name
- Enter the root domain:
jamesmurty.com
/feed/
as the RSS feed endpoint, I also needed
to make this URL path point to the new RSS feed location /feeds/rss.xml
. This
was easy enough to do with a custom routing rule specified with the following
XML snippet in the Edit Redirection Rules section of the Enable Web Hosting
properties:<RoutingRules>
<RoutingRule>
<Condition>
<KeyPrefixEquals>feed/</KeyPrefixEquals>
</Condition>
<Redirect>
<ReplaceKeyWith>feeds/rss.xml</ReplaceKeyWith>
</Redirect>
</RoutingRule>
</RoutingRules>
Set Up DNS using Amazon Route 53
To serve websites from S3 using a root domain, such as a domain without a leading subdomain prefix likewww
or blog
, you must use
Amazon Route 53 as a DNS server for the site. Unfortunately this
adds to the complexity and cost of S3-hosted websites, but I decided it is
worth the hassle.The necessary steps are covered in detail in Amazon's website hosting instructions, but in brief here's what I did to set up the domain-to-bucket mappings:
- Create a hosted zone for your domain in Route 53
- Note the nameservers assigned to that hosted zone (called Delegation Set in Amazon's console)
- Create a record set for the hosted zone
- Add an A record alias (Type: A, Alias: Yes) to the record set to map my
root domain
jamesmurty.com
to the Amazon URL for the authoritative S3 bucket, in my casejamesmurty.com.s3-website-us-east-1.amazonaws.com
.
The target bucket should be selectable in the Alias Target drop down list. - Add a CNAME record to the record set to map the
www.jamesmurty.com
subdomain to the root domainjamesmurty.com
.
Once you are happy that the Route 53 settings are correct, set up (or switch over) the nameservers at your domain name registrar to point to the Delegation Set endpoints you noted above.
Before long, your domain names should resolve to the appropriate S3 buckets and your static site should be available.
from http://jamesmurty.com/2013/05/23/migrate-wordpress-blog-to-static-site/
----------------------------------------
install pelican static blog
I always recommend using
virtualenv
and virtualenvwrapper
, and then install the required pip
packages inside the virtual environment. In this case I am using markdown
as a markup format for my blog post, so I am installing it as well:$ mkvirtualenv my-pelican-blog -a ~/my-pelican-blog-project-folder
$ pip install -r pelican markdown
pelican-quickstart
command, and answer each question:$ pelican-quickstart
content
folder. Running the following command will generate the static HTML files with Pelican's simple theme:$ make html
$ make serve
Defining Pelican settings
Now you will see two new files,pelicanconf.py
and publishconf.py
. They are settings files, filled with the answers that you gave running pelican-quickstart
. In my specific case, I tuned them up a bit, for matching my personal requirements.First of all, I wanted to set DISQUS as external comment system:
DISQUS_SITENAME = "thesoftjaguar"
archives
later:# Urls
ARTICLE_URL = 'posts/{date:%Y}/{date:%m}/{date:%d}/{slug}/'
ARTICLE_SAVE_AS = 'posts/{date:%Y}/{date:%m}/{date:%d}/{slug}/index.html'
YEAR_ARCHIVE_SAVE_AS = 'posts/{date:%Y}/index.html'
MONTH_ARCHIVE_SAVE_AS = 'posts/{date:%Y}/{date:%m}/index.html'
# Feeds
FEED_ALL_ATOM = 'feeds/all.atom.xml'
FEED_ALL_RSS = 'feeds/all.rss.xml'
CATEGORY_FEED_ATOM = 'feeds/%s.atom.xml'
CATEGORY_FEED_RSS = 'feeds/%s.rss.xml'
TAG_FEED_ATOM = 'feeds/%s.atom.xml'
TAG_FEED_RSS = 'feeds/%s.rss.xml'
TEMPLATE_PAGES = {
'projects.html': 'projects.html',
}
THEME = 'bootstrap-theme'
Creating your own theme
If you want some extra customization (like I do), you will create your own theme. Pelican themes are quite cool, but I already had a really basic page using Twitter bootstrap and I wanted to adapt my old Django blog to that style.A way of doing this, is to create a folder with your theme name, as it is defined in the
THEME
setting parameter. In my case I called my theme bootstrap-theme
, with two other folders: static
and templates
. Pelican is requiring a specific folder structure.I copied simple theme template files into my
templates
folder, and I editted them. In addition, there is a cool feature in
Pelican 3: if it doesn't find a required template file, it will inherit
it from the simple
theme, so you don't need to store uneditted simple theme files in your custom theme.Now, you are on your own. You should keep in mind that there are several template variables that you have to use, but that's it.
However, I found several problems when I wanted to display the blog archives by year and month, and Pelican's documentation is not really clear about that subject. Using Jinja2
groupby
filter was my way of solving the problem:<h1 class="page-title">Archive</h1>
<ul>
{% for year, year_articles in articles|groupby('date.year') %}
<li><h2>{{ year }}</h2></li>
{% for month, month_articles in year_articles|groupby('date.month') %}
<ul>
<li><h4>{{ month_articles[0].date.strftime('%B') }}</h4></li>
{% for article in month_articles %}
<div class="entry-archive">
<div class="date">
{{ article.date.strftime('%A %d') }}
</div>
<div class="detail">
<a href="{{ SITEURL }}/{{ article.url }}" rel="bookmark" title="Permalink to {{ article.title|striptags }}">{{ article.title }}</a>
</div>
</div>
{% endfor %}
</ul>
{% endfor %}
{% endfor %}
</ul>
Writing your first article
Just create a.md
file in the content
folder, and write the metadata, followed by the actual Markdown formatted text:Title: Migrating to a Pelican static blog
Date: 2013-04-06 02:24
Tags: static-blog, markdown, pelican, python, web-development, git, django
Category: programming
Slug: pelican-static-blog
Summary: How did I migrate my Django blog to a static one, using Pelican.
This is the content of my blog post. I should use Markdown here.
make html
, and that's it.from http://thesoftjaguar.com/posts/2013/04/06/pelican-static-blog/
-----------------------
https://github.com/jhamon/jhamon.github.com
------------------------------
pelican-bootstrap3
This is a Bootstrap 3 theme for Pelican. It's fully responsive. Bootstrap 3 has seen an official, final release now, so I don't expect any breaking changes anymore. I will try to keep it up-to-date.CONTRIBUTING
If you want to adjust this theme to your own liking, I encourage you to fork it. This theme has started to gather more and more attention in the form of stars and forks. If you make improvements that are useful to others and can make the theme better in general please don't hesitate to make a pull request. For contributing guidelines, look hereInstallation
First:git clone https://github.com/DandyDev/pelican-bootstrap3.git
Then:
Point the
THEME
variable in your pelicanconf.py
to /path/to/pelican-bootstrap3
Usage
This theme honors the following standard Pelican settings:- Putting feeds in the
<head>
section:FEED_ALL_ATOM
FEED_ALL_RSS
- Template settings:
DISPLAY_PAGES_ON_MENU
DISPLAY_CATEGORIES_ON_MENU
MENUITEMS
-
LINKS
(Blogroll will be put in the sidebar instead of the head)
- Analytics & Comments
-
GOOGLE_ANALYTICS
(classic tracking code) -
GOOGLE_ANALYTICS_UNIVERSAL
andGOOGLE_ANALYTICS_UNIVERSAL_PROPERTY
(Universal tracking code) DISQUS_SITENAME
-
PIWIK_URL
,PIWIK_SSL_URL
andPIWIK_SITE_ID
-
tag_cloud
variable for displaying tags in the sidebar. You can control the amount of tags shown with: TAG_CLOUD_MAX_ITEMS
Extras
Bootswatch and other Bootstrap 3 themes
Part of the versatility of this theme comes from the fact that I included all the lovely Bootstrap 3 themes from Bootswatch, built by Thomas Park. You can tell Pelican what Bootswatch theme to use, by settingBOOTSTRAP_THEME
to the desired theme, in lowercase (ie. 'readable' or 'cosmo' etc.). My own site is using Simplex. If you want to use any other Bootstrap 3 compatible theme, just put the minified CSS in the static/css
directory and rename it using the following naming scheme: bootstrap.{theme-name}.min.css
. Then update the BOOTSTRAP_THEME
variable with the theme-name used.Article info
SetSHOW_ARTICLE_AUTHOR
to True to show the author of the article at the top of the article and in the index of articles. Set SHOW_ARTICLE_CATEGORY
to show the Category of each article. Set SHOW_DATE_MODIFIED
to True to show the article modified date next to the published date.Custom CSS
If you want to add custom css to the theme, without having to clone and maintain your own version of the theme, you can use theCUSTOM_CSS
variable. The value is the location where you tell Pelican to put the file (see below):CUSTOM_CSS = 'static/custom.css'
To tell Pelican to copy the relevant file to the desired destination, add the path to STATIC_PATHS
and the destination to EXTRA_PATH_METADATA
, like so:# Tell Pelican to add 'extra/custom.css' to the output dir
STATIC_PATHS = ['images', 'extra/custom.css']
# Tell Pelican to change the path to 'static/custom.css' in the output dir
EXTRA_PATH_METADATA = {
'extra/custom.css': {'path': 'static/custom.css'}
}
Pygments
You can choose the syntax highlighting style by using thePYGMENTS_STYLE
variable to specify one of the built-in Pygments styles. By default the native
style is used. The following styles are avaiable:- autumn
- borland
- bw
- colorful
- default
- emacs
- friendly
- fruity
- manni
- monokai
- murphy
- native
- pastie
- perldoc
- solarizeddark
- solarizedlight
- tango
- trac
- vim
- vs
- zenburn
Pagination
Pelican-Bootstrap3 follows the standard Pagination settings of Pelican and uses the Bootstrap3 Pagination component, but you can optionally use the Boostrap3 Pager by settingUSE_PAGER
to True
.Bootstrap fluid layout
If you'd like to use the fluid container layout from Bootstrap, set the flagBOOTSTRAP_FLUID
to True.Site Brand
You can provide a logo for your site usingSITELOGO
. For example: SITELOGO = 'images/my_site_logo.png'
. You can then define the size of the logo using SITELOGO_SIZE
. The width
of the <img>
element will be set accordingly.By default the
SITENAME
will be shown as well. It's also possible to hide the site name using the HIDE_SITENAME
flag.Breadcrumbs
It's possible to show breadcrumbs in your site using theDISPLAY_BREADCRUMBS
flag. By default the article category isn't shown in the breadcrumbs, if you wish to enable it, set the DISPLAY_CATEGORY_IN_BREADCRUMBS
flag to True.Navbar
If you wish to use the inverse navbar from Bootstrap, set the flagBOOTSTRAP_NAVBAR_INVERSE
to True.Related Posts
This theme has support for the Related Posts plugin. All you have to do, is enable the plugin, and the theme will do the rest.IPython Notebook support
This theme supports including IPython notebooks through the Liquid Tags plugin. If you enable the plugin, the theme will automatically include the right CSS/JS to make the notebooks work.Favicon
Set theFAVICON
option in your pelicanconf.py
. For example: FAVICON = 'images/favicon.png'
Index page
- If
DISPLAY_ARTICLE_INFO_ON_INDEX
is set to True, article info (date, tags) will be show under the title for each article, otherwise only title and summary will be shown (default).
Short menu labels for pages
By default, the title of a page is used both for showing the title as part of a page's content, and, if pages in menu is enabled, as the label of the corresponding menu item. You can choose a different label for the menu (such as a short single word) than the page title by adding a Menulabel metadata attribute to the page header (Menulabel:
in
markdown, :Menulabel:
in rst).FROM https://github.com/DandyDev/pelican-bootstrap3
---------------------------
一个基于python3.3.x+pelican的静态博客程序
Dependences
- Python 3.3.x
- Pelican
Running
$ virtualenv .venv
$ . .venv/bin/activate
$ pip install -r requirements.pip
$ make html
$ make serve
Then the blog is generated and can be previewed in http://localhost:8000/.
from https://github.com/zonyitoo/blog
--------------------
https://github.com/mattmakai/mattmakai.com/tree/gh-pages/source
https://github.com/mattmakai/mattmakai.com/blob/gh-pages/source/Makefile
--------------------
https://github.com/mattmakai/mattmakai.com/tree/gh-pages/source
https://github.com/mattmakai/mattmakai.com/blob/gh-pages/source/Makefile