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:
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 ""