diff options
Diffstat (limited to 'helpers')
-rw-r--r-- | helpers/pathspec.go | 8 | ||||
-rw-r--r-- | helpers/url.go | 10 |
2 files changed, 7 insertions, 11 deletions
diff --git a/helpers/pathspec.go b/helpers/pathspec.go index 847029f44..b82ebd992 100644 --- a/helpers/pathspec.go +++ b/helpers/pathspec.go @@ -69,11 +69,9 @@ func NewPathSpecWithBaseBaseFsProvided(fs *hugofs.Fs, cfg config.Provider, baseB ProcessingStats: NewProcessingStats(p.Lang()), } - if !ps.CanonifyURLs { - basePath := ps.BaseURL.Path() - if basePath != "" && basePath != "/" { - ps.BasePath = basePath - } + basePath := ps.BaseURL.Path() + if basePath != "" && basePath != "/" { + ps.BasePath = basePath } return ps, nil diff --git a/helpers/url.go b/helpers/url.go index f167fd3d2..a24f05b12 100644 --- a/helpers/url.go +++ b/helpers/url.go @@ -283,15 +283,13 @@ func AddContextRoot(baseURL, relativePath string) string { } // PrependBasePath prepends any baseURL sub-folder to the given resource -// if canonifyURLs is disabled. -// If canonifyURLs is set, we will globally prepend the absURL with any sub-folder, -// so avoid doing anything here to avoid getting double paths. -func (p *PathSpec) PrependBasePath(rel string) string { - if p.BasePath != "" { +func (p *PathSpec) PrependBasePath(rel string, isAbs bool) string { + basePath := p.GetBasePath(!isAbs) + if basePath != "" { rel = filepath.ToSlash(rel) // Need to prepend any path from the baseURL hadSlash := strings.HasSuffix(rel, "/") - rel = path.Join(p.BasePath, rel) + rel = path.Join(basePath, rel) if hadSlash { rel += "/" } |