pino.py or how I generate my blog
No I’m not dead, just playin’ Diablo 3.
Anyway, as mentioned before my blog was made using Stacey, but I wanted something fully static to ditch PHP for good.
So I decided to code my own blog generator using Python. I usually don’t like scripting languages, but I wanted to take a look at Python for a while now, and I must say it’s the first scripting language that I like.
So here it is, pino.py my python script that generates a fully static HTML blog.
OK great, how does it work ?
The structure looks like this :
- _pino_config.json – Configuration file.
- _pino_internal.py – Contains internal functions, nothing to change here except if you want to fork the project and roll your own implementation.
- htaccess – If you want a .htaccess file, it will be copied.
- pages/ – Contains one HTML file per static page. If you have a file named about.html, the URL for your site will be http://site.com/about.
- pino.py – Script to call to generate the blog.
- posts/ – Directory that contains all the blog posts, the following structure must be respected :
- Year/ (ex: 2012) – Directory containing subdirectories for each month
- Month/ (ex: 03) - All posts for this month
- day.url-title/ (ex: 07.my-super-awesome-post) – Directory for a post
- _attr.json – The post attributes, such as title, date, description, keywords
- _post.html – The post content written in HTML
- various resources – All resources needed for this post (images etc…)
- styles/ – Contains the CSS, JS and static resources needed.
- templates/ – Contains the HTML templates for the index page, the 404 page and the posts pages.
Building the entire blog is freakin’ easy, once the configuration file is set, just call pino.py and you are done.
The output directory containing the blog will be where you set it in the config file, and will look like this :
- 404.html – The custom 404 error page.
- Year (ex: 2012) – Directory containing subdirectories for each month.
- Month (ex: 03) – Directory containing all post of this month
- url part (ex: my-super-awesome-post) – A post directory
- index.html – The post itself
- various resources – All the resources for this post
- feed/feed.rss – The rss feed.
- index.html – The index page.
- styles/ – All your styles etc…
- Static page/index.html (ex: about/index.html) – A static page.
All right, now all you need to do is upload it to your server, but that’s not my problem.