Migrating blog to nikola + GAE

This blog has been in deep lethar­gy for sev­er­al years. I’m not sure I can ­make it come back to life, but I’ll try, first of all by ex­plain­ing how I ­man­aged to mi­grate it from blog­ger to stat­ic site host­ing gen­er­at­ed by niko­la and host­ed on GAE (Google app en­gine).

Import in Nikola

Nikola proposes the plugin import_blogger which allows you to import an XML export file of blogger into the nikola file structure. You may install it with:

nikola plugin -i import_blogger

A niko­la project is then cre­at­ed with the com­mand:

nikola import_blogger -o name_of_blog blogger_export. xml

Then copy the generated configuration file (e.g. conf. py. import_blogger-20171228_142937) to the file conf. py and modify the configuration according to your wishes.

Blog ar­ti­cle files are gen­er­at­ed in html for­mat with a . meta file in re­struc­tured­text for­mat con­tain­ing the ar­ti­cle’s meta­da­ta.

Overall the conversion goes well and the rendering is acceptable. However, some articles require some tweaking. I get them through the tools: pandoc and html2text2 to get a version of the article in restructuredtext format to be taken up and modified by hand:

html2text2 article. html | pandoc -f markdown -t rst > article. rst
mv article. html article. html article. bak

Hosting on GAE

Google pro­vides pret­ty de­tailed ex­pla­na­tions for host­ing a stat­ic blog on GAE. Ap­plied to a stat­ic blog gen­er­at­ed by Niko­la, you need to:

  1. Cre­ate a project on the con­­sole google cloud.

  2. Put the file app. yaml in the following directory files at the root of the project:

    runtime: python27
    api_version: 1
    threadsafe: true
    - url: /
      static_files: index.html
      upload: index.html
    - url: /en/
      static_files: en/index.html
      upload: en/index.html
    - url: /(.*)
      static_files: \1
      upload: (.*)
  3. Change the parameter DEPLOY_COMMANDS in the file conf. py as follows (replacing gae_project_id with the identifier of the project created in 1.:

    PRETTY_URLS = False
        'default': [
            "cd output && gcloud app deploy --project gae_project_id"

It is probably possible to use PRETTY_URLS by modifying the file app. yaml to take by default the files index. html, but this configuration allows to keep the same URLs as on blogger if you configure the redirection for the old URLs:

    ('2012/04/lettre-eva-joly.html', '/posts/2012/04/lettre-eva-joly.html'),

Or even more simply, as @GetNikola very kindly pointed out to me on twitter, by replacing posts with "" in the variable POSTS:

            ("posts/*.txt", "", "post.tmpl"),
            ("posts/*.rst", "", "post.tmpl"),
            ("posts/*.html", "", "post.tmpl"),

Then a simple nikola build && nikola deploy will make the site accessible on the URL https://gae_project_id. appspot. com. You are free to configure your DNS registration so that your domain name redirects to this page. You can also configure the automatic generation and renewal of certificates to make your site accessible in HTTPS. This is easily done on the google cloud console.

Leave a comment
The name you want to show others