## Jekyll: Add Caption to Image

Having only relatively recently started to blog using Jekyll, I’ve only just come across the problem of trying to add captions to images - sans plugin.

Fortunately Jekyll is very easily extensible with some straight-forward HTML/CSS. Of course, following the framework’s separation of concerns, we need to do three things: Add markup to our _includes folder, update our stylesheet, and finally include a reference to our markup in the blog post file.

In the _includes folder, I created a new file called image.html, which includes,

with a CSS class center with properties adjusted to taste.

Turning to the blog post, I want to add,

{% include image.html url="/path/image.png" description="Caption" %}


making use of Jekyll’s include tag. Everything should be self-explanatory, although it should be said that I’ve used a relative path to the image file as prefxing url with site.BASE_PATH led to a Liquid Exception. Et voilà,

and of course we can add any sort of customisation from here.

All the best,

Tom

## Creating a GitHub Repo from a CLI

Having spent the past couple weeks wrestling with what to write about I’ve settled on this helpful tidbit. My constant need to refer to this basic workflow is some indication that (a) it’s useful, and (b) I really ought to have better recall. Although there are helpful command-line tools out there that steamroll over much of what is to follow, I myself am in a bit of Homebrew limbo, not to mention the following is arguably more enlightening.

Aim of the game: Create a repo from a command-line interface and push the local repo to GitHub. This gives us that much more control in setting up the initial directory structure before starting out on a project. Having run a git init in our root directory and made our first commit we can get started.

First we need to create the GitHub repo from the command-line. To do this we use the unix curl command, which allows us to interact with the server. Following the GitHub API we write,

where we specify our GitHub username and the repo name in place of ‘USER’ and ‘REPO’ respectively. The option -u specifies the username (and password) to be used, and -d indicates a POST request. At a minimum we should specify our username and the repo name. We can easily include more information in the POST request as required. We can also specify further authentication following the -u parameter if desired. Following exactly as above, we will be prompted to type our password after entering the curl command.

where ‘USER’ and ‘REPO’ are our GitHub username and the new repo name, as above. This creates an alias for the URL specified, in all subsquent push commands we need only specify our remote with origin, which will be understood as the full URL.

It should be said that this step require you to already have set up an SSH key with your GitHub account, if not you can follow the steps here. You can just as easily push to an HTTPS URL, which is this case would correspond to, https://github.com/USER/REPO.git.

And finally, we can push our new project to our remote repo,

With any luck, we should have a commit in our newly minted remote repo.

All the best,

Tom

Hopefully I’ll be in a position to post actual factual content soon enough, so yay!

In the meantime I thought it would be useful to list all the resources I’ve used so far to get my blog in the state you see it in now.

Behind the scenes, I’ve added Thor following pretty much the same steps as per the linked blog post. Pretty obviously, this speeds up my workflow just a bit: getting rid of the need to add all the front matter by hand. One issue that I came across was how best to create nice looking URLs for each blog post. I haven’t found a definite answer so far, my solution was to add to my jekyll.thor file,

where title is the name I give the post from the command line. The permalink for each page will simply be constructed out of the title rather than the entire file name including the date. I’m using the jekyll-sitemap gem to automatically generate a sitemap for SEO goodness. Finally, maybe stating the obvious, but I’m hosting using GitHub Pages, for cost and ease of use with Github.

Upfront stuff: I’m really happy with the overall look and feel of the dbyll theme, looks great on mobile and easy to customise. I changed my gravatar using Pixen, ultimately I want to graduate to a decent looking 16 bit cat.

I purchased my domain name through Namecheap and followed the steps here.

Most of the other setup including adding Disqus and adding Google analytics went pretty much as per the available documentation. Further instruction can be found here. Other than that, there’s always this handy documentation.

All in all, it was a good learning experience with a shallow learning curve. I’d like to add more functionality in the future, but for the time being I need to make a start on content. Feel free to add in helpful pointers.

Tom

## Hello World!

Hello there plucky internet user, this is my blog!

I am a junior developer working in London, UK with experience in Ruby, JavaScript and Python. This blog is very much in the spirit of personal/professional development insofar as many people, both older and wiser than I, preach the importance of deliberate and consistent application of oneself cough Cal Newport.

More about me, I’m very new to the world of development but have throughly enjoyed my experiences so far. I have gone through the increasing popular route of not majoring in computer science and instead going through a bootcamp at the start of this year. London is a very vibrant and exciting place to work as a developer, with a bustling startup scene and numerous meetups to boot.

If this blog has left you wanting more from yours truly, I tweet – or more accurately retweet, details, details – a fair bit as well as all the usual razzamatazz, see sidebar.

I hope to use this blog to write about technologies or techniques be they practical or more theoretical (not a CompSci major). Hopefully you too will be able to profit from this journey, so let’s get started!

Tom