diff --git a/src/Sculpin/Core/Permalink/SourcePermalinkFactory.php b/src/Sculpin/Core/Permalink/SourcePermalinkFactory.php
index <HASH>..<HASH> 100644
--- a/src/Sculpin/Core/Permalink/SourcePermalinkFactory.php
+++ b/src/Sculpin/Core/Permalink/SourcePermalinkFactory.php
@@ -116,7 +116,11 @@ class SourcePermalinkFactory
                 }
                 $permalink = preg_replace('/:filename/', $filename, $permalink);
                 $permalink = preg_replace('/:slug_filename/', $this->normalize($slug ?: $filename), $permalink);
-                $basename = substr($filename, strrpos($filename, '/')+1);
+                if (strrpos($filename, '/') !== -1) {
+                    $basename = substr($filename, strrpos($filename, '/')+1);
+                } else {
+                    $basename = $filename;
+                }
                 $prettyBasename = substr($basename, 0, strrpos($basename, '.'));
                 $permalink = preg_replace('/:basename/', $basename, $permalink);
                 $permalink = preg_replace('/:pretty_basename/', $prettyBasename, $permalink);
Fixes bug with :basename tag in permalinks

When :basename was used for files in the root source directory, one character was removed from the beginning. This fixes this.