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

Add disableKinds option #2534

Closed
Jos512 opened this Issue Oct 8, 2016 · 14 comments

Comments

Projects
None yet
4 participants
@Jos512

Jos512 commented Oct 8, 2016

Hi,

I'm using hugo_0.17_Windows-64bit.zip. In my config.toml file I've disabled the generation of tag and category pages (my site doesn't need them) as follows:

[taxonomies]
  category = "" 
  tags = ""

This worked on Hugo 0.16 and earlier: no tag and category pages were generated, and no error appeared. With Hugo 0.17, however, I get the following error message:

PS I:\site> hugo server --buildDrafts
Started building sites ...
panic: Node with ID "taxlist--0" in use

goroutine 1 [running]:
panic(0xa19840, 0xc042370740)
        /usr/local/Cellar/go/1.7.1/libexec/src/runtime/panic.go:500 +0x1af
github.com/spf13/hugo/hugolib.(*Site).getOrAddNode(0xc0420022c0, 0xc042370720, 0xa, 0x1, 0x2)
        /Users/spf13/gopath/src/github.com/spf13/hugo/hugolib/site.go:2228 +0x79e
github.com/spf13/hugo/hugolib.(*Site).nodeLookup(0xc0420022c0, 0xc042370700, 0x8, 0x0, 0x1, 0xc042370700)
        /Users/spf13/gopath/src/github.com/spf13/hugo/hugolib/site.go:2264 +0x165
github.com/spf13/hugo/hugolib.(*Site).renderListsOfTaxonomyTerms(0xc0420022c0, 0x1, 0x0, 0x0)
        /Users/spf13/gopath/src/github.com/spf13/hugo/hugolib/site.go:1882 +0x1ca
github.com/spf13/hugo/hugolib.(*HugoSites).preRender(0xc0420123c0, 0x101, 0x0, 0x101, 0x0, 0x1b)
        /Users/spf13/gopath/src/github.com/spf13/hugo/hugolib/hugo_sites.go:419 +0xd1
github.com/spf13/hugo/hugolib.(*HugoSites).Build(0xc0420123c0, 0x101, 0x0, 0x1b, 0x0)
        /Users/spf13/gopath/src/github.com/spf13/hugo/hugolib/hugo_sites.go:225 +0x205
github.com/spf13/hugo/commands.buildSites(0x1, 0x0, 0xa)
        /Users/spf13/gopath/src/github.com/spf13/hugo/commands/hugo.go:666 +0xf7
github.com/spf13/hugo/commands.build(0xc0424a3a9e, 0x1, 0x1, 0xc042332450, 0xc042332450)
        /Users/spf13/gopath/src/github.com/spf13/hugo/commands/hugo.go:467 +0xa0
github.com/spf13/hugo/commands.server(0xe48d20, 0xc0422bdbf0, 0x0, 0x1, 0x0, 0x0)
        /Users/spf13/gopath/src/github.com/spf13/hugo/commands/server.go:164 +0x4e6
github.com/spf13/hugo/vendor/github.com/spf13/cobra.(*Command).execute(0xe48d20, 0xc0422bdbd0, 0x1, 0x1, 0xe48d20, 0xc04
22bdbd0)
        /Users/spf13/gopath/src/github.com/spf13/hugo/vendor/github.com/spf13/cobra/command.go:599 +0x23b
github.com/spf13/hugo/vendor/github.com/spf13/cobra.(*Command).ExecuteC(0xe475c0, 0xb63300, 0x40e514, 0xe503d0)
        /Users/spf13/gopath/src/github.com/spf13/hugo/vendor/github.com/spf13/cobra/command.go:689 +0x36e
github.com/spf13/hugo/commands.Execute()
        /Users/spf13/gopath/src/github.com/spf13/hugo/commands/hugo.go:174 +0x74
main.main()
        /Users/spf13/gopath/src/github.com/spf13/hugo/main.go:26 +0x39

If I change my config.toml file to:

[taxonomies]
  category = "categories" 
  tags = "tags"

Then Hugo 0.17 generates my site fine:

PS I:\site> hugo server --buildDrafts
Started building sites ...
Built site for language en:
10 of 10 drafts rendered
0 future content
0 expired content
18 pages created
0 non-page files copied
0 paginator pages created
4 categories created
0 tags created
total in 90 ms
Watching for changes in I:\site\{data,content,layouts,static,themes}
Serving pages from memory
Web Server is available at http://localhost:1313/ (bind address 127.0.0.1)
Press Ctrl+C to stop

Can I still disable tags and category pages in Hugo 0.17? I'd really like to because I use Hugo not as a blog, and so have no need for tag/category pages.

Thanks,

@bep

This comment has been minimized.

Show comment
Hide comment
@bep

bep Oct 8, 2016

Member

Can I still disable tags and category pages in Hugo 0.17?

This is a regression that will be fixed, but not for 0.17.

Member

bep commented Oct 8, 2016

Can I still disable tags and category pages in Hugo 0.17?

This is a regression that will be fixed, but not for 0.17.

@bep bep added the Bug label Oct 8, 2016

@bep bep added this to the v0.18 milestone Oct 8, 2016

@Jos512

This comment has been minimized.

Show comment
Hide comment
@Jos512

Jos512 Oct 8, 2016

This is a regression that will be fixed, but not for 0.17.

I understand that. Thanks Bep.

Jos512 commented Oct 8, 2016

This is a regression that will be fixed, but not for 0.17.

I understand that. Thanks Bep.

@bep bep changed the title from Hugo 0.17 requires tags & category pages to Hugo 0.17 requires taxonomy definition Oct 8, 2016

@bep

This comment has been minimized.

Show comment
Hide comment
@bep

bep Oct 8, 2016

Member

What you can try is to just use some dummy, but unique names for the taxonomies:

[taxonomies]
  category = "n1" 
  tag = "n2"
Member

bep commented Oct 8, 2016

What you can try is to just use some dummy, but unique names for the taxonomies:

[taxonomies]
  category = "n1" 
  tag = "n2"
@Jos512

This comment has been minimized.

Show comment
Hide comment
@Jos512

Jos512 Oct 8, 2016

Thanks Bep, that indeed suppresses the generation of tags and category pages ("0 n1 created" and "0 n2 created").

PS I:\site> hugo server --buildDrafts
Started building sites ...
Built site for language en:
10 of 10 drafts rendered
0 future content
0 expired content
18 pages created
0 non-page files copied
0 paginator pages created
0 n1 created
0 n2 created
total in 85 ms
Watching for changes in I:\site\{data,content,layouts,static,themes}
Serving pages from memory
Web Server is available at http://localhost:1313/ (bind address 127.0.0.1)
Press Ctrl+C to stop

So for people with the same issue: using a dummy, unique name different from "categories" and "tags" is a viable workaround.

Jos512 commented Oct 8, 2016

Thanks Bep, that indeed suppresses the generation of tags and category pages ("0 n1 created" and "0 n2 created").

PS I:\site> hugo server --buildDrafts
Started building sites ...
Built site for language en:
10 of 10 drafts rendered
0 future content
0 expired content
18 pages created
0 non-page files copied
0 paginator pages created
0 n1 created
0 n2 created
total in 85 ms
Watching for changes in I:\site\{data,content,layouts,static,themes}
Serving pages from memory
Web Server is available at http://localhost:1313/ (bind address 127.0.0.1)
Press Ctrl+C to stop

So for people with the same issue: using a dummy, unique name different from "categories" and "tags" is a viable workaround.

@bep

This comment has been minimized.

Show comment
Hide comment
@bep

bep Oct 16, 2016

Member

I suggest we just add a new flag:

DisableTaxonomies = false
Member

bep commented Oct 16, 2016

I suggest we just add a new flag:

DisableTaxonomies = false
@Jos512

This comment has been minimized.

Show comment
Hide comment
@Jos512

Jos512 Oct 19, 2016

Sounds like a good idea to me. Perhaps the Hugo output can then also be cleaned up. Meaning, when DisableTaxonomies is set to true, then Hugo doesn't have to print..

0 categories created
0 tags created

..each time the site builds.

Would such a flag also affect the usability of categories? (Like in the front matter and when using functions like where) Because I do use categories to organise my content and to generate ordered lists of content; it's just that I have no need for category and tag pages.

Jos512 commented Oct 19, 2016

Sounds like a good idea to me. Perhaps the Hugo output can then also be cleaned up. Meaning, when DisableTaxonomies is set to true, then Hugo doesn't have to print..

0 categories created
0 tags created

..each time the site builds.

Would such a flag also affect the usability of categories? (Like in the front matter and when using functions like where) Because I do use categories to organise my content and to generate ordered lists of content; it's just that I have no need for category and tag pages.

@bep

This comment has been minimized.

Show comment
Hide comment
@bep

bep Oct 19, 2016

Member

Hugo doesn't have to print

Agree.

Member

bep commented Oct 19, 2016

Hugo doesn't have to print

Agree.

@bogem

This comment has been minimized.

Show comment
Hide comment
@bogem

bogem Nov 23, 2016

Contributor

#2649 fixes it, but the idea of disableTaxonomies flag is really cool.

Contributor

bogem commented Nov 23, 2016

#2649 fixes it, but the idea of disableTaxonomies flag is really cool.

@bep

This comment has been minimized.

Show comment
Hide comment
@bep

bep Nov 23, 2016

Member

#2649 fixes it

No it doesn't, it does not provide a way to "turn off" stuff.

This is still useful. But it would be great if we agreed on the naming standard, because we probably want to add some more, eventually.

If we use the Kind type we will get a pretty nice and general solution.

So if we could have a disableKinds = ["taxonomy", "home", "RSS"] etc.

See https://github.com/spf13/hugo/blob/master/hugolib/page.go#L53

Totally not sure about the name of that config var.

Member

bep commented Nov 23, 2016

#2649 fixes it

No it doesn't, it does not provide a way to "turn off" stuff.

This is still useful. But it would be great if we agreed on the naming standard, because we probably want to add some more, eventually.

If we use the Kind type we will get a pretty nice and general solution.

So if we could have a disableKinds = ["taxonomy", "home", "RSS"] etc.

See https://github.com/spf13/hugo/blob/master/hugolib/page.go#L53

Totally not sure about the name of that config var.

@bogem

This comment has been minimized.

Show comment
Hide comment
@bogem

bogem Nov 23, 2016

Contributor

I mean, it fixed the occurred panic, but yes it doesn't disable this stuff

Contributor

bogem commented Nov 23, 2016

I mean, it fixed the occurred panic, but yes it doesn't disable this stuff

@moorereason

This comment has been minimized.

Show comment
Hide comment
@moorereason

moorereason Dec 14, 2016

Contributor

Fleshing out the disableKinds idea.

  • Add disableKinds option as pflag/viper StringSlice
  • Allowed options: home, taxonomy, rss, sitemap, 404
  • Default value: robots
  • Deprecate disable404, disableRSS, disableSitemap
  • Keep enableRobotsTXT since it's disabled by default. If we tried to roll it in here, the default would be disableKinds = [ "robots" ] which could trip people up if they forgot that when trying to disable something else.

Disable Sitemap & 404

disableKinds = [ "sitemap", "404" ]

hugo --disableKinds sitemap,404

Help Message

      --disableKinds            Disable certain kinds of pages (home, taxonomy, rss, sitemap, 404)
or
      --disableKinds            Disable certain kinds of pages

Comments

Internally, I think we'd want to add bools to our global site context or ConfigProvider (if we go that route) so that it would be easy to do if siteConfig.GetBool("disableSitemap") without having to interact with a slice each time.

Contributor

moorereason commented Dec 14, 2016

Fleshing out the disableKinds idea.

  • Add disableKinds option as pflag/viper StringSlice
  • Allowed options: home, taxonomy, rss, sitemap, 404
  • Default value: robots
  • Deprecate disable404, disableRSS, disableSitemap
  • Keep enableRobotsTXT since it's disabled by default. If we tried to roll it in here, the default would be disableKinds = [ "robots" ] which could trip people up if they forgot that when trying to disable something else.

Disable Sitemap & 404

disableKinds = [ "sitemap", "404" ]

hugo --disableKinds sitemap,404

Help Message

      --disableKinds            Disable certain kinds of pages (home, taxonomy, rss, sitemap, 404)
or
      --disableKinds            Disable certain kinds of pages

Comments

Internally, I think we'd want to add bools to our global site context or ConfigProvider (if we go that route) so that it would be easy to do if siteConfig.GetBool("disableSitemap") without having to interact with a slice each time.

@bep

This comment has been minimized.

Show comment
Hide comment
@bep

bep Dec 14, 2016

Member

@moorereason that looks mostly very good. But I think we should just add all Kind types to that list, including robots and section; those may be funky, but if people want to shoot themself in the foot, let them. I kind of appreciate a construction ala this without too much special cases:

renderPage(p *Page) error {
 
    if isDisabled(p.Kind) {
       return nill
    }
}

I think the value of this will be more visible when we start to add a matrix of output files per Kind.

Member

bep commented Dec 14, 2016

@moorereason that looks mostly very good. But I think we should just add all Kind types to that list, including robots and section; those may be funky, but if people want to shoot themself in the foot, let them. I kind of appreciate a construction ala this without too much special cases:

renderPage(p *Page) error {
 
    if isDisabled(p.Kind) {
       return nill
    }
}

I think the value of this will be more visible when we start to add a matrix of output files per Kind.

@bep bep modified the milestones: v0.19, v0.18 Dec 16, 2016

@bep bep changed the title from Hugo 0.17 requires taxonomy definition to Add disableKinds option Jan 2, 2017

@bep bep self-assigned this Feb 18, 2017

bep added a commit to bep/hugo that referenced this issue Feb 18, 2017

@bep bep closed this in 6d2281c Feb 18, 2017

@Jos512

This comment has been minimized.

Show comment
Hide comment
@Jos512

Jos512 Mar 8, 2017

@bep , you mentioned above that Hugo doesn't need to print when kinds are disabled. Has that feature be implemented with disableKinds?

I'm asking because with the following in config.toml

disableKinds = ["section", "taxonomy", "taxonomyTerm"]

[taxonomies]
  category = ""
  tags = ""

I still get the following messages:

Started building sites ...
Built site for language en:
14 of 14 drafts rendered
0 future content
0 expired content
401 regular pages created
1 other pages created
1 non-page files copied
0 paginator pages created
0  created
0  created
total in 1899 ms

But as we discussed above, this "0 created" and "0 created" is redundant. Should this be dropped?


PS I:\site\website> hugo env
Hugo Static Site Generator v0.19 windows/amd64 BuildDate: 2017-02-27T12:36:30+01:00
GOOS="windows"
GOARCH="amd64"
GOVERSION="go1.8"

Jos512 commented Mar 8, 2017

@bep , you mentioned above that Hugo doesn't need to print when kinds are disabled. Has that feature be implemented with disableKinds?

I'm asking because with the following in config.toml

disableKinds = ["section", "taxonomy", "taxonomyTerm"]

[taxonomies]
  category = ""
  tags = ""

I still get the following messages:

Started building sites ...
Built site for language en:
14 of 14 drafts rendered
0 future content
0 expired content
401 regular pages created
1 other pages created
1 non-page files copied
0 paginator pages created
0  created
0  created
total in 1899 ms

But as we discussed above, this "0 created" and "0 created" is redundant. Should this be dropped?


PS I:\site\website> hugo env
Hugo Static Site Generator v0.19 windows/amd64 BuildDate: 2017-02-27T12:36:30+01:00
GOOS="windows"
GOARCH="amd64"
GOVERSION="go1.8"

@bep

This comment has been minimized.

Show comment
Hide comment
@bep

bep Mar 8, 2017

Member

Please use http://discuss.gohugo.io/ for questions/troubleshooting.

Member

bep commented Mar 8, 2017

Please use http://discuss.gohugo.io/ for questions/troubleshooting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment