[from now] 2014/08/02 20:21:48

diff --git a/src/main/groovy/gaiden/DocumentSource.groovy b/src/main/groovy/gaiden/DocumentSource.groovy
index 355c717..872c94e 100644
--- a/src/main/groovy/gaiden/DocumentSource.groovy
+++ b/src/main/groovy/gaiden/DocumentSource.groovy
@@ -36,7 +36,7 @@
      */
     PageSource findPageSource(PageReference pageReference) {
         pageSources.find {
-            it.path == pageReference.path
+            pageReference.path in [it.path, it.outputPath]
         }
     }
 }
diff --git a/src/main/groovy/gaiden/PageReferenceFactory.groovy b/src/main/groovy/gaiden/PageReferenceFactory.groovy
index f8ec667..9cf5e6b 100644
--- a/src/main/groovy/gaiden/PageReferenceFactory.groovy
+++ b/src/main/groovy/gaiden/PageReferenceFactory.groovy
@@ -33,7 +33,7 @@ private Path getPath(Path original, PageSource basePageSource) {
             return getCanonicalPath(gaidenConfig.pagesDirectory.resolve(path))
         }

-        return getCanonicalPath(basePageSource.path.resolve(path).toAbsolutePath())
+        return getCanonicalPath(basePageSource.path.resolveSibling(path).toAbsolutePath())
     }

     private static Path getCanonicalPath(Path path) {
diff --git a/src/main/groovy/gaiden/markdown/GaidenLinkRenderer.groovy b/src/main/groovy/gaiden/markdown/GaidenLinkRenderer.groovy
index e0a982b..4a92ecf 100644
--- a/src/main/groovy/gaiden/markdown/GaidenLinkRenderer.groovy
+++ b/src/main/groovy/gaiden/markdown/GaidenLinkRenderer.groovy
@@ -67,19 +67,20 @@
     }

     protected LinkRenderer.Rendering render(String url, String title, String text) {
-        if (UrlUtils.isUrl(url) || isPageSourceExtension(url)) {
+        if (UrlUtils.isUrl(url)) {
             return createRendering(url, title, text)
         }

         def pageReference = pageReferenceFactory.get(Paths.get(url), pageSource)
-
         def targetPageSource = context.documentSource.findPageSource(pageReference)
         if (!targetPageSource) {
-            System.err.println("WARNING: " + messageSource.getMessage("output.page.reference.not.exists.message", [url, pageSource.path]))
+            if (isPageSourceExtension(url)) {
+                System.err.println("WARNING: " + messageSource.getMessage("output.page.reference.not.exists.message", [url, pageSource.path]))
+            }
             return createRendering(url, title, text)
         }

-        def relativePath = pageSource.outputPath.relativize(targetPageSource.outputPath).toString()
+        def relativePath = pageSource.outputPath.parent.relativize(targetPageSource.outputPath).toString()
         return createRendering("${relativePath}${pageReference.hash}", title, text)
     }