Skip to content
Build static Github Pages with all the tools in Rails
JavaScript Ruby CoffeeScript
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

Rails Pages


These are just 3 apps I create a lot, and you should use a lot too. When you create your new ruby gem or jquery plugin, just run:

git branch gh-pages
git checkout gh-pages
rails new . -m
rails server

Then start building your pages. Most of the HTML architecture has been standardized, so the header/footer/sidebar/navigation/etc are all defaulted in and easy to customize. It's all Haml too, so everything gets perfectly printed. It's filled out data-wise too, so you'll have a super "semantic" site from the get-go.

Development Tips

Sometimes when you're building your static site, it's just a lot easier to have everything dynamic, and even to be using mongodb (via Mongoid) to store models. That's the main reason I put this together: we're all really used to Rails, so dealing with models doesn't scare us, it's actually easier than having to learn a new templating language and file structure.

So, you can tell it to use mongoid, and redis, no problem. If you do, it will create a base Page model for you, which will allow you to do full-on blogging. With this setup, every time you save a document (in app/docs/, it'll do what github-pages does to it: syntax highlight with pygments. Then it'll save it to mongo. When you're ready to push to gh-pages, you can run rake compile and it'll compile a static version with the correct file structure for GithubPages.

But if you all of a sudden realize you want to add some dynamic functionality, and you'll actually be needing the database, well then you can just push to heroku, no changes necessary.

Testing Tips

When you want to test views, just create a Rails app using this template:

cd spec
rails new spec_environment -t
cd ..

Then you can run view tests, and render partials, no problem.

Something went wrong with that request. Please try again.