aboutsummaryrefslogtreecommitdiffhomepage
path: root/hugolib/filesystems
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <[email protected]>2021-11-08 11:50:51 +0100
committerBjørn Erik Pedersen <[email protected]>2021-11-08 14:10:46 +0100
commit2b01c85d14102353015cf6860d30be3d92964495 (patch)
treede5dbb36e0dcb6478d920af8ae94884d6571af06 /hugolib/filesystems
parentc09f5c5fd35c03de0444928ada3ce1c5a214b321 (diff)
downloadhugo-2b01c85d14102353015cf6860d30be3d92964495.tar.gz
hugo-2b01c85d14102353015cf6860d30be3d92964495.zip
Fix path resolution in hugo new
With theme and project with content directories and command on the form `hugo new posts/test.md`. Fixes #9129
Diffstat (limited to 'hugolib/filesystems')
-rw-r--r--hugolib/filesystems/basefs.go11
1 files changed, 7 insertions, 4 deletions
diff --git a/hugolib/filesystems/basefs.go b/hugolib/filesystems/basefs.go
index cfbd295ba..939d88459 100644
--- a/hugolib/filesystems/basefs.go
+++ b/hugolib/filesystems/basefs.go
@@ -157,11 +157,14 @@ func (b *BaseFs) AbsProjectContentDir(filename string) (string, string) {
if !isAbs {
// A filename on the form "posts/mypage.md", put it inside
// the first content folder, usually <workDir>/content.
- // The Dirs are ordered with the most important last, so pick that.
+ // Pick the last project dir (which is probably the most important one).
contentDirs := b.SourceFilesystems.Content.Dirs
- firstContentDir := contentDirs[len(contentDirs)-1].Meta().Filename
- return filename, filepath.Join(firstContentDir, filename)
-
+ for i := len(contentDirs) - 1; i >= 0; i-- {
+ meta := contentDirs[i].Meta()
+ if meta.Module == "project" {
+ return filename, filepath.Join(meta.Filename, filename)
+ }
+ }
}
return "", ""