diff --git a/README.md b/README.md
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
 A subsite for displaying git information.
 
-[![Hackage](https://img.shields.io/hackage/v/yesod-gitrev.svg)](https://hackage.haskell.org/package/yesod-gitrev) [![Build Status](https://travis-ci.org/DanBurton/yesod-gitrev.svg)](https://travis-ci.org/DanBurton/yesod-gitrev)
+[![Hackage](https://img.shields.io/hackage/v/yesod-gitrev.svg)](https://hackage.haskell.org/package/yesod-gitrev)
 
 You can use the `gitRev` splice (or `tGitRev` typed splice)
 to generate a value of type `GitRev`.
diff --git a/examples/ExampleMain.hs b/examples/ExampleMain.hs
--- a/examples/ExampleMain.hs
+++ b/examples/ExampleMain.hs
@@ -12,7 +12,11 @@
 
 import Yesod.Core
 import Yesod.GitRev
+import ExampleTH (ensureGitContext)
 
+-- In case this is tested outside of a git context
+$ensureGitContext
+
 data Master = Master
   { getGitRev :: GitRev
   }
@@ -25,3 +29,6 @@
 
 main :: IO ()
 main = warp 3000 $ Master $$(tGitRev)
+
+main2 :: IO ()
+main2 = warp 3000 $ Master $(gitRev)
diff --git a/examples/ExampleTH.hs b/examples/ExampleTH.hs
new file mode 100644
--- /dev/null
+++ b/examples/ExampleTH.hs
@@ -0,0 +1,9 @@
+module ExampleTH (ensureGitContext) where
+
+import Language.Haskell.TH (Q, runIO, Dec)
+import System.Process (callProcess)
+
+ensureGitContext :: Q [Dec]
+ensureGitContext = runIO $ do
+  callProcess "git" ["init", "--quiet"]
+  return []
diff --git a/src/Yesod/GitRev/Data.hs b/src/Yesod/GitRev/Data.hs
--- a/src/Yesod/GitRev/Data.hs
+++ b/src/Yesod/GitRev/Data.hs
@@ -2,13 +2,20 @@
 {-# LANGUAGE TemplateHaskell #-}
 {-# LANGUAGE QuasiQuotes #-}
 {-# LANGUAGE TypeFamilies #-}
+{-# LANGUAGE CPP #-}
 
 module Yesod.GitRev.Data where
 
 import GitHash
-import Language.Haskell.TH.Syntax (Lift, Q, TExp, Exp, unTypeQ)
+import Language.Haskell.TH.Syntax (Lift, Q, Exp, unTypeQ)
 import Yesod.Core
 
+#if MIN_VERSION_GLASGOW_HASKELL(9,0,0,0)
+import Language.Haskell.TH (Code, examineCode)
+#else
+import Language.Haskell.TH.Syntax(TExp)
+#endif
+
 -- | You should not construct one of these yourself.
 -- Instead, use gitRev or tGitRev.
 -- Fields added to this record are treated as a minor version bump.
@@ -25,19 +32,32 @@
   }
   deriving Lift
 
+type TSpliceable a =
+#if MIN_VERSION_GLASGOW_HASKELL(9,0,0,0)
+  Code Q a
+#else
+  Q (TExp a)
+#endif
+
 mkYesodSubData "GitRev" [parseRoutes|
 / GitRevR GET
 |]
 
 -- | A typed splice for creating a GitRev.
 -- Example: $$(tGitRev) :: GitRev
-tGitRev :: Q (TExp GitRev)
+tGitRev :: TSpliceable GitRev
 tGitRev = [|| gitRevFromGitInfo $$(tGitInfoCwd) ||]
 
 -- | An untyped splice for creating a GitRev.
 -- Example: $(gitRev) :: GitRev
 gitRev :: Q Exp
-gitRev = unTypeQ tGitRev
+gitRev = unTypeQ . examine $ tGitRev
+  where
+#if MIN_VERSION_GLASGOW_HASKELL(9,0,0,0)
+    examine = examineCode
+#else
+    examine = id
+#endif
 
 -- This function is considered to be "internal".
 -- Changes to this function will not be accounted for in minor version bumps.
diff --git a/yesod-gitrev.cabal b/yesod-gitrev.cabal
--- a/yesod-gitrev.cabal
+++ b/yesod-gitrev.cabal
@@ -1,5 +1,5 @@
 name:                yesod-gitrev
-version:             0.2.1
+version:             0.2.2
 synopsis:
   A subsite for displaying git information.
 author:              Dan Burton
@@ -43,10 +43,13 @@
   main-is: TestExamples.hs
   build-depends:
       base
+    , template-haskell
+    , process
     , yesod-core
     , yesod-gitrev
   other-modules:
       ExampleMain
+      ExampleTH
   default-language: Haskell2010
 
 
