summaryrefslogtreecommitdiffstats
path: root/hugolib/page_paths.go
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2017-04-27 09:33:40 +0200
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2017-04-27 09:50:13 +0200
commitfea4fd86a324bf9679df23f8289887d91b42e919 (patch)
treef0f939afeea5188359ab34e55c40e936a3ed3392 /hugolib/page_paths.go
parent656f818867ab3e3dd9a9cc067e6da2e54bd6548b (diff)
hugolib: Avoid index.md in /index/index.html
Hugo 0.20 broke some sites that grouped their blog post and images together in subfolders. This commit re-introduces that behaviour: * If the file base name resolves to the same as the base name for the output type (i.e. "index" for HTML), the user probably meant it, so we treat that as an `uglyURL`, i.e. `my-blog-post-1.md`=> `/my-blog-post-1/index.html` * The main use case for this is to group blog post and images together. * Note that for the top level folder there will be a potential name conflict with a `section` `index.html` (if enabled) * This issue will not be relevant for subfolders in sections * Hugo will soon add support for nested sections, but we will have to find a way to separate them from the rest (`/content/_mysubsection` maybe). Fixes #3396
Diffstat (limited to 'hugolib/page_paths.go')
-rw-r--r--hugolib/page_paths.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/hugolib/page_paths.go b/hugolib/page_paths.go
index 0d1b1c363..f842abdd7 100644
--- a/hugolib/page_paths.go
+++ b/hugolib/page_paths.go
@@ -141,6 +141,15 @@ func createTargetPath(d targetPathDescriptor) string {
isUgly := d.UglyURLs && !d.Type.NoUgly
+ // If the page output format's base name is the same as the page base name,
+ // we treat it as an ugly path, i.e.
+ // my-blog-post-1/index.md => my-blog-post-1/index.html
+ // (given the default values for that content file, i.e. no slug set etc.).
+ // This introduces the behaviour from < Hugo 0.20, see issue #3396.
+ if d.BaseName != "" && d.BaseName == d.Type.BaseName {
+ isUgly = true
+ }
+
if d.Kind != KindPage && len(d.Sections) > 0 {
pagePath = filepath.Join(d.Sections...)
needsBase = false