Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/gohugoio/hugo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2018-11-15 15:35:28 +0300
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2018-11-15 18:37:11 +0300
commit5df2b79dd2734e9a00ed1692328f58c385676468 (patch)
tree43c116e383b20e8dcec07cb4ab8ac92d77b171d7 /hugolib/paths/paths.go
parent12742bac71c65d65dc56548b643debda94757aee (diff)
Fix Permalink for resource, baseURL with path and canonifyURLs set
Fixes #5226
Diffstat (limited to 'hugolib/paths/paths.go')
-rw-r--r--hugolib/paths/paths.go10
1 files changed, 9 insertions, 1 deletions
diff --git a/hugolib/paths/paths.go b/hugolib/paths/paths.go
index 05d5019d2..7de0d9ffe 100644
--- a/hugolib/paths/paths.go
+++ b/hugolib/paths/paths.go
@@ -34,7 +34,6 @@ type Paths 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
// Directories
@@ -192,6 +191,15 @@ func New(fs *hugofs.Fs, cfg config.Provider) (*Paths, error) {
return p, nil
}
+// GetBasePath returns any path element in baseURL if needed.
+func (p *Paths) GetBasePath(isRelativeURL bool) string {
+ if isRelativeURL && p.CanonifyURLs {
+ // The baseURL will be prepended later.
+ return ""
+ }
+ return p.BasePath
+}
+
func (p *Paths) Lang() string {
if p == nil || p.Language == nil {
return ""