mirror of
https://github.com/gohugoio/hugo.git
synced 2025-04-29 15:10:35 +03:00
Fix sub-folder baseURL handling for Page resources
I.e. images etc. Fixes #4228
This commit is contained in:
parent
54a89cde69
commit
f25d8a9e17
9 changed files with 136 additions and 52 deletions
|
@ -319,12 +319,11 @@ func AddContextRoot(baseURL, relativePath string) string {
|
|||
// 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 {
|
||||
basePath := p.BaseURL.url.Path
|
||||
if !p.canonifyURLs && basePath != "" && basePath != "/" {
|
||||
if p.BasePath != "" {
|
||||
rel = filepath.ToSlash(rel)
|
||||
// Need to prepend any path from the baseURL
|
||||
hadSlash := strings.HasSuffix(rel, "/")
|
||||
rel = path.Join(basePath, rel)
|
||||
rel = path.Join(p.BasePath, rel)
|
||||
if hadSlash {
|
||||
rel += "/"
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue