Check out some of the wordpress tutorials on building your own theme. Some of them have all sorts of slick code in the head section and on the body to generate code.
Have to say though, if I was doing anything like a blog, I would definitely just use wordpress and do my own theme. A normal work year for one person is 2000 hours. I'll bet they have at least 30,000 hours into that development, minimum. Why reinvent the wheel?