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

page.TableOfContents hangs #10791

Closed
jmooring opened this issue Mar 4, 2023 · 6 comments · Fixed by #10793
Closed

page.TableOfContents hangs #10791

jmooring opened this issue Mar 4, 2023 · 6 comments · Fixed by #10793

Comments

@jmooring
Copy link
Member

jmooring commented Mar 4, 2023

hugo v0.112.0-DEV-f56ce01ae1a3e5b399410ea8876ebc7321204edd+extended linux/amd64 BuildDate=2023-03-04T21:04:01Z

Error: Error building site: "/home/jmooring/code/hugo-testing/content/_index.md:1:1": timed out initializing value. You may have a circular loop in a shortcode, or your site may have resources that take longer to build than the timeout limit in your Hugo config file.

markdown

{{< toc >}}

layouts/shortcodes/toc.html (no problems)

{{ .Page.TableOfContents }}

layouts/shortcodes/toc.html (error / timed out)

{{ page.TableOfContents }} 

Sorry.

@jmooring jmooring changed the title page.TableOfContents page.TableOfContents hangs Mar 4, 2023
@bep
Copy link
Member

bep commented Mar 4, 2023

I willl look at this, but:

{{ .Page.TableOfContents }}
{{ page.TableOfContents }}

The two above isn't the same thing unlsess .Page == page.

@bep
Copy link
Member

bep commented Mar 4, 2023

OK; I now understand what's happening.

There's a special construct for shortcodes which allows calling .TableOfContents on itself. That isn't available on the pageso to speak.

So,

  • your construct is creating an infinite loop, and that is not something that I can fix (or: want is probably a better word)
  • but it's safe to use .Fragments to create the same ToC, assuming you use the correct delimiter.

@bep bep closed this as completed Mar 4, 2023
@bep
Copy link
Member

bep commented Mar 4, 2023

Well, it's not very hard to fix -- but it's not a bug.

@bep bep reopened this Mar 4, 2023
@bep bep added this to the v0.112.0 milestone Mar 4, 2023
@jmooring
Copy link
Member Author

jmooring commented Mar 4, 2023

It should be very far down on your list.

@bep
Copy link
Member

bep commented Mar 5, 2023

Also,

{{ page.TableOfContents }} 

From a shortcode doesn't make much sense as you currently will get the ToC of the first page that calls .Content which may or may be a totally different page than you think it is. That particular problem may be fixable (and that would be useful), but that's certainly not "today".

bep added a commit to bep/hugo that referenced this issue Mar 5, 2023
@bep bep modified the milestones: v0.112.0, v0.111.2 Mar 5, 2023
@bep bep closed this as completed in #10793 Mar 5, 2023
bep added a commit that referenced this issue Mar 5, 2023
@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 Mar 27, 2023
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.

2 participants