@@ -16,13 +16,17 @@ module Text.Hakyll.File
1616import System.Directory
1717import System.FilePath
1818import Control.Monad
19+import Data.List (isPrefixOf)
1920
2021-- | Auxiliary function to remove pathSeparators form the start. We don't deal
21−-- with absolute paths here.
22+-- with absolute paths here. We also remove $root from the start.
2223removeLeadingSeparator :: FilePath -> FilePath
2324removeLeadingSeparator [] = []
24−removeLeadingSeparator p@(x:xs) | x `elem` pathSeparators = xs
25− | otherwise = p
25+removeLeadingSeparator path
26+ | (head path') `elem` pathSeparators = (tail path')
27+ | otherwise = path'
28+ where path' = if "$root" `isPrefixOf` path then drop 5 path
29+ else path
2630
2731-- | Convert a relative filepath to a filepath in the destination (_site).
2832toDestination :: FilePath -> FilePath