diff --git a/LICENSE b/LICENSE
new file mode 100644
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,30 @@
+Copyright (c) 2010, Alexander Dunlap.
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+    * Redistributions of source code must retain the above copyright
+      notice, this list of conditions and the following disclaimer.
+
+    * Redistributions in binary form must reproduce the above
+      copyright notice, this list of conditions and the following
+      disclaimer in the documentation and/or other materials provided
+      with the distribution.
+
+    * Neither the name of Alexander Dunlap nor the names of other
+      contributors may be used to endorse or promote products derived
+      from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/Setup.hs b/Setup.hs
new file mode 100644
--- /dev/null
+++ b/Setup.hs
@@ -0,0 +1,2 @@
+import Distribution.Simple
+main = defaultMain
diff --git a/Yesod/Paginate.hs b/Yesod/Paginate.hs
new file mode 100644
--- /dev/null
+++ b/Yesod/Paginate.hs
@@ -0,0 +1,89 @@
+{-# LANGUAGE QuasiQuotes, TemplateHaskell, CPP, TypeFamilies, FlexibleInstances, MultiParamTypeClasses, FlexibleContexts #-}
+-- | Provides a pagination subsite for Yesod.
+--
+-- Route layout:
+--
+-- > /           PaginateHomeR   GET
+-- > /#Int       PaginateStartR  GET
+-- > /#Int/#Int  PaginateR       GET
+--
+-- If no numbers are given, display the items starting from the beginning with the default count. If one number is given,
+-- display the items starting from that index with the default count. If two numbers are given, the first one is the count
+-- and the second is the starting index. (This is so the user can modify the end of the URL to move forward in the pagination.)
+module Yesod.Paginate
+  ( Paginate (..)
+  , PaginateRoute (..)
+  , defaultPaginate
+  , prevLink
+  , nextLink
+  )
+  where
+
+import Yesod
+import Control.Applicative
+import Language.Haskell.TH.Syntax
+
+data Paginate master a = Paginate
+  { pgnDefaultCount :: Int                                                              -- ^ How many items to show per page by default
+  , pgnGetItems     :: Int -> Int -> GHandler (Paginate master a) master [a]            -- ^ Get a certain count of items at a certain offset
+  , pgnItemCount    :: GHandler (Paginate master a) master Int                          -- ^ How many items there are in all
+  , pgnDisplayItems :: Int -> Int -> [a] -> GHandler (Paginate master a) master RepHtml -- ^ Render the items on a page given the count and offset
+  }
+
+mkYesodSub
+  "Paginate master a"
+  [ ClassP ''Yesod [VarT $ mkName "master"]
+  ]
+#if GHC7
+  [parseRoutes|
+#else
+  [$parseRoutes|
+#endif
+/           PaginateHomeR   GET
+/#Int       PaginateStartR  GET
+/#Int/#Int  PaginateR       GET
+|]
+
+getPaginateHomeR :: GHandler (Paginate master a) master RepHtml
+getPaginateHomeR = do
+  pgn <- getYesodSub
+  toMaster <- getRouteToMaster
+  redirect RedirectSeeOther (toMaster (PaginateR (pgnDefaultCount pgn) 0))
+
+getPaginateStartR :: Int -> GHandler (Paginate master a) master RepHtml
+getPaginateStartR start = do
+  pgn <- getYesodSub
+  toMaster <- getRouteToMaster
+  redirect RedirectSeeOther (toMaster (PaginateR (pgnDefaultCount pgn) start))
+
+getPaginateR :: Int -> Int -> GHandler (Paginate master a) master RepHtml
+getPaginateR howmany start = do
+  pgn <- getYesodSub
+  xs <- pgnGetItems pgn howmany start
+  pgnDisplayItems pgn howmany start xs
+
+defaultPaginate
+  :: (YesodPersist master, PersistBackend (YesodDB master (GHandler (Paginate master a) master)), PersistEntity a)
+  => Int                                                                -- ^ Default number of items to show
+  -> [Filter a]                                                         -- ^ Filters to apply
+  -> [Order a]                                                          -- ^ Ordering to apply
+  -> (Int -> Int -> [a] -> GHandler (Paginate master a) master RepHtml) -- ^ Display function
+  -> Paginate master a
+defaultPaginate x fs os d = Paginate
+  { pgnDefaultCount = x
+  , pgnGetItems = \y z -> map snd <$> runDB (selectList fs os y z)
+  , pgnItemCount = runDB (count fs)
+  , pgnDisplayItems = d
+  }
+
+-- | Link to the previous page.
+prevLink :: Paginate master a -> Int -> Int -> Maybe (Route (Paginate master a))
+prevLink p howmany start
+  | start > 0 = Just (PaginateR howmany (max 0 (start-howmany)))
+  | otherwise = Nothing
+
+-- | Link to the next page.
+nextLink :: Paginate master a -> Int -> Int -> GHandler (Paginate master a) master (Maybe (Route (Paginate master a)))
+nextLink p howmany start = go <$> pgnItemCount p where
+  go l | start < l-howmany-1 = Just (PaginateR howmany (start+howmany))
+       | otherwise           = Nothing
diff --git a/yesod-paginate.cabal b/yesod-paginate.cabal
new file mode 100644
--- /dev/null
+++ b/yesod-paginate.cabal
@@ -0,0 +1,36 @@
+-- yesod-markdown.cabal auto-generated by cabal init. For additional
+-- options, see
+-- http://www.haskell.org/cabal/release/cabal-latest/doc/users-guide/authors.html#pkg-descr.
+Name:                 yesod-paginate
+Version:              0.0
+Synopsis:             Pagination for Yesod sites.
+Description:          
+License:              BSD3
+License-file:         LICENSE
+Author:               Alexander Dunlap
+Maintainer:           alexander.dunlap@gmail.com
+Copyright:            (c) 2010 Alexander Dunlap
+Category:             Web, Yesod
+Build-type:           Simple
+Stability:            Alpha
+-- Extra files to be distributed with the package, such as examples or
+-- a README.
+-- Extra-source-files:  
+
+-- Constraint on the version of Cabal needed to build this package.
+Cabal-version:       >=1.6
+
+flag ghc7
+
+Library
+  if flag(ghc7)
+    build-depends:   base                      >= 4.3      && < 5
+    cpp-options:     -DGHC7
+  else
+    build-depends:   base                      >= 4        && < 4.3
+  Exposed-modules:  Yesod.Paginate
+  Build-depends: yesod, template-haskell
+
+source-repository head
+  type:     git
+  location: git://github.com/ajdunlap/yesod-paginate.git
