How to Blog with Jekyll

Recently, I decided to switch my personal blog over to Jekyll, a blog-aware, static site generator written in Ruby. By design, Jekyll is simple, fast, and not bloated like most CMS. In fact, Jekyll doesn’t need a database to run and there’s no traditional admin panel to create, edit, and manage your posts. Instead, you get to use your favorite text editor and version control system to push changes to your site. Everything lies on your local computer, meaning there’s no chance for data loss due to a faulty database on your server. You also don’t have to worry about constant updates and security flaws.

If you’re willing to hack a little, I’d highly recommend switching over to Jekyll. Sure, you lose the bells and whistles, but you’ll be able to focus on the important part: the writing.

Getting Started with Jekyll and GitHub

Jekyll was developed by GitHub co-founder Tom Preston-Werner, so naturally, GitHub Pages offers free web hosting that you can use to power your Jekyll site. We’ll start off by getting Jekyll set up on your local computer and then pushing it to a new repository on GitHub.

Start off by installing Ruby if you don’t already have it. Then we can update RubyGems and use it to install Jekyll.

$ gem update --system
$ gem install jekyll

You should also go ahead and install RDiscount to process Markdown, which is what Jekyll uses for authoring posts (of course, you can use Textile or HTML if you prefer). By default, Jekyll uses Maraku, but I found it slower and more difficult to use than RDiscount.

$ sudo gem install rdiscount

If you want code syntax highlighting on your blog, you can also install Pygments. You’ll need to install Python to continue.

$ sudo easy_install Pygments

Your local dev environment is now completely setup to run Jekyll. To get your site up and running, all you have to do now is to create a new directory and a new repository on GitHub in the format username.github.com

$ mkdir frankjwu.github.com
$ cd frankjwu.github.com

For the sake of seeing progress, you can create a new index.html file in your new directory and fill it with the following.

<!DOCTYPE html>
<html>
<head>
  <title>Frank Wu</title>
</head>

<body>
  <h1>Hello World!</h1>
</body>
</html>

You can now start your local Jekyll server, navigate to http://localhost:4000, and see your new site!

$ jekyll --server

Push it up to your recently created GitHub directory and you’ll see it up and running on GitHub Pages as well.

$ git init
$ git add .
$ git commit -m "Initial commit"
$ git remote add origin [email protected]:frankjwu/frankjwu.github.com.git
$ git push origin master

It may take around ten minutes for GitHub Pages to fully update.

Configuring Your New Blog

Obviously, you’ll want to do more with your blog than just display a single HTML file. To do so, you’ll need to setup your directory with the basic structure that Jekyll expects:

.
|-- _config.yml
|-- _includes
|-- _layouts
|   |-- default.html
|   `-- post.html
|-- _posts
|   |-- 2007-10-29-why-every-programmer-should-play-nethack.textile
|   `-- 2009-04-26-barcamp-boston-4-roundup.textile
|-- _site
`-- index.html

Simple! All of these folders are fairly self-explanatory, but if you’re unsure what something does, you can read the Jekyll documentation. _config.yml holds your configuration settings, _includes stores partials, _layouts holds templates for displaying your site content, _posts contains your blog posts, _site is automatically generated by Jekyll with your static pages, and index.html is the page that will be displayed at your root URL.

We’ll go ahead and create a simple default.html layout to get started.

<!DOCTYPE html>
<html>
<head>
  <title>{{ page.title }}</title>    
  <!-- You can load CSS files and other meta data -->
</head>
<body>
  <h1>Welcome!</h1>
  {{ content }}
</body>
</html>

Update your index.html file with the following:

---
layout: default
title: Frank Wu
---

You’ll notice that the default layout uses Liquid code to pull the page title and content, giving you some additional flexibility in creating your layouts.

If you’re following the tutorial step-by-step and you do want to use RDiscount and Pygments, go ahead and create your _config.yml file now with the following.

markdown: rdiscount
pygments: true

If you want to use a custom domain, you have to create a CNAME file and put the desired domain name inside it. You will then need to add an A record that points to 204.232.175.78 in your DNS settings.

At this point, you have already created the basic skeleton of your site and simple configuration settings. Jekyll is up and running and all you need now is to start designing the site layout with HTML (infused with Liquid) and CSS. Even if you’re a talented designer, it’s a good idea to fork an existing Jekyll blog to see how they work. You might want to start with forking Tom Preston-Werner’s blog or even mine to get an idea of what to do next.

Writing Posts

Writing new posts is super easy with Jekyll. You just create a new file in the _posts folder in the format “YYYY-MM-DD-post-title.markdown”. Add the necessary YAML information to the top of the post and Jekyll will do everything else for you. Here’s what this post looks like:

---
layout: post
title: How to Blog with Jekyll
---

Recently, I decided to switch my...

I like being able to work with drafts of my posts, so I created an additional _drafts folder and then added this to my .gitignore file to make sure my half-baked posts don’t accidentally appear on my GitHub repository.

$ mkdir _drafts

It’s also a good idea to add your _site directory to your .gitignore. When Jekyll is run, the _site directory is populated with the static pages that make up your site.

If you want to move blog posts from your old blog, the Jekyll gem provides a number of easy migrations for you as well. I’ll briefly run through the Tumblr migrations since that’s what I migrated from, but you can find full instructions for other systems here.

$ mkdir _import
$ gem install sequel mysqlplus
$ gem install nokigiri
$ ruby -rubygems -e 'require "jekyll/migrators/tumblr";
  Jekyll::Tumblr.process("http://www.your_blog_url.com", true)'

The above steps will create a new directory for your imported posts, install the necessary gems for the migrators to work, and then perform the actual data migration from your old blog. After migrating, you might want to clean up the markup in your old posts, especially if you didn’t use Markdown before.

Thoughts

Obviously, Jekyll isn’t for everyone since it requires a bit of familiarity with the terminal, Git, and Liquid markup, but I’m extremely satisfied with the entire system. I love being able to open my text editor to write posts and then previewing everything on my local server before pushing the changes to a GitHub repository. Pages load quickly since they’re just static HTML files and I feel at ease making incremental changes to the live site.

If you’re still not sure, I’d recommend reading Tom Preston-Werner’s “Blogging Like a Hacker” and Paul Stamatiou’s extremely detailed tutorial, “How To: Wordpress to Jekyll”, for some additional inspiration and thoughts.


What I've Learned from Rap Music

I think it’s funny how so many people completely misunderstand rap (and country, although that’s a topic for a completely different post). I’ve heard tons of people say, “I listen to everything. Except rap. Oh, and country.” Who knew there were so many fans of Serbian turbofolk?

Rap music is literally spoken word poetry interlaced with background instrumentation — a point one of my English teachers (who I’ll probably direct this to) decided to capitalize on. In his example, he juxtaposed an older, exquisitely beautiful poem with a few song lyrics from LMFAO to show how modern day “poetry” and eloquence (or lack thereof) doesn’t even come close to touching that of the past. It’s a great example. I laughed! But I’ve also learned a great deal from our modern day poets: the poets from the streets of Compton, the poets that brandish racks on racks on racks, and the poets that have hustled their way to greatness.

Here are just a few of the many lessons that I’ve learned from rap music:

  • Hard work pays off. It’s hard to find another genre of music that contains as many self-made men and women as rap does. You won’t find many of Fortune’s fools here: these people know how to make money, and they do so on their own merits. Justin Kan puts it best when he writes, “Rap music is music for entrepreneurs.”

  • If you build it, they will come. In the digital age, literally anyone can write, record, and release music for the world to hear. To counter that, most rappers now release their music online in the form of free mixtapes. Considering the fact that musicians used to make a ton of money off selling records, this is an extremely bold move. It’s also become increasingly successful in launching new careers — nowadays, most rappers build a loyal fanbase by giving away their music and then go on to reap the rewards when touring or when they sign to a major label.

  • You don’t need to rely on someone else to succeed. Contradicting what I just said, some rappers actually choose not to sign to a label because they don’t even need them to succeed! Mac Miller’s Blue Slide Park is a great example of this. Although it wasn’t very highly received by critics, Blue Slide Park debuted at number one on the US Billboard 200 by selling 144,000 copies without the backing of a major label. You can question Mac’s musical merits, but you can’t knock his hustle.

  • There’s usually a deeper meaning behind even the simplest of rhymes. That’s great because it’s just as fun to simply listen to the songs (after all, music is a form of entertainment) as it is to dissect them. Exegesis at its finest.

  • Stand for something greater than yourself. A recurring theme in rap music is the idea that the rapper is not only representing himself and his “crew,” but more importantly, he’s representing his city. Some even manage to create an entire movement around their music: XV’s “Squarian” movement, for example, embraces individuality and teaches his listeners that it’s okay to be yourself. That’s music you can believe in.

  • Believe in yourself. I think the main reason I like rap music so much is because it’s such an authentic form of inspiration. This might seem ironic because the majority of rappers tend to aggrandize their own lives, but usually, it’s with good reason. These same rappers often had extremely humble upbringings — a stark contrast from the level of wealth they now boast about. But back then, all they had was their own spirit and confidence in themselves to push themselves to pursue a better life, even if it meant dealing drugs to survive. I think Drake says it best when he channels his inner Muhammad Ali, “I’m the greatest, man, I said that before I knew I was.” Pusha T also does the idea justice when he raps about his dark past, “CNN said I’d be dead by 21. Blackjack, I just pulled an ace as you looking at the king in his face.”

  • Triple entendres exist. Don’t even ask me how.

  • Age is just a number and talent matters a whole lot more. Nas was just 20 when he released Illmatic, which is regularly recognized as one of the greatest and most socially conscious albums of all time. Less macrocosmic examples include Earl Sweatshirt releasing EARL at 16 and Joey Bada$$ releasing 1999 at 17. The rap game is, for the most part, a meritocracy.

  • Respect those who paved the way for you. Another deeply rooted belief in the rap game is that you probably weren’t the first in your lane and you certainly won’t be the last. Because of that, you’ll find older rappers taking younger ones under their wing, cosigning their careers, and then propelling their newfound protegés to fame. The younger ones learn to respect their mentors and when the time comes, they return the favor by bringing in newer talent.

You can find more of my thoughts on music over at Lost In The Sound, where I’ll probably republish this post.


Two Heads are Better than One

It’s an age-old adage taught all over the world to foster a sense of collaboration and teamwork — one that took a hit in the journal Science in August of 2010.

Led by Bahado Bahrami of the Interacting Mind Project (University College London and Aarhus University in Denmark), the study concluded that two heads are only sometimes better than one, making the important distinction that both heads must be both competent and able (or perhaps just willing) to communicate their weaknesses.

But isn’t this something that we already fundamentally understood? Imagine an open-heart surgery conducted by a heart surgeon and an astrophysicist, both of whom are world-renowned in their respective fields of study. Two brilliant minds working together, but one is obviously going to be less capable than the other. In this case, one head is certainly better than two.

For all other instances, having more brilliant minds is certainly very worthwhile. In the near future — and far future for that matter — steps should be taken to encourage more collaboration in solving problems, harnessing the incredible amount of intellectual wealth that exists in the world today.

No mind is identical to another. Each person sees and interprets information differently. Relative wealth, living conditions, education, and a number of other variables all contribute to how someone may see the world. Sure, an astrophysicist may not be the most reliable person to conduct an open-heart surgery, but who’s to say that an astrophysicist has no valuable thoughts to contribute on the methodology of the surgery? It is already understood that with no specialization in the field, an astrophysicist would not be the most technically capable, but from an intellectual standpoint, he will at least have thoughts to share and observations to make. That’s the inherent beauty of the human mind.

Sometimes, the most straightforward approach to a problem is indeed the best approach. But when time, money, and effort allow, looking at all the alternate pathways from A to B provides very useful insight. By only considering one option — because of tradition, principle, or simply out of pragmatism — many doors are closed. By taking into account every other pathway, it is possible to pool the collective knowledge and experience of all the brilliant minds out there, analyze them objectively, and then innovate accordingly.

With respect to the world’s depleting natural resources, much of modern technological research has been turned towards discovering a more efficient and environmentally friendly way to power our automobiles. Plant biologists have begun biobased-fuel research projects, chemists have been investigating fuel cell catalysts, and other alternative fuel sources have been considered. Which one will be predominantly used in the future? Who knows? Maybe it’s one of the aforementioned, maybe it’s a mixture of them, or perhaps, maybe it hasn’t been discovered yet.

People are out there. Ideas are out there. We just need to find a way to harness them.


Hello World

Those two words — clearly innocent when looked at individually — always combine together to seemingly destroy the harmonious sanctity of a fresh slate. It’s almost as if we’re plucking away the petals of a newly blossoming rose petal, plucking away petal by petal, until we’re left with nothing but a lonely and tattered stem. And rarely, does the destruction of such beauty lead to even newer and greater things.

But for years, programmers have all begun their journeys by making these two words appear on the screen for the first time, tossing away any sense of freshness in exchange for a headfirst plunge into learning a new language. In these cases, destruction is grand, it is majestic, it is welcomed. For us, taking that first babystep in the right direction is ceremonial, marking a journey into the unknown that will inevitably be worth the effort put in. Heck, my Twitter account actually started off the same way back in July of 2011. Goodbye fresh slate, hello world.

On that note, I can think of no better way to begin my personal blog, where I’ll share the lessons I’ve learned, my ideas for the future, and whatever else I want to say. I hope you’ll join me.