Quickly Publishing a Blog with bashblog

Maybe it's just me, but blogging seems to have become dominated by certain big-name, high-profile platforms. I won't name them — you probably know which ones I'm talking about.

To be honest, those platforms can be a bit much for personal blogging. Which, in case you're wondering, isn't dead. In fact, there are several great platforms for those of us who want to keep our blogging simple — like Write.as, for example.

But if you want to take full control of your blogging, you need to host your blog yourself. That could mean installing software like WordPress and all of its plumbing. Or you can turn to a static site generator like Jekyll.

What if I told you that you can publish a blog using a piece of software that weighs less than 60 KB? And with some plain text files, of course.

That's the promise of bashblog. Let's take a look at it.

bashblog?

bashblog is a small shell script that does all the heavy lifting (other than the writing, of course) to create a blog. bashblog's developer crafted the script:

because I wanted a very, very simple way to post entries to a blog by using a public folder on my server, without any special requirements and dependencies.

You don't need to be a command line guru to use bashblog, either. Although you need to embrace your inner geek a bit to get going, you only need to remember a few options to effectively use bashblog.

You can run bashblog under Linux, Mac OS, and operating systems based on BSD like FreeBSD and OpenBSD. Windows users, you're out of luck. You can try running bashblog under Cygwin (which provides a UNIX-like environment under Windows), but I can't guarantee that it'll work.

Getting Set Up

Download the script and put it somewhere in your path. Then, make the script executable by opening a terminal window, navigating to the folder into which you copied the script and then type:

chmod +x bb.sh

Next, create a folder for your blog's files. When testing bashblog, I put that under my /home directory in a folder called Public Notebook.

If you plan to format your posts using Markdown, you'll need a Markdown processor like Discount or John Gruber's markdown.pl installed on your computer. If you don't have that installed, bashblog assumes you'll be formatting your posts using HTML.

Other Setup Tasks

There are two other tasks you need to complete before you can start using bashblog: specifying the editor to use when writing posts and adding your blog's metadata.

Specifying the Editor

Because it's a script that runs from the command line, bashblog needs to know what editor to use when you're writing a post. It looks in a file called .bashrc (which contains configurations that you use when at the command line). You'll need to set the editor in that file by adding this line to the file (if it's not already there):

export EDITOR=[editor name]

To be honest, I haven't had much luck with graphical editors and bashblog — that might have to do with the way my computer is set up. I haven't had problems with terminal editors, though. You can use Emacs or vim, but I also recommend Micro or the venerable nano.

Adding Your Blog's Metadata

By metadata, I mean things like your blog's title, your name, social media links, and the like. There are two ways you can do that. You can open the file bb.sh in a text editor and find the section labelled global_variables(). Here's an example:

Some of the metadata that you can change

From there, change the information as you need to.

The other way is to create a file called .config, put it in the same folder as your blog, and edit that file. Creating the file .config ensures that you don't mess up the script and is useful if you plan to use bashblog to create more than one blog.

Here's a sample .config file that you can use as a template. After you edit the file, remember to save it with the name .config.

You're all set up. Now you're ready to start blogging.

Using bashblog

Open a terminal window and navigate to the folder for your blog. Then type bb.sh post and press Enter. bashblog creates a new post and opens it in your default text editor.

A new post in bashblog

The first line is your post's title. Change what's there, but don't add any heading formatting (whether Markdown or HTML) to it. bashblog does that automatically when it publishes the post.

Type the body of your post, and then save it and quit the editor. When you do that, you can press:

Besides creating the post when you press p, bashblog updates the structure of your blog, updates a page that lists all of your posts, and generates an RSS feed.

Here's what a blog looks like:

A blog post published with bashblog

You can add any formatting to you blog posts, including images:

A blog post with an image

Whenever you publish a new post, upload the blog to your web host to share it with the world (wide web).

Styling Your Blog

As you can see from the examples above, out of the box, a blog that bashblog generates is serviceable. It does, however, lack a bit of visual flair. You can change the look and feel of your blog using a Cascading Style Sheet (CSS for short).

To do that, open either the file bb.sh or .config in a text editor. Find the entry labelled css_include= and then add the name of your CSS file between the single quotes after the equal sign. Here's an example:

Changing the CSS file that bashblog uses

In case you're wondering, I usually put the CSS files for anything I publish on the web in their own folder just to keep things neat and tidy.

Here's what a blog I quickly slapped together looks like with a CSS files that I also quickly slapped together:

Custom CSS file with bashblog

If you aren't comfortable working with CSS, or you're not sure where to begin, here are some simple CSS files that you can use with bashblog. Feel free to edit and change them to suit your needs.

Other Useful Options

bashblog, as you've seen, is fairly simple to use. And it does have a few other options than post. Let's take a look at a few of them.

Typing bb.sh rebuild does what it says on the tin. It recreates the structure of your blog when you make a change to the configuration — for example, when you've been experimenting with CSS files.

You can delete individual posts by typing bb.sh delete filename, where filename is the name of the post you want to get rid of. After you press Enter, bashblog sends that file to the digital dustbin and rebuilds your blog.

Typing bb.sh list generates a list of your post, with the newest at the top of the list:

A list of posts

What happens if you have a Markdown processor installed on your computer but want to write and format your posts with HTML instead? Type bb.sh post -html to force bashblog to use HTML instead of Markdown.

Forcing the use of HTML instead of Markdown

Finally, what if you want to go all scorched earth with your blog and start over? Type bb.sh reset. When you press Enter, bashblog prompts you to confirm that you really want to do this. If you are, type Yes, I am!.

Final Thoughts

bashblog isn't for every blogger — especially bloggers who need more from their platforms or tools. But if you want a quick and dirty way to dip your feet into the blogging world, or if you want to embrace the DIY web, then bashblog is worth a look.