[Haskell-cafe] Hosting a static site with Yesod

Tobias Dammers tdammers at gmail.com
Sun Nov 30 19:47:14 UTC 2014


Out of interest; why would you use Yesod for this? It's a great platform
for sure, but way overkill for serving a bunch of static files IMO - all
you need, really, would be a simple single-file Scotty app, I'd think.

On Sat, Nov 29, 2014 at 04:04:47PM +0000, Michael Snoyman wrote:
> I just wrote an answer to this on StackOverflow:
> http://stackoverflow.com/questions/27200701/hosting-a-static-site-with-yesod/27204171#27204171
> 
> On Sat, Nov 29, 2014, 5:43 PM Christopher Reichert <creichert07 at gmail.com>
> wrote:
> 
> >
> >
> > On Sat, Nov 29 2014, Yifan Yu <yvifan at gmail.com> wrote:
> > > Hi all,
> > >
> > > I'm experimenting with Yesod and I've created a simple scaffolding site
> > > with yesod. I've downloaded a bootstrap template site and wish to simply
> > > host this site with yesod. The template site has an index.html and a
> > bunch
> > > of css and js files. This seemly simple task has baffled me. By my
> > > understanding, the site should be placed under the 'static' directory, I
> > > tried to use sendFile to send the index.html file in getHomeR, but only
> > the
> > > content of the that file is displayed, without the css and js. Should I
> > do
> > > this with a Subsite?
> > >
> >
> > You might want to try the question on the Yesod mailing lists if you
> > don't find your answer here.
> >
> > A simple solution would be to just port the index.html to hamlet and put
> > that directly in the ./templates/homepage.hamlet file. The
> > homepage.hamlet file is complimented by a homepage.julius and
> > homepage.lucius file which takes a flavor of javascript and css,
> > respectively. In Yesod, the combination of these files is known as a
> > widget.
> >
> > You can move your javascript and css into those widget files directly or
> > you can put them in your static dir (but your html is served from
> > homepage.hamlet by default in the scaffold).
> >
> > The static directory is already a subsite for static resources (see the
> > config/routes file).
> >
> > Also see the section "widgetFile" in this Yesod Book chapter:
> > http://www.yesodweb.com/book/scaffolding-and-the-site-template
> >
> > If you want to serve the static files as a separate subsite you might
> > find the following links helpful:
> >
> > https://github.com/yesodweb/yesod/wiki/Static-file-subsite-Hello-World
> > https://groups.google.com/forum/#!msg/yesodweb/
> > Cz8hvgiu0d0/l90NGvhAyLEJThis
> >
> > Hope that helps,
> >
> > --
> > Christopher Reichert
> > irc: creichert
> > gpg: C81D 18C8 862A 3618 1376  FFA5 6BFC A992 9955 929B
> > _______________________________________________
> > Haskell-Cafe mailing list
> > Haskell-Cafe at haskell.org
> > http://www.haskell.org/mailman/listinfo/haskell-cafe
> >

> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe



More information about the Haskell-Cafe mailing list