A Static Site Generator In Go

Static site generation is really about building an online business presence. You can build a family blog with a free Wordpress site. Your family won't mind it if your site is a little slow. They will wait! Customer won't wait! Research clearly shows customer conversion rates are heavily influenced by how fast your site loads. It takes a lot to make a fast Wordpress site. Even after you do all of that you will still have a site that is far slower than a static site. The very fastest static sites use Content Delivery Network (CDN) like Amazon CloudFront. The servers are placed around the world so your content will be delivered with less network latency. Using a CDN for all of your content is just part of the strategy in maximizing business conversion rates.

Remember this: Google considers site load time to be sufficiency important that they factor it into the page ranking!

The vision for gen-blog/gen-site system is to provide a high speed, high reliability, high conversion rate system for promoting an online business.

Why build a static site generator? A bunch of reasons come to mind:

  1. Security - static HTML has huge security advantages over a dynamic site with a database. Basically when there is no way to login there is no way for an attacker to do much damage.
  2. Unlimited HTML5/CSS3 tempesting and styling opportunities. - No PHP or other language to get in the ways of your design. All of the pages are built with some fairly easy to understand Go templates. The templates use HTML, CSS and JavaScript. That means that creating a new template for a site is much easier.
  3. Performance - back in the olden days you could tolerate a server with some PHP or .net on it. Generating dynamic content was an acceptable solution. Today a high traffic site needs to use a content delivery network (CDN) to serve its content. Dynamic content generation and content delivery networks don't mix all that well. Why not just pre-generate *all* the pages and then make all the content static.
  4. Internal Neatness - This sounds strange at first but let me explain. Systems like WordPress have a really interesting mix of PHP, HTML, JavaScript and CSS all churned together. With a static site generator you have a much cleaner separation of HTML/CSS/JS from the underlying generator. If you really need some sort of dynamic content, then you can build a RESTful back end and make calls to it (Use JSONP or Socket.IO). Either way it becomes much similar to build and maintain. All of the rendering and display logic, all of the style and interaction is handled on the front end in just one system. All of the back end logic is in a RESTful API. Much cleaner.
  5. Scalability - You can build a scalable PHP or .net system if you have lots of dollars and lots of folks to work on it and lots of time. Facebook has done it. Using static pages and a CDN still beats it. With hardware scattered across the world serving static content is faster than serving dynamic content. You might say that you don't need that kind of scalability. Most of the time you are correct. What happens when your blog gets listed on digg.com or reddit.com or news.ycombinator.com? If you are trying to attract attention then this is the day that you succeeded. Can your dynamic server stand up to that traffic spike? A CDN based static site can.
  6. Searchability - Inherently designed to work with Google/Bing and other search technologies. The more dynamic a site the more difficult it can be for search engines to index it. A static site skips all of that.
  7. Get Off of the Upgrade Wagon - One of the constant irritations with WordPress is the unending stream of upgrades. You need to do them! Security is important! Then they break something. Aaaarrrrggggg!!!!! Now you have to go in and spend hours debugging what changed and why and fixing some crazy theme or plug in to work. With a static site all you have is HTML/CSS and any JavaScript that you added. Changes to the "go" programming language will not have any effect on the static site generator because it is compiled code. I have compiled code that is 10 years old that is running unchanged on Mac and Linux.

What do you loose when you go to a static site generator?

  1. If you really need the thousands of WordPress plug ins, then you should use WordPress. Fact is most people don't use very many, if any, of the plug ins.
  2. A GUI for configuration for all sorts of stuff. With a static site generator there is a lot less to configure. Basically you have go-templates, HTML5, CSS3 and JavaScript. That is it. (There is 1 configuration file that is about 20 lines long. It is in JSON and lists stuff like "Author" and your "Copyright")

Gen-Site system

I am building a system that addresses the weakness in static site generators. I call it gen-site.

What do you gain with the gen-site system?

  1. Your posts are kept in a "git" repository. This means that you can access the history of every post back to the beginning of time.
  2. Backups occur every day. The backups go to Amazon S3 and then to Amazon Glacier. This is essentially a forever backup. We use strong encryption before sending them to S3. Amazon encrypts them before sending it to Glacier.
  3. Edit your posts anywhere with a modern browser. Note: This feature is still in development. You login to your account on gen-site and use a GUI markdown editor inside a browser. This is a better GUI editor than most current bloging/CMS systems offer.
  4. Tracking of how frequently pages are accessed.
  5. Tracking of which browsers are being used to access pages.

Not ready yet - but getting closer

Gen blog is not ready yet - but I have started to push the code up to github. https://github.com/pschlump/gen-blog . I will change this when it is working a little better.

•       •       •       •       •       •

Summary: # of Words: 1204
Author: Philip J. Schlump
Published On: 2013-10-18

Download code from this articles in .tar.gz for Mac/Linux/Unix or .zip with CR/LF for Windows format.


Before You Go....

Have you read "Unintend Consinsequences"?

"I laughed so hard it hurt..."
    Rod Brown

"Incredibly funny! Incredibly true!"
    Tad Stevens