Jekyll update for my blog site

My blog site was shutdown for quite a while for certain reasons. However I strongly feel this is a good way for me to capture what I learned along the way and share with anyone who might feel helpful for them. Thanks to all people who provided postivie feedback. After clearup the issue and I finally decide to continue working on my blog site. First thing I do is to update my blog development enviroment which is Jekyll, installed in ubuntu 16.04 VM.

Jekyll on Ubuntu

What is Jekyll?

Jekyll is a very popular tool to build/generate a static web/blog site. It is based on Ruby, which is a script programming language. Ruby library is packaged and distributed as “gem”. Jekyll is one of Ruby’s gem.

If you do a google search “ubuntu 16.04 install jekyll”, you will find a number of links, which have detailed steps, e.g.

  • https://www.digitalocean.com/community/tutorials/how-to-set-up-a-jekyll-development-site-on-ubuntu-16-04

Essentially two steps:

  1. sudo apt-get install ruby ruby-dev make gcc
  2. sudo gem install jekyll bundler

Issues encountered:

After upgrade, jekyll is running version 3.8.6.

weng@weng-u1604:/mnt/vb-win7-share/github/blog$ gem info jekyll

*** LOCAL GEMS ***

jekyll (3.8.6, 3.8.5)
    Author: Tom Preston-Werner
    Homepage: https://github.com/jekyll/jekyll
    License: MIT
    Installed at (3.8.6): /home/weng/.rvm/gems/ruby-2.6.3
                 (3.8.5): /home/weng/.rvm/gems/ruby-2.6.3

    A simple, blog aware, static site generator.
weng@weng-u1604:/mnt/vb-win7-share/github/blog$ 

The new version jekyll deprectes markdown “redcarpet”, so I have to change my _config.yml to below:

 
weng@weng-u1604:/mnt/vb-win7-share/github/blog$ cat _config.yml
...
# Build settings
markdown: kramdown
theme: minima
plugins:
  - jekyll-feed

With _config.yml change, Jekyll is able to rebuild my blog, but failed to render image link like below:

 
![image alt text] (/path/to/image/filename.jpg)

I look around net, couldn’t find any solution, except that I change to html format :

 
<img src="/pathto/image/filename.jpg" alt="alt text">

Since I have many existing MD files, which have image links, I ended up to wrote the below small bash script to do the work:

 
#!/bin/bash 

files=`ls *.md`
for f in $files
do
    echo "============================="
    echo "Processing file : $f "

    while [ 1 ]
    do 
        todo=`grep -n '\!\[' $f | head -1 | wc -l`
        if [ $todo -eq 1 ]
	then
	   linenum=`grep -n '\!\[' $f | head -1 | awk -F: '{print $1}' `
	   line=`grep '\!\[' $f | head -1 `
	   # process one line
	   echo "Process one line : $line, replacing with "
	   alt_text=`echo $line | awk -F'] ' '{print $1}' | sed 's/\!\[//g ' `
	   img_file=`echo $line | awk -F'] ' '{print $2}' | sed 's/(//g' | sed 's/)//g' `

	   # new line format is like <img src="/pathto/image/filename.jpg" alt=" alt text"> 
	   newline=`echo "<img src=\"$img_file\" alt=\"$alt_text\"> "`
	   echo $newline
	   #insert line line after current line
	   cmd=`echo "sed -i '$linenum a $newline ' $f " `
	   eval $cmd
	   echo ".........."
	   #delete old line
	   cmd=`echo sed -i \'${linenum}d\' $f `
	   eval $cmd
	   sync
         else
	   echo " done!"    
	   echo "============================="
           break	   
         fi
    done
done

Main page recent posts

The main page most recent posts are not shown, which I haven’t fixed it. Now I simply change to show all posts sorted by date.