Fork me on GitHub

Elizabeth's Jekyll How to Post

by Elizabeth Peele

25 Oct 2013

To make a Jekyll site, the first thing you need to do is open the terminal. Then, once you have opened the terminal, it might be a good idea to go ahead and run a git pull upstream gh-pages to refresh everything you've done on github so far. While this may be a new site, it's good to get into the practice so that you don't accidentally create a clone and then can't figure why things won't merge until your very helpful professor has to walk you through the problem. Not that that happened or anything.

Moving on, to actually build a Jekyll site you will need to type jekyll new {name of your site}. Then, you need to change the directory you are working in by typing cd {name of your site}. This will move you into the directory for your new site. You can check to see what is in there by typing ls.

Once this is done, you need to make a new git repo. To do this, type git init. Since this repo will not have commits, you will make a commit to it now. Type git add . to add the files and then git commit -m "{insert your own message here}" to commit them.

Then, for a very important step, you are going to want to make sure that you have a .gitignore file that will cause git to ignore your site/ files. To do this, type nano .gitignore and add site/.

To commit this, we need to go through the same process we did before, type git add .gitignore and then git commit -m "Ignore _site/ directory".

This is a very important step, so to ensure that you have completed it properly, type git status to check that no _site/ files are there. If there are, you will need to check to see if you had a previous error for why it didn't work, or post a question somewhere and ask what is going on.

Now, in order for your pages to show up online, we're going to rename the default branch from master to gh-pages. I repeat, it needs to be renamed to gh-pages. Renaming it to gh-page means you will have to go back and delete it later on. To do this change, type git branch -m master gh-pages.

Penultimately, you need to go to Github.com and create a new repository by clicking the "new repository" button. It should be the one that looks like a notebook with a plus sign on that is to the right of your name on the top right part of your screen. Name the repo the same thing you called your jekyll site. Please don't check the box that creates a README.

Finally, you can add and push your commits of your repo as a remote by typing git remote add origin https://github.com/{your-username}/mysite and then git push origin gh-pages.

After all of this, you then need to go to github.com to make changes to the css.

First, go to mysite/index.html and here add in /fall2013/ to the line of code that starts with a href=. The spaces in there make it easier for people to read, so while not 100% necessary, it is good coding practice. (Thanks for the tip Elliott and Grant!)). Then, go to _config.yml to add a line that states baseurl: /{name of your site} underneath the name, markdown, and pygments categories.

From here, you should be able to play with the css and continue growing your own repo. Have fun!

Elizabeth Peele is a first year MSIS at the University of North Carolina Chapel Hill. Find Elizabeth Peele on Twitter, Github, and on the web.
comments powered by Disqus