diff --git a/hakyll.cabal b/hakyll.cabal
--- a/hakyll.cabal
+++ b/hakyll.cabal
@@ -1,5 +1,5 @@
 Name:    hakyll
-Version: 3.5.1.0
+Version: 3.5.2.0
 
 Synopsis: A static website compiler library
 Description:
diff --git a/src/Hakyll/Core/Rules.hs b/src/Hakyll/Core/Rules.hs
--- a/src/Hakyll/Core/Rules.hs
+++ b/src/Hakyll/Core/Rules.hs
@@ -172,9 +172,9 @@
     pattern <- rulesPattern <$> ask
     provider <- rulesResourceProvider <$> ask
     group' <- rulesGroup <$> ask
-    return $ filterMatches pattern $ map (toId group') $ resourceList provider
-  where
-    toId g = setGroup g . toIdentifier
+    -- Important: filter with pattern *before* setting the group
+    return $ map (setGroup group') $ filterMatches pattern $
+        map toIdentifier $ resourceList provider
 
 -- | Apart from regular compilers, one is also able to specify metacompilers.
 -- Metacompilers are a special class of compilers: they are compilers which
diff --git a/src/Hakyll/Web/Urls.hs b/src/Hakyll/Web/Urls.hs
--- a/src/Hakyll/Web/Urls.hs
+++ b/src/Hakyll/Web/Urls.hs
@@ -29,7 +29,8 @@
 --
 renderTags' :: [TS.Tag String] -> String
 renderTags' = TS.renderTagsOptions TS.renderOptions
-    { TS.optRawTag = (`elem` ["script", "style"]) . map toLower
+    { TS.optRawTag   = (`elem` ["script", "style"]) . map toLower
+    , TS.optMinimize = (`elem` ["br", "img"])
     }
 
 -- | Convert a filepath to an URL starting from the site root
diff --git a/tests/Hakyll/Core/Rules/Tests.hs b/tests/Hakyll/Core/Rules/Tests.hs
--- a/tests/Hakyll/Core/Rules/Tests.hs
+++ b/tests/Hakyll/Core/Rules/Tests.hs
@@ -8,46 +8,47 @@
 import qualified Data.Set as S
 
 import Test.Framework
-import Test.Framework.Providers.HUnit
 import Test.HUnit hiding (Test)
 
 import Hakyll.Core.Rules
 import Hakyll.Core.Rules.Internal
 import Hakyll.Core.Identifier
+import Hakyll.Core.Identifier.Pattern
 import Hakyll.Core.Routes
 import Hakyll.Core.Compiler
 import Hakyll.Core.Resource.Provider
 import Hakyll.Core.Resource.Provider.Dummy
+import Hakyll.Core.Writable.CopyFile
 import Hakyll.Web.Page
+import TestSuite.Util
 
 tests :: [Test]
-tests =
-    [ testCase "runRules" rulesTest
+tests = fromAssertions "runRules" [case01]
+
+-- | Dummy resource provider
+--
+provider :: IO ResourceProvider
+provider = dummyResourceProvider $ M.fromList $ map (flip (,) "No content")
+    [ "posts/a-post.markdown"
+    , "posts/some-other-post.markdown"
     ]
 
 -- | Main test
 --
-rulesTest :: Assertion
-rulesTest = do
+case01 :: Assertion
+case01 = do
     p <- provider
     let ruleSet = runRules rules p
-    assert $ expected == S.fromList (map fst (rulesCompilers ruleSet))
+    expected @=? S.fromList (map fst (rulesCompilers ruleSet))
   where
     expected = S.fromList
         [ Identifier Nothing "posts/a-post.markdown"
         , Identifier Nothing "posts/some-other-post.markdown"
         , Identifier (Just "raw") "posts/a-post.markdown"
         , Identifier (Just "raw") "posts/some-other-post.markdown"
+        , Identifier (Just "nav") "posts/a-post.markdown"
         ]
 
--- | Dummy resource provider
---
-provider :: IO ResourceProvider
-provider = dummyResourceProvider $ M.fromList $ map (flip (,) "No content")
-    [ "posts/a-post.markdown"
-    , "posts/some-other-post.markdown"
-    ]
-
 -- | Example rules
 --
 rules :: Rules
@@ -63,5 +64,11 @@
         match "posts/*" $ do
             route $ setExtension "html"
             compile getResourceString
+
+    -- Regression test
+    group "nav" $ do
+        match (list ["posts/a-post.markdown"]) $ do
+            route idRoute
+            compile copyFileCompiler
 
     return ()
diff --git a/tests/Hakyll/Web/Urls/Relativize/Tests.hs b/tests/Hakyll/Web/Urls/Relativize/Tests.hs
--- a/tests/Hakyll/Web/Urls/Relativize/Tests.hs
+++ b/tests/Hakyll/Web/Urls/Relativize/Tests.hs
@@ -13,7 +13,7 @@
 tests = fromAssertions "relativizeUrls"
     [ "<a href=\"../foo\">bar</a>" @=?
         relativizeUrls ".." "<a href=\"/foo\">bar</a>"
-    , "<img src=\"../../images/lolcat.png\"></img>" @=?
+    , "<img src=\"../../images/lolcat.png\" />" @=?
         relativizeUrls "../.." "<img src=\"/images/lolcat.png\" />"
     , "<a href=\"http://haskell.org\">Haskell</a>" @=?
         relativizeUrls "../.." "<a href=\"http://haskell.org\">Haskell</a>"
diff --git a/tests/Hakyll/Web/Urls/Tests.hs b/tests/Hakyll/Web/Urls/Tests.hs
--- a/tests/Hakyll/Web/Urls/Tests.hs
+++ b/tests/Hakyll/Web/Urls/Tests.hs
@@ -15,8 +15,8 @@
     [ fromAssertions "withUrls"
         [ "<a href=\"FOO\">bar</a>" @=?
             withUrls (map toUpper) "<a href=\"foo\">bar</a>"
-        , "<img src=\"OH BAR\">" @=?
-            withUrls (map toUpper) "<img src=\"oh bar\">"
+        , "<img src=\"OH BAR\" />" @=?
+            withUrls (map toUpper) "<img src=\"oh bar\" />"
 
         -- Test escaping
         , "<script>\"sup\"</script>" @=?
