diff --git a/ginger.cabal b/ginger.cabal
--- a/ginger.cabal
+++ b/ginger.cabal
@@ -2,7 +2,7 @@
 -- documentation, see http://haskell.org/cabal/users-guide/
 
 name:                ginger
-version:             0.1.1.2
+version:             0.1.2.0
 synopsis:            An implementation of the Jinja2 template language in Haskell
 description:         Ginger is Jinja, minus the most blatant pythonisms. Wants
                      to be feature complete, but isn't quite there yet.
@@ -31,6 +31,7 @@
                , bytestring
                , data-default >= 0.5
                , filepath >= 1.3
+               , http-types
                , mtl >= 2.2
                , parsec >= 3.0
                , safe >= 0.3
@@ -38,6 +39,7 @@
                , text
                , transformers >= 0.3
                , unordered-containers >= 0.2.5
+               , utf8-string
                , vector
   hs-source-dirs:      src
   default-language:    Haskell2010
diff --git a/src/Text/Ginger/Run.hs b/src/Text/Ginger/Run.hs
--- a/src/Text/Ginger/Run.hs
+++ b/src/Text/Ginger/Run.hs
@@ -54,6 +54,7 @@
 import Data.Text (Text)
 import Data.String (fromString)
 import qualified Data.Text as Text
+import qualified Data.ByteString.UTF8 as UTF8
 import Control.Monad
 import Control.Monad.Identity
 import Control.Monad.Writer
@@ -66,6 +67,7 @@
 import Data.Scientific as Scientific
 import Data.Default (def)
 import Safe (readMay)
+import Network.HTTP.Types (urlEncode)
 
 -- | Execution context. Determines how to look up variables from the
 -- environment, and how to write out template output.
@@ -148,10 +150,23 @@
             , ("str", fromFunction . unaryFunc $ toGVal . asText)
             , ("sum", fromFunction . variadicNumericFunc 0 $ Prelude.sum)
             , ("truncate", fromFunction . unaryNumericFunc 0 $ Prelude.fromIntegral . Prelude.truncate)
+            , ("urlencode", fromFunction $ gfnUrlEncode)
             ]
 
         gfnRawHtml :: Function (Run m)
         gfnRawHtml = unaryFunc (toGVal . unsafeRawHtml . asText)
+
+        gfnUrlEncode :: Function (Run m)
+        gfnUrlEncode =
+            unaryFunc
+                ( toGVal
+                . Text.pack
+                . UTF8.toString
+                . urlEncode True
+                . UTF8.fromString
+                . Text.unpack
+                . asText
+                )
 
         gfnDefault :: Function (Run m)
         gfnDefault [] = return def
