The newly remodeled code.dblock.org is powered by Jekyll and Github pages. The source code can be found here.
The Old
My homegrown system was built in 2008. The tech stack was Microsoft ASP.net with a SQL Server back-end. I did most publishing with Windows LiveWriter that used AtomPub.
Needless to say that was starting to really annoy me, having to boot a VirtualBox VM with Windows on my Mac just to publish an article. Worse, copy paste between the host and the guest OS was not working for images, so I used Dropbox for screenshots. The system was originally designed to save me time, only to ultimately become a time suck. Finally, WinHost, where the blog was hosted, while providing excellent service, actually costs quite a bit of money.
Migration
Posts
I had to write a migration from the old SQL data to the new markdown format.
ActiveRecord does a good job talking to a SQL server.
I had to fight tiny_tds
a bit, needing to reinstall iconv
and brew install freetds
.
Create a database.yml configuration file.
Connect to the database.
Define models, such as Post
.
Require the models explicitly.
Iterate over posts.
The posts were stored in HTML, I convert them to Markdown with reverse_markdown.
Figure out where to write the post on disk and write the markdown post.
The full script is here.
Disqus
I wrote a script to rewrite post URLs for Disqus comments and uploaded it as instructed. Posts appeared after I set the correct disqus-shortname
in my _config.yml.
Jekyll
Theme
I picked Minimal Mistakes and altered it a bit to remove clutter. Thanks @mmistakes for the awesome work.
Github Limitations
If you’re like me and don’t want to generate the Jekyll site yourself, be aware that Github pages doesn’t support many plugins. This means you can’t make features like, for example, tags, to work at the moment. Create a Gemfile that references github-pages to see an identical output as what Github would show.
Serve Jekyll locally via bundle exec jekyll serve
.
Syntax Highlighting
Github pages don’t support syntax highlighting the same way all markdown content does on Github. You can’t use backticks. This means ```ruby will not syntax highlight Ruby, you have to use Pygments with one of the very many lexers to highlight code.
{% highlight ruby %}
# Ruby code goes here
{% endhighlight %}
Tags and Related Posts
None of these will currently work on Github pages, so I removed them from the theme. Add your +1 to pages-gem#93.
Search
I added Google Custom search in this commit.
CNAME
I used code2.dblock.org
while iterating on the system, then finally updated the CNAME file to make the actual switch. Github custom domains are documented here.
Finally, I happened to rename the repo a few times from code
to code.dblock.org
and back. Github will bring your site down for a while when that happens - you have been warned.
Contribute
If you see a typo in a post or want to contribute in any other way, please don’t hesitate to open issues and make pull requests.