mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-20 21:31:32 +02:00
Fix Permalink for resource, baseURL with path and canonifyURLs set
Fixes #5226
This commit is contained in:
@@ -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 ""
|
||||
|
Reference in New Issue
Block a user