Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression with "hugo new" from a theme #9129

Closed
bep opened this issue Nov 5, 2021 · 9 comments · Fixed by #9144
Closed

Regression with "hugo new" from a theme #9129

bep opened this issue Nov 5, 2021 · 9 comments · Fixed by #9144
Assignees
Milestone

Comments

@bep
Copy link
Member

bep commented Nov 5, 2021

See https://discourse.gohugo.io/t/can-you-use-markdown-files-for-default-content-in-a-theme/35447

@bep bep self-assigned this Nov 5, 2021
@bep bep added the Bug label Nov 5, 2021
@bep bep added this to the v0.89.1 milestone Nov 5, 2021
@danielfdickinson
Copy link

FYI (in case it gives some clues to check with the listed issue) I'm working on a minimal reproducible test case for a related (but different) bug with hugo new. For obvious reasons I suspect the archetype-related changes. I will create a bug report once I have the test case created. (Hugo in my case in running in WSL2, with VSCode running on Windows 10). The site is a Hugo module, but the theme is only available as a git submodule, and I am mounting other modules in order to import their README.md files as assets to use in pages on the site. The issue I have is related to having both the site's content -> content mount and one module that mounts content/docs -> content/some/other/dir/docs.

@bep bep modified the milestones: v0.89.1, v0.90 Nov 5, 2021
@danielfdickinson
Copy link

danielfdickinson commented Nov 5, 2021

Preface

It turns out the case I have is the same bug. I now have a repo at https://github.com/danielfdickinson/hugo-mounted-content-subdir-bug-0-89 for demonstrating the issue.

Seeing the issue using the repository

  1. git clone https://github.com/danielfdickinson/hugo-mounted-content-subdir-bug-0-89.git
  2. (Probably optional): hugo server
  3. See that the site is generated correctly by browsing to http://localhost:1313/
  4. Ctrl-C
  5. hugo new post/a-new-post.md
  6. See:
    Error: mkdir /tmp/hugo_cache/modules/filecache/modules/pkg/mod/github.com/danielfdickinson/netlify-new-oldnew-mashup/example!site@v0.0.0-20211013045709-e4253b573e12/content/docs/post/: permission denied
    
  7. hugo mod vendor
  8. hugo new post/another-new-post.md
  9. See:
    panic: [BUG] no Page found for "/home/daniel/webdev/debug/verify-steps-content-subdir-bug/_vendor/github.com/danielfdickinson/netlify-new-oldnew-mashup/exampleSite/content/docs/post/another-new-post.md"
    
    goroutine 1 [running]:
    github.com/gohugoio/hugo/create.(*contentBuilder).applyArcheType(0xc00047c180, {0xc000812e70, 0xa9}, {0xc0007a46c0, 0xa})
            /root/project/hugo/create/content.go:268 +0x354
    github.com/gohugoio/hugo/create.(*contentBuilder).buildFile(0xc00047c180)
            /root/project/hugo/create/content.go:237 +0x1ad
    github.com/gohugoio/hugo/create.NewContent.func1()
            /root/project/hugo/create/content.go:100 +0x297
    github.com/gohugoio/hugo/create.NewContent(0xc000465760, {0x0, 0x0}, {0x7ffd5d2ec085, 0x66f045})
            /root/project/hugo/create/content.go:104 +0x5f8
    github.com/gohugoio/hugo/commands.(*newCmd).newContent(0xc00049bbc0, 0xc0003a2000, {0xc000139d50, 0x1, 0x0})
            /root/project/hugo/commands/new.go:83 +0x150
    github.com/spf13/cobra.(*Command).execute(0xc0003a2000, {0xc000139d20, 0x1, 0x1})
            /go/pkg/mod/github.com/spf13/cobra@v1.2.1/command.go:856 +0x60e
    github.com/spf13/cobra.(*Command).ExecuteC(0xc0006e8780)
            /go/pkg/mod/github.com/spf13/cobra@v1.2.1/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
    

The relevant config:

From:

https://github.com/danielfdickinson/hugo-mounted-content-subdir-bug-0-89/blob/dce95ec1364dac9851d1f2910bb2cdce3f3130c5/config.toml#L62

to the end of that file.

[module]

  [[module.mounts]]
    source = 'content'
    target = 'content'

  [[module.mounts]]
    source = 'static'
    target = 'static'

  [[module.mounts]]
    source = 'layouts'
    target = 'layouts'
  [[module.mounts]]
    source = 'data'
    target = 'data'

  [[module.mounts]]
    source = 'assets'
    target = 'assets'

  [[module.mounts]]
    source = 'i18n'
    target = 'i18n'

  [[module.mounts]]
    source = 'archetypes'
    target = 'archetypes'

  [[module.imports]]
    ignoreConfig = true
    ignoreMounts = true
    path = "github.com/danielfdickinson/hugo-debug-tables"

    [[module.imports.mounts]]
      source = "static"
      target = "static"

    [[module.imports.mounts]]
      source = "layouts"
      target = "layouts"

    [[module.imports.mounts]]
      source = "data"
      target = "data"

    [[module.imports.mounts]]
      source = "assets"
      target = "assets"

    [[module.imports.mounts]]
      source = "README.md"
      target = "assets/README-debug-tables.md"

    [[module.imports.mounts]]
      source = "i18n"
      target = "i18n"

    [[module.imports.mounts]]
      source = "archetypes"
      target = "archetypes"

  [[module.imports]]
    path = "github.com/danielfdickinson/hugo-minimal-test"

    [[module.imports.mounts]]
      source = "static"
      target = "static"

    [[module.imports.mounts]]
      source = "layouts"
      target = "layouts"

    [[module.imports.mounts]]
      source = "data"
      target = "data"

    [[module.imports.mounts]]
      source = "assets"
      target = "assets"

    [[module.imports.mounts]]
      source = "i18n"
      target = "i18n"

    [[module.imports.mounts]]
      source = "archetypes"
      target = "archetypes"

  [[module.imports]]
    path = "github.com/danielfdickinson/netlify-new-oldnew-mashup/exampleSite"
    ignoreConfig = true
    ignoreImports = true

    [[module.imports.mounts]]
      source = "content/docs"
      target = "content/test-docs"

@danielfdickinson
Copy link

Oh, and that was using Hugo 0.89.1 on WSL2 on Windows 10.

@eric-pierce
Copy link

Thanks @danielfdickinson - confirming I have the same issue. I'm using the FeelIt theme

@kansaichris
Copy link

kansaichris commented Nov 8, 2021

@bep Here's another set of step-by-step instructions to reproduce the bug with a new Hugo site:

$ hugo new site lorem
Congratulations! Your new Hugo site is created in /Users/chris/Sites/lorem.

Just a few more steps and you're ready to go:

1. Download a theme into the same-named folder.
   Choose a theme from https://themes.gohugo.io/ or
   create your own with the "hugo new theme <THEMENAME>" command.
2. Perhaps you want to add some content. You can add single files
   with "hugo new <SECTIONNAME>/<FILENAME>.<FORMAT>".
3. Start the built-in live server via "hugo server".

Visit https://gohugo.io/ for quickstart guide and full documentation.
$ cd lorem
$ hugo new theme ipsum
Creating theme at /Users/chris/Sites/lorem/themes/ipsum
$ echo "theme = 'ipsum'" >> config.toml
$ mkdir themes/ipsum/content
$ hugo new posts/test.md
panic: [BUG] no Page found for "/Users/chris/Sites/lorem/themes/ipsum/content/posts/test.md"

goroutine 1 [running]:
github.com/gohugoio/hugo/create.(*contentBuilder).applyArcheType(0xc000bca000, {0xc000168340, 0x3c}, {0xc0003939c0, 0xa})
	github.com/gohugoio/hugo/create/content.go:253 +0x354
github.com/gohugoio/hugo/create.(*contentBuilder).buildFile(0xc000bca000)
	github.com/gohugoio/hugo/create/content.go:222 +0x1ad
github.com/gohugoio/hugo/create.NewContent(0xc00016f600, {0x0, 0x0}, {0x7ffeefbffc49, 0x41a9385})
	github.com/gohugoio/hugo/create/content.go:98 +0x80d
github.com/gohugoio/hugo/commands.(*newCmd).newContent(0xc000717dd0, 0xc0001f0c80, {0xc00059bbb0, 0x1, 0x0})
	github.com/gohugoio/hugo/commands/new.go:83 +0x150
github.com/spf13/cobra.(*Command).execute(0xc0001f0c80, {0xc00059bb80, 0x1, 0x1})
	github.com/spf13/cobra@v1.2.1/command.go:856 +0x60e
github.com/spf13/cobra.(*Command).ExecuteC(0xc000ab8f00)
	github.com/spf13/cobra@v1.2.1/command.go:974 +0x3bc
github.com/gohugoio/hugo/commands.Execute({0xc00011e0a0, 0x2, 0x2})
	github.com/gohugoio/hugo/commands/hugo.go:92 +0xb4
main.main()
	github.com/gohugoio/hugo/main.go:23 +0x58

I'm running hugo v0.89.0+extended darwin/amd64 and go1.17.2 darwin/amd64 on macOS 10.15.7 Catalina.

Hope this helps!

@bep bep modified the milestones: v0.90, v0.89.2 Nov 8, 2021
@bep bep removed the CantReproduce label Nov 8, 2021
@bep
Copy link
Member Author

bep commented Nov 8, 2021

OK, I will fix this -- but the workaround is to include the "content" part in the command, e.g.:

hugo new content/posts/test.md

bep added a commit to bep/hugo that referenced this issue Nov 8, 2021
With theme and project with content directories and command on the form `hugo new posts/test.md`.

Fixes gohugoio#9129
@danielfdickinson
Copy link

First, thank you for the fix!

A note though:

OK, I will fix this -- but the workaround is to include the "content" part in the command, e.g.:

hugo new content/posts/test.md

For me that just added content to error message (i.e. it didn't workaround the issue). Since there is a fix in progress it's not a big deal, but I thought I should mention it.

bep added a commit to bep/hugo that referenced this issue Nov 8, 2021
With theme and project with content directories and command on the form `hugo new posts/test.md`.

Fixes gohugoio#9129
@bep bep closed this as completed in #9144 Nov 8, 2021
bep added a commit that referenced this issue Nov 8, 2021
With theme and project with content directories and command on the form `hugo new posts/test.md`.

Fixes #9129
@kansaichris
Copy link

Thanks, @bep, that did the trick! ✨

@github-actions
Copy 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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 14, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants