output: Remove duplicate layout lookup layouts
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Thu, 25 Jan 2018 08:37:05 +0000 (09:37 +0100)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Thu, 25 Jan 2018 08:37:05 +0000 (09:37 +0100)
This can happen for sections if Type and Section are equal.

Of no real practical difference, but it makes the docs less confusing.

Fixes #4319

output/layout.go

index 5ffc191308df1f7a97004206f001f60cab4a7d8f..206293842cf0543e22f65585b82cc5e0ca987648 100644 (file)
@@ -17,6 +17,8 @@ import (
        "fmt"
        "strings"
        "sync"
+
+       "github.com/gohugoio/hugo/helpers"
 )
 
 // These may be used as content sections with potential conflicts. Avoid that.
@@ -95,6 +97,7 @@ func (l *LayoutHandler) For(d LayoutDescriptor, f Format) ([]string, error) {
        }
 
        layouts = prependTextPrefixIfNeeded(f, layouts...)
+       layouts = helpers.UniqueStrings(layouts)
 
        l.mu.Lock()
        l.cache[key] = layouts