Create a static blog, the miracle solution

- Article en français

These days, many of us have a blog and some of us run more than one. Whether you're going on holiday, have a new project in mind or want to talk about a particular subject a blog is the way to express yourself. On specialised platforms, it's usually fast and free. The problem is that your information no longer belongs to you; you have no control over it, there's advertising and it's difficult to personalise.

Self-host a blog?

We see more and more people doing the opposite to what they have done in previous years; they return to Wordpress on a shared hosting site on a virtual/dedicated server (because Wordpress uses a lot of resources) Therefore, we realise that a blog engine like Wordpress (or similar) provides more than necessary. That is true for most - what do we need on a blog? A place to write content and sometimes comments.

So why not a simple, static site (or blog) to do business? There's no need for anything else other than simple HTML pages. It's light, easy to access for visitors and doesn't need to generate dynamic content at each request. As a bonus, static files cost almost nothing to host!

But how? Re-invent the wheel? Develop its own tool?

No, of course not.

Instead, by using the excellent tool open-source (and of course on Python!) called Pelican.

Workflow with Pelican

We reveal to you what we have put in place internally to manage the publication of content in a way that is ,in our opinion, the most simple and powerful that exists.

The installation and configuration of Pelican are not covered here, the documentation is very comprehensive in this subject.

The concept is simple! To add a new article we create a Markdown file. We will not be explaining this system, but you should look it up if you don't know it!

As web professionals, we make it a habit to always use a Markdown editor, from a great service called Github.

We use this editor to write and publish our articles via Github. The articles are simple Markdown files created by Github.

The editors are therefore managed by Github groups and have the opportunity to create an article via WYSIWYG, proposed in place of a repository (containing the blog articles).

We benefit from the workflow offered by Github : once an article is finished, it goes through a validation stage and replay via a pull-request then push on the branch "master", once it’s ready to be published.

From simple commit and push on Github, anyone can add an article. It’s like magic.

Evidently there must be some preparation beforehand. As it must pass through an intermediary that serves to generate and send the HTML files through a file distribution service, in our case, Amazon S3, we already use many Travis-C1, and have decided to take part in this intermediary role (details below). The advantage is that, also in this case, the tool is free for open-source projects.

Our step-by-step workflow:

  • Every user can use Github to write content. They, as first-rate 'power-users' can do this from their computer and send it to Github.

  • The work is then sent to Travis-CI, an open-source platform of continual integration. The latter plays an essential role; firstly, it generates the blog pages from Markdown, then tests the functionality of the whole. In a sense, Travis-CI checks that no anomalies are present and from there validates its release and publishes the new content.

  • Once the blog is "built", the files are uploaded to the Amazon S3 file hosting service at a relatively low cost.

  • To ensure seamless and fast worldwide availability, Cloudflare is added at the end of the chain. The service also has a free offer.

workflow blog

Resources describing the sending of documents to Amazon S3 are available online, for example here, we will not be developing more, however, it takes a little more practice to work directly with Travis (and so, automate everything). But here are some scripts that can help:

https://gist.github.com/maximegaillard/8543581

Nb : A basic knowledge of Travis is still required.

A blog for 1$

Now you know how to own a blog that belongs to you and that costs almost nothing (~1$ /year), is very fast, resistant to the increase of traffic and above all, allows you to write content without worrying about anything else.

Would that not be a miracle solution?

Publié le dans Python par Maxime Gaillard