TurnToJPG -->


Since I switched from octopress to hugo, hugo is wonderful, but I get used to use Octopress’s naming method. For example, if I create a new post in Octopress I’d rather using following command:

$ rake new_post["PostName"]

Then the generated post name would be something like following:

 $ ls -lt | more
total 3632
-rw-rw-r--  1 dash dash  5292 Apr  1  2016 2015-11-05-good-material.markdown
-rw-rw-r--  1 dash dash   540 Apr  1  2016 2016-01-04-purge-cloudstack-env.markdown
-rw-rw-r--  1 dash dash 22256 Apr  1  2016 2016-01-15-linux-tips-4.markdown

While hugo use the origin name, like:

$ hugo new post/
$ ls -lt content/post | more
-rw-rw-r--  1 dash dash  5292 Apr  1  2016

So I wrote a small script for using the same naming principle of Octopress:

$ cat /usr/bin/myhugo 
    # Create post using hugo.
    hugo new post/$
    # Add current date timestamp.
    mv content/post/$ content/post/`date --rfc-3339=date`-$
    # Hint for editing.
    echo "Please Edit" $PWD/content/post/`date --rfc-3339=date`-$

Now using myhugo for creating the post will be looked like:

 $ ~/myhugo WriteLeetCode
/home/dash/Code/ created
Please Edit

Enjoy the rake new_poststyle post name!


Just add an alias in ~/.zshrc:

alias hugoserve='hugo serve -w --theme=hyde-a'

Then type hugoserve will start local preview and you visit http://localhost:1313 for previewing your website.