GitHub Pages

Posted on: 26 January 2014

This is where we are going to document what we do at each meeting. Everybody who gives a presentation can contribute to this site.

[edit 28 January 2014]

How to add posts

Posts are published by pushing a markdown file to the _posts directory in our GitHub Pages repository.

Once you have access to the repo, you could create the file directly in the web interface, or you clone the repo to your machine.

    
  $ git clone https://github.com/CodeHubOrg/codehuborg.github.io.git
    

If you have jekyll installed, you can run a copy of this site locally.

        
  $ cd codehuborg.github.io/
  $ jekyll serve --watch
    

You can then view the site in your browser at http://localhost:4000.

Create a new file in the _posts directory, for example by copying the one for this post. You need to name the file in the YYYY-MM-DD-title.md format. In the file, you can set the title and categories of the posts at the top. Keep the layout set to 'post'.

For example this post has in its front matter:

  ---
  layout: post
  title: GitHub Pages
  categories:
  - github
  - jekyll
  --- 

For writing the post, you can use Markdown or HTML. Also, Github Pages uses Pygments, and it is enabled for this site. That means when you want to highlight code, you can use a syntax like the following, taking PHP as an example.

{'% highlight php %}
    <?php  
    $html = 'This statement is ';  
    //I love ternary operators
    $html .= ($number_of_people > 30)? 'right' : 'wrong';  
    echo $html;  
    ?>
{'% endhighlight %}

It will look on the site like this:

    <?php  
    $html = 'This statement is ';  
    //I love ternary operators
    $html .= ($number_of_people > 30)? 'right' : 'wrong';  
    echo $html;  
    ?>

Once you have written your post, push it to the repository on GitHub. - If you have run the site locally, don't forget to list the _site directory in your .gitignore file.

Some useful resources if you are not familiar with Git and GitHub:

 

If you haven't used Markdown before: http://daringfireball.net/projects/markdown/basics

By Katja
Posted in Categories: github jekyll