Skip to content

Instantly share code, notes, and snippets.

Created June 7, 2012 17:59
  • Star 84 You must be signed in to star a gist
  • Fork 12 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
github pages tips for jekyll wiki

Working With Github Pages

The FAQ maintained by Github covers most stumbling blocks, some other tips and tricks supplied here.


Add _site to .gitignore. The generated site should not be uploaded to Github since its gets generated by github.

Working With Code Partials

It might be the case that you are able to eval your code on the browser (javascript, css, html). If you can, it is nice to provide example code and also, working examples. You can DRY up your code samples and keep them easily up to date with the following strategy.

You want to start with file structure that has an _includes directory where you will put your snippets, and a markdown file that will be parsed into your github page. "includes" are analogous to partials.

├── _includes
│   ├── alert_msg.js
├── index.markdown

and some js in your snippet.

  alert("hello world");

and include that snippet in your markdown for it to be picked up by pygments and rendered into HTML:

{% highlight javascript %}
{% include alert_msg.js %}
{% endhighlight %}

Now create the working example by evaling the partial.

  <script type="text/javascript" charset="utf-8">
        {% include alert_msg.js %}
        return false;

Keeping documentation up to date

Having the gh-pages convention is nice, but it keeps it hard to share between to branches and this is a problem if you want to publish your documentation. A simple solution is to provide a post-commmit hook that clones the repo into a temp directory, generates the documentation, copies that documentation into that branch and then pushes the code to the gh-pages branch on your github remote; triggering the page build process.

  #!/usr/bin/env ruby
  require 'fileutils'
  if `git branch`.split("\n").detect{|x| x.match(/^\*/)}.match(/master/)
    puts "updating documentation on the gh-pages branch"
    myrepo = ""
    temp = "/tmp/myrepo"
    `docco src/*.coffee`
    `git clone -b gh-pages #{myrepo} #{temp}`
    FileUtils.cp_r("docs/", temp) do
      system("git remote add github #{myrepo}")
      system("git add docs && git commit -a -m 'updating documentation' && git push github gh-pages")
Copy link

Jed, I'd like to incorporate all this into the Jekyll wiki. Would this be OK?

Linking to this works too, but as a gist it's not easily extensible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment