-
-
Notifications
You must be signed in to change notification settings - Fork 7.4k
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 .RenderShortcodes #7297
Comments
This issue has been automatically marked as stale because it has not had recent activity. The resources of the Hugo team are limited, and so we are asking for your help. |
Would this feature, if implemented, render the shortcodes for the current output format? That'd be super great! |
Yes. |
Is this going to get implemented at all any time soon? People keep asking how to build my PR and since no equivalent functionality exists in mainline and @bep outright rejected my PR likely as they felt this was a better way to implement this (and therefore it became the only implementation they'd accept, apparently) I don't have any actual alternative option to get shortcodes processed in JSON output. |
Checking your PR it was rejected not outright for a feeling but for missing formalities. Open an issue, describe and discuss your issue, then if it is deemed a good addition to hugo open a PR referencing that issue number. |
A need for this came up again yesterday: |
This came up again as the potential solution to a forum issue I posted: https://discourse.gohugo.io/t/table-of-contents-render-hook/45352 |
A layouts/shortcodes/include.html shortcode may look like this: ```html {{ $p := site.GetPage (.Get 0) }} {{ $p.RenderShortcodes }} ``` Fixes gohugoio#7297
A layouts/shortcodes/include.html shortcode may look like this: ```html {{ $p := site.GetPage (.Get 0) }} {{ $p.RenderShortcodes }} ``` Fixes gohugoio#7297
A layouts/shortcodes/include.html shortcode may look like this: ```html {{ $p := site.GetPage (.Get 0) }} {{ $p.RenderShortcodes }} ``` Fixes gohugoio#7297
A layouts/shortcodes/include.html shortcode may look like this: ```html {{ $p := site.GetPage (.Get 0) }} {{ $p.RenderShortcodes }} ``` Fixes gohugoio#7297
A layouts/shortcodes/include.html shortcode may look like this: ```html {{ $p := site.GetPage (.Get 0) }} {{ $p.RenderShortcodes }} ``` Fixes gohugoio#7297
A layouts/shortcodes/include.html shortcode may look like this: ```html {{ $p := site.GetPage (.Get 0) }} {{ $p.RenderShortcodes }} ``` Fixes #7297
Tried it out, works great, thanks! |
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 been hit by this issue twice recently -- so I assume this is a problem worth solving (I know there are similar issue, and this also relates to
.RenderString
.Currently we have:
.Content
which gives rendered HTML with shortcodes rendered..RawContent
which gives the raw source excluding front matter. No shortcodes rendered.A common pattern is to include files using
.GetPage
via a shortcode, e.g.:# Title {{< include "foo.md" >}}
Using the
{{<
means you can include just about anything and it will be preserved as-is. But it will not partake in the global rendering context re. table of contents, foot notes etc.You can do this in your shortcode:
And then
# Title {{% include "foo.md" %}}
The above will work but any shortcodes in
foo.md
will not be rendered.Which this issue is all about.
I assume that it makes sense that
.RenderString
uses this method internally by default, but what I need is basically:These should also work:
/cc @regisphilibert @onedrawingperday @digitalcraftsman @moorereason and gang
And yes, this is tightly connected to a
Page
so I think a method makes sense.The text was updated successfully, but these errors were encountered: