NBSoftSolutions Now Runs on Jekyll

There is no one lazier than the programmer, and I am included in this group. When I was constructing this site everything was dynamic and repetitive. The home page was only a placeholder for content that was retrieved via a server- side call, and all the content pages needed the same duplicated HTML so that they would appear correctly. A problem arose where there would be a noticeable pause when the request for the homepage was sent and when the page finally loaded, as the homepage was filled with individual Ajax calls. Then when search engine bots crawled the site, they would just report the placeholders and not the actual content. It was a good first attempt, but there was definitely improvements to be made.

Learning about Server Side Includes, mitigated the duplication conundrum somewhat. This allowed the header and the comments to be injected automatically. However, the problem was still present, especially because I every content page needed the same HTML header. This was a major pain when the CSS file changed and I had to change every file to make sure it referenced the right file.

I designed my own static content generator in C#, which would locate certain layouts and find the appropriate content for it. For instance, the home, blog, and about page were all layout templates. The content pages were now simply the HTML that was to inserted into the layout. The only thing “special” about the content pages were that they had a title attribute that was encapsulated by HTML comments. This was used to to create the URL and the header elements.

Not to brag, but the generator worked extremely well. I used a combination of HTML Agility Pack and CsQuery to parse and create the website. I even stole the method that Stackoverflow uses to create SEO-friendly URLs, which was another thing that was completely automated based off the title. Not to mention the server side include could insert the date when the content was last modified. I found this insanely cool, as I would never have to worry about changing the date, it would automatically update. It even was relatively simple to add new pages, such as the archive page.

While my own Jekyll-like creation worked well, I’m not sure how much longer it could have lasted. I hate to admit it, but there were certain flaws in my program. One of them was that invalid HTML characters had to be manually replaced in the content. This became a problem when I drafted content in Microsoft Word, as Word will replace “ with “ and ”. You may think that those were easy to track down, but they weren’t. Also I had to be careful when copying and pasting code into the content as if there were any less than or greater than signs they would sometimes mess everything up and make the final page not render.

What were some other reasons that I switched to Jekyll?

  • Markdown. Nothing can be as simple and powerful as Markdown. I don’t have to lookup how I had my CSS classes, and everything is readable. No more HTML. Markdown isn’t all peachy, as I found out the hard way when I wanted to link to Wikipedia’s A* article. If you don’t escape the asterisk in the URL, Markdown will fail with a confusing error message. The version of Markdown that I am using is Maruku, which is the default in Jekyll and supports definition lists, which can be found sporadically through this site.

  • YAML. This is basically a better version of my title attribute. I still am looking for a way to get a pretty permalink with no date in it.

  • Pagination. Probably the main reason why I have chosen to given up on my own creation. I didn’t want to think of a design and then have to implement it. With Jekyll, it appears to be straightforward.

Comments: