diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2018-01-05 11:07:50 +0100 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2018-01-06 10:29:13 +0100 |
commit | f25d8a9e17fb65fa41dafdcbf0358853d68eaf45 (patch) | |
tree | fd8932fdf88b3774b5773866c5f8ceadea2cc15a /helpers/pathspec.go | |
parent | 54a89cde69c1fcda7afe0ba0f4e0de86f5f69aa5 (diff) |
Fix sub-folder baseURL handling for Page resources
I.e. images etc.
Fixes #4228
Diffstat (limited to 'helpers/pathspec.go')
-rw-r--r-- | helpers/pathspec.go | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/helpers/pathspec.go b/helpers/pathspec.go index 281203712..450391f16 100644 --- a/helpers/pathspec.go +++ b/helpers/pathspec.go @@ -26,6 +26,10 @@ import ( type PathSpec struct { BaseURL + // If the baseURL contains a base path, e.g. https://example.com/docs, then "/docs" will be the BasePath. + // This will not be set if canonifyURLs is enabled. + BasePath string + disablePathToLower bool removePathAccents bool uglyURLs bool @@ -124,6 +128,13 @@ func NewPathSpec(fs *hugofs.Fs, cfg config.Provider) (*PathSpec, error) { ProcessingStats: NewProcessingStats(lang), } + if !ps.canonifyURLs { + basePath := ps.BaseURL.url.Path + if basePath != "" && basePath != "/" { + ps.BasePath = basePath + } + } + publishDir := ps.AbsPathify(cfg.GetString("publishDir")) + FilePathSeparator // If root, remove the second '/' if publishDir == "//" { |