postToBlog : Post blogs to github.io from terminal.
Installation
postToBolg is a shell script that posts a markdown file to a Github.pages hosted personal blog from terminal. The blog must be powered by the Jekyll. To use it, simply copy the shell scripts dispOption.sh and postToBlog.sh into any directory that is included in your $PATH, then reopen the terminal. You should be good to go by then.
Setup
Open postToBlog.sh and change the following as indicated. To see your defaults, use -h option.
- change the value of
_repository_address
to the directory of your blog’s repository, which usually named like <YourGithubCount>.github.io._repository_address="directory to your github.io"
- change values of
_posts_address
and_posts_sub_address
to the relative directory of your posts’ directory with respect to their upper directories. Normally, the value of_posts_address
is _posts/ and doesn’t need to be changed. Meanwhile, the_posts_sub_address
is added to classify your files to a default folder._posts_address="_posts/" _posts_sub_address="2018/" #classify your files by year for instance
-
specify a default input filename by setting
_mfile
. This will save you some time I think. - setup head information that is needed by the Jekyll for configuring your post. The value of
_layout
must be defined in the Jekyll’s styles._layout='post' #using the layout named post _categories='Command Line Tools' #example category _tags='shell,git,jekyll' #example tags
Usage
postToBlog [-i<markdown-file>] [-l<layout>] [-T<title>] [-c<categories>] [-t<tags>] [-s<sub-directory>] [-S] [-h]
Options
With proper settings, no argument is needed to run the script most of the times. Use following options if it’s not one of those.
- -i: Input markdown file.
- -l: Post’s layout.
- -T: The blog’s title. The h1 level head in the input markdown file will be used as the title by default. And manually input is needed if none was found. Using this option will overwrite the title.
- -c: Post’s category. Commas is needed if there were more than one.
- -t: Post’s tags. Commas is needed if there were more than one.
- -s: Sub-directory for classify your files.
- -S: Save a copy of the output file. The format of the output file’s name is as defined as by the Jekyll, which consists of the post’s date and the blog’s title connected by ‘-‘. For example, 2018-11-12-postToBlog-post-your-blog-to-Github-io-from-terminal.md. Note that special symbols in the blog’s title such as ! and : will deleted.
- -h: Show help inforamtion.
Example
To post the file your are reading now I used
postToBlog -i README.md -c "Command Line Tools" -t "shell,git,jekyll"