-
-
Notifications
You must be signed in to change notification settings - Fork 7.6k
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
Link hook has no context to current page #12884
Comments
That's is how it works. I'm guessing a little, but what I think you mean is that if you do something like this in the homepage template: {{ range site.RegularPages }}
{{ .Content }} // the page you as .Page in the render hooks for .Content is "." (e.g. `/posts/page1`) and not $ (the home page)
{{ end }} You expect the Does the above describe the problem? |
You are right. I wasn't aware of that myself but by In fact, I needed |
We recently added support for what I called "scoped content rendering", which should support what you want. We haven't found time to complete the documentation, yet: There are some things that's important to understand:
But with the new {{ range site.RegularPages | first 20 }}
{{ with .Markup "home" }}
{{ .Render.Content }}
{{ end }}
{{ end }} In the above example (given that the named scope is only used on the home page), you can be certain that I'll close this now, I suggest you take further questions at https://discourse.gohugo.io/ |
I'm not totally sure what's your requirements, but I think Hugo's internal link hook template provides a good compromise for link resolution: |
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. |
I have a homepage that I want to customize with render hooks for a certain section. I created the corresponding folder
layouts/glossary/_markup/
and a filerender-link.html
inside. According to the documentation (or at least my understanding of it), in the render hook, I should have access to.Page
that points to the page containing the link.If you put a (debug) script in the
render-link.html
file containingand create a link in the section (glossary in my case), you will see, that
.Page
is the page object of the pointed-to page.So, either one should be done in my opinion
.Page
refers to the page that the link points toPersonally, I think it would be useful to have access to the local page, I see benefits for both solutions.
What version of Hugo are you using (
hugo version
)?I use the NPM package [email protected].
Does this issue reproduce with the latest release?
This is the latest version I can find on NPM and the latest version here on GitHub. I have not build hugo from scratch to test on master.
The text was updated successfully, but these errors were encountered: