
Static Sites on Heroku - craigkerstiens
http://anti-pattern.com/2012/6/2/static-sites-on-heroku
======
mixonic
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.

------
smarx
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.

------
MattRogish
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/>

------
johtso
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.

------
programminggeek
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.

~~~
jvc26
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.

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

------
TazeTSchnitzel
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.

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

~~~
TazeTSchnitzel
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

~~~
chrisrhoden
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.

------
whichdan
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.

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

------
bfcapell
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>

~~~
pearkes
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.

~~~
bfcapell
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! :)

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

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

------
jenius
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.

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

~~~
winton
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.

~~~
jaspervdj
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).

------
damian2000
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...](http://xtargets.com/2010/10/04/using-gmail-for-
email-on-a-heroku-managed-domain/)

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

------
shykes
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

------
darkxanthos
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.

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

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

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

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

------
tuananh
I use toto to host my blog on heroku.

