hugo
hugo copied to clipboard
Panic with hugo new if target folder is a symbolic link
What version of Hugo are you using (hugo version
)?
$ hugo version hugo v0.92.2-CDF6A0D6+extended linux/amd64 BuildDate=2022-02-11T14:17:39Z VendorInfo=gohugoio
Does this issue reproduce with the latest release?
Yes
The problem
hugo new
fails if target folder is a symbolic link:
$ hugo new posts/drafts/test/index.md
panic: [BUG] no Page found for "/home/hebron/dev/cavelab-blog/content/posts/drafts/test/index.md"
goroutine 1 [running]:
github.com/gohugoio/hugo/create.(*contentBuilder).applyArcheType(0xc000b76000, {0xc000b60a40, 0x40}, {0xc0005abc58, 0x8})
/root/project/hugo/create/content.go:276 +0x354
github.com/gohugoio/hugo/create.(*contentBuilder).buildFile(0xc000b76000)
/root/project/hugo/create/content.go:244 +0x1ad
github.com/gohugoio/hugo/create.NewContent.func1()
/root/project/hugo/create/content.go:104 +0x297
github.com/gohugoio/hugo/create.NewContent(0xc000115550, {0x0, 0x0}, {0x7ffc6376e528, 0x9702e5})
/root/project/hugo/create/content.go:108 +0x5fe
github.com/gohugoio/hugo/commands.(*newCmd).newContent(0xc0004fac90, 0xc00098ea00, {0xc00081eec0, 0x1, 0x0})
/root/project/hugo/commands/new.go:83 +0x150
github.com/spf13/cobra.(*Command).execute(0xc00098ea00, {0xc00081ee90, 0x1, 0x1})
/go/pkg/mod/github.com/spf13/[email protected]/command.go:856 +0x60e
github.com/spf13/cobra.(*Command).ExecuteC(0xc000996c80)
/go/pkg/mod/github.com/spf13/[email protected]/command.go:974 +0x3bc
github.com/gohugoio/hugo/commands.Execute({0xc00003c0a0, 0x2, 0x2})
/root/project/hugo/commands/hugo.go:92 +0xb4
main.main()
/root/project/hugo/main.go:23 +0x58
Target folder drafts
is a symbolic link.
$ ls content/posts -l
...
lrwxrwxrwx 1 hebron hebron 43 Aug 3 2021 drafts -> '/home/hebron/notes/Second brain/blog/drafts'
The file content/posts/drafts/test/index.md
does get created, but with the following content:
---
title: "Content Placeholder"
_build:
render: never
list: never
publishResources: false
---
This used to work, but has been broken. Not entirely sure in what version it stopped working, but it may have been related to the following change:
Fix path resolution in hugo new https://github.com/gohugoio/hugo/commit/2b01c85d14102353015cf6860d30be3d92964495 @bep https://github.com/gohugoio/hugo/issues/9129
Confirmed. Panic introduced with 9185e11effa682ea1ef7dc98f2943743671023a6.
Run into the same issue, needed to write a workaround bash script facilitating mv
.
Won't fix. See https://github.com/gohugoio/hugo/issues/11556.
Won't fix. See #11556.
@jmooring Just to clarify, is this the correct way to achieve the same result as my symbolic link — using module mount instead?
[module]
[[module.mounts]]
source = '../../notes/Second brain/blog/drafts'
target = 'content/posts/drafts'
[[module.mounts]]
source = 'content'
target = 'content'
It seems to work :)
is this the correct way
Yes. See https://gohugo.io/getting-started/directory-structure/#union-file-system.
is this the correct way
Yes. See https://gohugo.io/getting-started/directory-structure/#union-file-system.
Perfect, thank you. This is indeed a much better solution than the symbolic link.
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.