[Solved] Creating _index.md for taxonomyTerm pages tags, categories hangs Hugo


#1

Hello,

I was playing around with adding Branch Bundles for Kinds other than regular sections and home.

So I tried adding _index.md as content/tags/_index.md.

But after that, Hugo hangs.

I have uploaded the site to my Sandbox repo; checkout the taxonomyterm-_index-hugo-hang branch.

The build gets stuck at (below log from Netlify):

11:38:33 PM: Cloning into '/tmp/hugo/bin'...
11:38:35 PM: Hugo Static Site Generator v0.38-DEV-904A3D9D:CHROMA-5640F89 linux/amd64 BuildDate: 2018-03-19T13:41:50-0400
11:38:35 PM: Building sites …
12:08:21 AM: Build exceeded maximum allowed runtime

If I delete the _index.md files in the content/tags/ and content/categories/ directories, the build starts happening once again.

My idea was that it was possible to have Branch Bundles for taxonomyTerm pages (so that we can assign, content, front-matter, image resources, etc. to those; just that I tried it out the first time.

On that branch, Hugo hangs on this commit, but starts working again once that commit is reverted (or you check out the master branch of that repo)… Build from master branch, but without the taxonomyTerm Branch Bundles: https://hugo-sandbox.netlify.com/.


If I create a Leaf Bundle (index.md) instead of Branch Bundle (_index.md), Hugo works fine… but then "page" Kind page is created for tags and categories instead of "taxonomyTerm" Kind.


Update 1

Even Branch Bundle for taxonomy Kind page works: https://hugo-sandbox.netlify.com/tags/resources/

Update 2

Actually above statement in “Update 1” is not completely true… Adding content/tags/resources/_index.md worked.

But then Hugo started hanging again when I next added content/categories/miscellaneous/_index.md.

Update 3

As @onedrawingperday suggested, looks like this bug affects taxonomy and taxonomyTerm branch bundles only for tags and categories taxonomies. What’s peculiar is that Hugo seems to hang for one case of taxonomy Kind branch bundle (content/categories/miscellaneous/_index.md), but not another (content/tags/resources/_index.md).

Previous Debug (the “hangs” status in below debug does not apply anymore… everything works!*):

  1. Add content/_index.md … works
  2. Add content/tags/_index.mdhangs
  3. Add content/categories/_index.mdstill hangs
  4. Remove content/tags/_index.md and content/categories/_index.md … works again!
  5. Add content/tags/resources/_index.md … still works! (resources is just one of the tags on that site.)
  6. Add content/categories/miscellaneous/_index.mdhangs again :confused: (miscellaneous is just one of the categories on that site.) … [See taxonomy-_index.md-hugo-hang2 branch]
  7. Remove content/categories/miscellaneous/_index.md … works again!
  8. Add content/projects/_index.md and content/projects/foo/_index.md… both work! – master branch

@bep Hopefully all of this help debug and fix this…

Update 4 (WORKS!)

  • It makes sense to not tag a tag taxonomyTerm page as that page is listing all the tags.
  • It makes sense to not categorize a category taxonomyTerm page as that page is listing all the categories.

With that fix, the hang issue is gone… The debugprint partial recursively shows all the nested pages in .Data.Pages… so short-circuiting taxonomyTerm and taxonomy caused issues.

Successfully created Branch Bundles


#2

I have been using _index.md for taxonomy terms myself for a while, as described in this topic and I never had Hugo hanging because of this use of _index.md

From what I’ve seen it appears that the taxonomy term tags has special meaning in Hugo as does categories. It may be that this bug is relevant for these two terms but I know first hand that this does not apply to custom taxonomy terms e.g. brands


#3

Thank you. Let me just confirm if we are on the same… ahem… page.

From your link, I was led to https://github.com/guayom/hugo-taxonomies/tree/master/content/brands, but there, I see the _index.md for taxonomy Kind pages, not for the taxonomyTerm Kind page content/brands/.

I see Hugo hanging when creating content/tags/_index.md.


#4

We are on the same page.

In one of my projects I use /content/brands/_index.md as well as /content/brands/some-brand/_index.md (for several taxonomy terms of the brands taxonomy) and I am not having problems.

May I suggest you test this with a custom taxonomy other than tags and categories


#5

Thanks! I just tried with a custom taxonomy project, and both content/project/_index.md and content/project/foo/_index.md worked.


#6

I tested that failing branch, and it builds fine for me:

▶ hugo version && hugo
Hugo Static Site Generator v0.37.1 darwin/amd64 BuildDate:

                   | EN
+------------------+-----+
  Pages            | 138
  Paginator pages  |   0
  Non-page files   |  48
  Static files     |  22
  Processed images |   0
  Aliases          |   0
  Sitemaps         |   1
  Cleaned          |   0

Total in 226 ms

▶ hugo version && hugo
Hugo Static Site Generator v0.38-DEV darwin/amd64 BuildDate:

                   | EN
+------------------+-----+
  Pages            | 138
  Paginator pages  |   0
  Non-page files   |  48
  Static files     |  22
  Processed images |   0
  Aliases          |   0
  Sitemaps         |   1
  Cleaned          |   0

Total in 249 ms


#7

Something’s not right… why do we see different number of pages? Your build has no pagination, etc… Can you please confirm you are building the same sandbox repo?

km²~/sandbox/:hugo/sandbox> hugo

                   | EN
+------------------+-----+
  Pages            | 447
  Paginator pages  |  17
  Non-page files   |  49
  Static files     |  25
  Processed images |   4
  Aliases          |   1
  Sitemaps         |   1
  Cleaned          |   0

Total in 4055 ms
km²~/sandbox/:hugo/sandbox> hugo version
Hugo Static Site Generator v0.38-DEV-904A3D9D:CHROMA-5640F89 linux/amd64 BuildDate: 2018-03-19T13:41:50-0400

I see the same on Netlify too:

image


#8

And here’s the failing build log from Netlify (it’s public): https://app.netlify.com/sites/hugo-sandbox/deploys/5ab1d3acefbe5d49b85c2008


#9

Here is the full set of commands:

git clone https://gitlab.com/kaushalmodi/hugo-sandbox --recurse-submodules 
cd hugo-sandbox/  
hugo # works
git checkout taxonomyterm-_index-hugo-hang
hugo # hangs


#10

Yea, I did not know about the submodules …

It hangs for me, too.


#11

So, I’m guessing there is an infinite loop in there somewhere, obviously related to that miscellaneous. I have tested this back to Hugo 0.35… same hang. I hope this is an issue with your templates and not Hugo. It is possible to bite your tail in the templates, which is hard to error handle in a general way.


#12

Hmm, miscellaneous also happens to be the category which I applied to all of those Branch Bundles (Home, taxonomy term, taxonomy),

I’ll debug this more later today… with the home, and taxonomyTerm term pages tagged and categorized with common values, I wonder if that caused the debugprint partial to go haywire…

Step 1 would be to remove all debugprint calls.


#13
  • It makes sense to not tag a tag taxonomyTerm page as that page is listing all the tags.
  • It makes sense to not categorize a category taxonomyTerm page as that page is listing all the categories.

With that fix, the hang issue is gone… The debugprint partial recursively shows all the nested pages in .Data.Pages… so short-circuiting taxonomyTerm and taxonomy caused issues.


#14

Closing

Home, TaxonomyTerm, Taxonomy Branch Bundles

NOTES

  • Don’t tag a page of tags taxonomyTerm Kind, don’t categorize a page of categories taxonomyTerm Kind, and so on.
  • It is OK to tag/categorize pages of taxonomy Kind of tags/categories taxonomy.
  • It is OK to tag/categorize page of home Kind too (home page).
  • You cannot create Leaf Bundles for those page Kinds, else they will auto-convert to page Kind.
  • And the remaining section Kind, anyways by definition is a Branch Bundle.

Confused with Page Kinds? See here.


Here’s how I prevent this infloop from happening again in the hugo-bare-min-theme.


Proposal: Helping catch infloop issues sooner
What markdown editor do you use?
Confused about taxonomy pages