Blog about writing blogs

This blog about writing blogs is upon request by pestering friends. Thanks to all other blogs about writing blogs.


To know these exist

Nikola Static website generator
Github Free website hosting
emacs Emacs : A wonderful text editor
orgmode Headings, Tables, Text formatting, Genetically Awesome!!!
Python virtual environment A special work place without pollution

Curious Columbus-es should then follow the links. (or) If you just want to get your blog up and running then, bother not, you shall.


Well

The idea is to create a blogging website hosted in Github, using a static site generator software Nikola, with the help of Python virtual environment and then write blog posts using emacs org mode.

Also

  1. I'm using Linux.
  2. I will be assuming the name of your blog as 'bottle'

GitHub

git : (British) a foolish or worthless person

– Merriam-Webster

So, keeping that in mind:

  1. Create a GitHub account with username 'bottle'
  2. Create a repository with the following name:'bottle.github.io'
  3. Instructions.

Once done this, GitHub will host your website in the following address(URL) : https://bottle.github.io/

Clone(copy) this newborn repository into your local machine a.k.a personal computer by using the following command:

git clone https://bottle.github.io/ $HOME/projects/bottle

You will be adding blog posts in ~/projects/bottle directory and will push them back to GitHub later.


Python Virtual Environment

If you haven't heard the news yet, Python is a programming language and Python 3 is here to stay.

Python Virtual environment basically copies python scripts to create a new workplace. You could install custom python packages specific to your project. This means packages used for one project will not pollute another project.

For e.g. if you wish to have a separate working environment for cooking vegetables, where you don't want nikola to be installed, create a virtual environment called vegetables.

Virtual environment wrapper

Gift-wrapped python virtual environment commands. For ease of use. No need to remember too many virtualenv commands.

Let "$HOME/virenvs" be our directory for all environments.

As always, names doesn't matter. It is what you do that defines you - Spiderman's ex-girlfriend

Steps

Make sure you have pip (python package manager) installed in your machine. And follow the steps :

pip install virtualenv
pip install virtualenvwrapper
export WORKON_HOME=$HOME/virenvs
source /usr/local/bin/virtualenvwrapper.sh
mkvirtualenv bottle
workon bottle

Now you should see that you have entered the 'bottle' environment.


Nikola

If you are inside the bottle, then you are ready to install nikola, the static site generator.

Installation

pip install --upgrade pip 'Nikola[extras]'
nikola plugin -i orgmode
cd $HOME/projects/bottle
git checkout -b sources

add a .gitignore file to $HOME/projects/bottle folder with the following content in it.

*.py[cod]
__pycache__
cache
output
.doit.db

commit this to git

git add .gitignore
git commit -m "Add .gitignore"

Website

Create a website using nikola

nikola init bottle

Fill in the form that follows.

It should show a success message after form is filled. Now, nikola will create a new folder called bottle inside $HOME/projects/bottle, which is unnecessary. So move its contents to $HOME/projects/bottle folder and delete the extra bottle.

mv my_first_site/* .
rm -r my_first_site

Your new site 'bottle' can be viewed either locally or globally(using a new technology called internet). The latter will be done later.

To view your recently created site locally,

nikola build
nikola serve

Open browser and enter localhost:8000 in the URL bar !

To stop the localhost web service in the terminal hit Ctrl-c.


Posts

Now, you would want to flush your ideas into blogs. That could be easily accomplished.

nikola new_post -e

The -e option will open the post in your text editor of choice;

Movimg on from editor of your choice,

  • Emacs Org-mode

    Every great software application is a file with some text in it and Emacs is a text file editor

    The best way to get started with Emacs is to follow its built-in tutorial. Open Emacs and press Ctrl-h t. Emacs tastes best when customized. Help is available at using emacs.

    org-mode in itself is the biggest reason people fall in love with Emacs so easily. I like org mode introduction by Harry Schwartz.

    Two cool things in org-mode that I must mention:

    1. creating tables |Name|Age <tab>
    2. exporting to html/pdf/LaTeX/odt/iCal … Ctrl-c Ctrl-e

  • To write a new blog post in Emacs org-mode

    You've already installed org mode plugin for nikola in your installation process.

    Now, append the following to your conf.py file(available in bottle folder)

    # Add the orgmode compiler to your COMPILERS dict.
    COMPILERS["orgmode"] = ('.org',)
    
    # Add org files to your POSTS, PAGES
    POSTS = POSTS + (("posts/*.org", "posts", "post.tmpl"),)
    PAGES = PAGES + (("stories/*.org", "stories", "story.tmpl"),)
    

    Now, to write a post using org-mode,

    nikola new_post -e -f orgmode
    

Comments

If you like using disqus as the commenting system then:

  1. Create a disqus account
  2. Login and click on your picture at top right and select install on site
  3. Fill in necessary details. If you don't see nikola platform in the list, don't worry, skip that and go to next page. If the next page is about installing manually by adding code where you want disqus to appear, SKIP that as well.
  4. Go to the last step and finish the configuration
  5. At the end of setup, you should see your disqus short name.
  6. That is your disqus ID you need to add in your conf.py file
# To use comments, you can choose between different third party comment
# systems.  The following comment systems are supported by Nikola:
#   disqus, facebook, googleplus, intensedebate, isso, livefyre, muut
# You can leave this option blank to disable comments.
COMMENT_SYSTEM = "disqus"
# And you also need to add your COMMENT_SYSTEM_ID which
# depends on what comment system you use. The default is
# "nikolademo" which is a test account for Disqus. More information
# is in the manual.
COMMENT_SYSTEM_ID = "your_disqus_account_id"

Publish

To launch the site in local host

nikola build
nikola serve

The 'nikola auto' command automatically updates the local site for every change you make to your post.

nikola auto

To publish your blog to the so called internet,

Edit the conf.py file and change these following variables. This helps in keeping the master branch of GitHub page less crowded.

GITHUB_SOURCE_BRANCH = 'sources'
GITHUB_DEPLOY_BRANCH = 'master'
nikola github_deploy

And visit https://bottle.github.io


Comments


Kindly leave your feedback here.