Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Static Sites on Heroku (anti-pattern.com)
35 points by craigkerstiens on June 3, 2012 | hide | past | favorite | 39 comments


I'm required by bootstrapper law to mention a project I'm working to get out of beta now:

http://spintoapp.com

Spinto is Git-based, like Heroku, and uses Jekyll with pre-processors for Sass/Scss (and Compass, Bourbon), Less & CoffeeScript. I agree with Brandon that FTP is hopelessly out of date and frustrating. Even more than that, I think there is madness in the idea that you need a database backend for your website to let somebody else change a comma, or an image (sometimes you need full-blown-CMS, but not always).

I'm trying to make a static websites easier for us to create, deploy, and collaborate on. Feedback _always_ appreciated.


Disclaimer: I'm a founder of Site44.

Like some of the commenters here, I looked around for simple static website hosting when I was trying to find a new home for my blog. I considered Heroku, GitHub Pages, and S3. Heroku didn't seem particularly optimized for static hosting (e.g., dyno spin-up time), and GitHub Pages lacked some flexibility (like custom mime types for my extension-less URLs). S3 doesn't handle things like sending gzipped content to only browsers that support it. Ultimately, my cofounder and I decided to build our own solution based on Dropbox: http://www.site44.com.

Site44 is in a private beta now, but we're hoping to move to a public beta very soon. I'd love to get some feedback from HN. The basic idea is that when you create a site (<foo>.site44.com or a custom domain), we create a folder for you in Dropbox, and then you publish by just modifying the contents of that folder.


Another option is Github pages. I host my blog there for free and have had posts featured on HN front page - served with nary a slowdown or github sending me a bill. It's awesome.

Github pages support a point-and-click interface (which is not likely what you want) but with a tiny amount of setup supports Jekyll https://help.github.com/articles/using-jekyll-with-pages / Octopress (what I use) http://octopress.org/docs/deploying/github/


This is a much cleaner way of serving static sites on Heroku: http://kennethreitz.com/static-sites-on-heroku-cedar.html

Using this technique you can even use .htaccess files.


You know, static hosting works really great on Amazon S3, as long as you don't need a .htaccess file. On all of my jekyll sites I use S3 now and there's even a jekyll-s3 gem that makes pushing your site up to S3 painless. The nice thing about using S3 is you don't have to wait for Heroku instance start up if it's not a high traffic site.


We also host our static site on S3, it costs us $0.12/month. Here's how we do it: http://blog.shopforcloud.com/2012/04/how-to-host-your-site-o...



The only issue with S3 I've found is the lack of naked domain support, so you need another service for redirects to your *.domain.tld.


If you register your domain through NameCheap and use their DNS hosting, HTTP redirects from naked domains are included.


I am using S3 also and it is surprisingly easy. For a small site the cost is close to nothing.


Heroku for a static site? Sounds like overkill. On my VPS I just do this:

1. Have public git repo, clone on server

2. Run nginx pointing to htdocs folder in git repo

3. When I want to deploy, ssh in and git pull

Works just fine. Sure, it's a public site on GitHub, but I could just as easily run a git server.


I just git push to the server from my laptop over SSH. No need for a git server (or Github, for that matter).


I should really try that... thanks!

Edit: Oh wow, I didn't realise I could just do this:

  git push ssh://example.com/git/repo


SSH is the transport you're using when you use github.

git@github.com:git/repo.git tells git to SSH using the 'git' user.


This is what I do. Works great!


can you explain more about the nginx thing? Since it's a GitHub repo, why you need a web server?


Oh, I guess I could use GitHub hosting, but I wanted to host it on my own server. (I actually have a good reason to - I needed to access a WebSocket server on the same origin)


I think the big advantage for people wanting to host a site on Heroku is they explicitly DON'T need their "own server".


I don't see the advantage of that. For small static sites I don't think it's much more hassle to put CloudFlare in front of your server. The advantage of such services is scaling up dynamic sites easily.


Isn't Heroku a mediocre option for a static site unless you're paying? If the site isn't accessed for a while they spin down your EC2 instance, and it takes a few seconds to get it back online.


My thought exactly. The 5-10 second lag involved in waking up a Heroku instance is a total drag for low-volume sites.


Two weeks ago I was looking for this. This is the easiest way I found to do it:

heroku create myproject --stack cedar --buildpack https://github.com/pearkes/heroku-buildpack-static


Ha! I never thought anyone would use that. It's basically a simple fork of their PHP buildpack that stops caring if it's PHP and just serves off of Apache. Perhaps I should clean it up.

I was also experimenting with a Pelican buildpack (a python Jekyll): https://github.com/pearkes/heroku-buildpack-pelican

You deploy you markdown files and it generates your html in the deploy process.


I tried a few other buildpacks like the nginx ones, in the end this was the only one that didn't force me to configure or adapt anything, just worked, so thanks a lot! :)


No worries! I fixed it all up so it should be much more concise then it was. Still no configuration!


It's exactly what is in Heroku's documentation: https://devcenter.heroku.com/articles/static-sites-on-heroku.


There's an even easier way to do static sites on heroku and have them compiled for you - use stasis (http://stasis.me) - I've built a framework on top of stasis and have been using it for months, as part of very large production sites, and it's been extremely stable and super easy to use.

All you need to do to get them working on heroku is include a super basic config.ru file, and you're all set. The files compile into a public folder which heroku uses to serve them.


What's the difference in using nanoc to do that?


I am the creator of Stasis. Compare the sheer length of docs for nanoc (http://nanoc.stoneship.org/docs) to those of Stasis (http://stasis.me), and keep in mind that Stasis can do anything that Nanoc does.


This is not the case, not by far. nanoc is aimed at building complex sites and hence has a lot more features than Stasis. Some examples:

- Items can contain arbitrary metadata in nanoc

- You can trivially build multiple representations of a single item in nanoc (e.g. a PDF/txt/html representation of a single markdown file)

- Dependency tracking in nanoc is fully automatic (no need to specify priorities)

- Nanoc is easily extensible using custom filters, custom deployers, custom helpers and more

Statis and nanoc have a different audience. To me, Stasis seems to be aimed at simpler, smaller sites, while nanoc is aimed at much more featureful sites. It is a good thing to have a lot of documentation (nanoc is frequently cited as a good example of how documentation should be handled).


Nice, but what about a mail server on your custom domain? I think its not that easy according to this post anyway ... http://xtargets.com/2010/10/04/using-gmail-for-email-on-a-he...


Adding MX records for gmail and adding A records / CNAMEs for Heroku are pretty much orthogonal. They shouldn't conflict with each other.


Another option is dotCloud's static service: http://docs.dotcloud.com/services/static/

  $ cat >>dotcloud.yml <<eof
  www:
    type: static
  $ dotcloud push myapp
  $ dotcloud url myapp.www


Doing it with Sinatra w/ no routes and just using the public folder seems easier IMO but the php method another commenter mentioned sounds like the best! I'll be doing that from now on methinks.


There is a more easy way: Just name your index.html to index.php and you can use a full featured Apache Webserver.


Loading the entire file into memory first seems like an antipattern. Doesn't Rack support lazy evaluation?


Sounds like an anti-pattern to me. That said, I do host some static sites on heroku.


$35/month for a static site? seems like overkill, no?


I use toto to host my blog on heroku.




Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: