With a frontmatter variable like:
biography = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut sed nunc vitae turpis eleifend tincidunt. In hac habitasse platea dictumst. {{< figure src="/media/spf13.jpg" title="Steve Francia" >}} Pellentesque viverra a tellus in mollis. Sed vitae congue odio, vitae tristique magna. Mauris id fermentum libero, sit amet ultricies metus. "
Provide a template function shortcodify that will render the figure shortcode into the output string.
This would allow shortcodes to be used in frontmatter data, within data file content, and expand the capabilities of Hugo for pages that require more than one 'content' block. See the Sawmill layout technique for an example of this use case, which is already supported by the Forestry.io CMS.
Provide a template function shortcodify that will render the figure shortcode into the output string.
Shortcodify? :-)
The shortcode's API requires a Page, so it couldn't be used in data files, and I think the "more than one content" block needs to be solved differently. I have plans for that. We could possibly, maybe adjust the shortcode's API to allow different things, and make this somehow work, but that is a rather big change and will need more than one person needing it.
Yeah, I was trying to follow the naming model of some of the other functions. 馃槃 Call it whatever you like, I really just want the ability to convert a shortcode in the string into the HTML (or whatever) in the shortcode template.
I didn't realize there was a requirement of a Page, I assumed that it was more of a converter that took some shortcode name and the (positional or named) variables passed into the process, and replaced that shortcode call into the resulting output based on whatever was in the Shortcode file.
I am a bit surprised that more people haven't run into this yet. The Sawmill method makes page building so easy for people. Setting up design components (blocks) of the page and then letting the editor build a page from those components without requiring a developer to build a special layout for every possible combination of blocks the editor might want. It does treat front matter like a little content database, but that seems reasonable.
I would like to know more about your plans for dealing with the need to support more than one content block. That might make this request irrelevant.
If you want to see the project that I am working on and where I have run into this issue, I'd be happy to show you. I don't think my use of Hugo or modular design elements is too far off the beaten path.
I would like to have something in my templates like this to process the string and get what I want out of it. {{ .Section.biography | shortcodify | markdownify }}
The shortcodes in the string would be rendered and then the output string of that function would pipe into the markdownify function to convert any markdown in the string to HTML.
That's the hopes and dreams I have at the moment. 馃槃
and will need more than one person needing it
Including @zivbk1, @budparr and I, that's a miminum of 3 馃槃, but I suspect this will grow to most users by the end of the year as more and more clients/editors are getting used to page builders.
When building a page with blocks of data, most of those are saved as Front Matter. It then falls on the developer to range on those blocks and apply the proper data processing/partial loading etc...
In the context of a very nice to have page builder, Hugo shortcodes are currently unusable by the editor and any search-and-replace workaround cooked up by developers (been there) will never match the reliability and usability of Hugo's shortcode API.
The shortcode's API requires a Page, so it couldn't be used in data files,
Fine by me.
I'm using the Sawmill approach for our clients, and confirm this would be a useful feature for our editors.
Absolutely want this feature, see https://discourse.gohugo.io/t/call-shortcodes-in-markdownified-text/21189 for context. @regisphilibert - got any examples of the search/replace method?
@johndmulhausen I answered in your thread.
The shortcode's API requires a Page
@bep This could simply be a required parameter on the newly introduced shortcodify function. So we always end up with a page.
{{/* layouts/_default/single.html */}}
{{ range .blocks }}
<div class="text">
{{ shortcodify .content $ }}
</div>
{{ end }}
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.
If this is a bug and you can still reproduce this error on the master branch, please reply with all of the information you have about it in order to keep the issue open.
If this is a feature request, and you feel that it is still relevant and valuable, please tell us why.
This issue will automatically be closed in the near future if no further activity occurs. Thank you for all your contributions.
I think it is still relevant and seems like it's getting closer to being implemented.
We should close in favour of #6703 though
I'm ok with that.
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.
If this is a bug and you can still reproduce this error on the master branch, please reply with all of the information you have about it in order to keep the issue open.
If this is a feature request, and you feel that it is still relevant and valuable, please tell us why.
This issue will automatically be closed in the near future if no further activity occurs. Thank you for all your contributions.
Any news on this? im currently stucked on shortcodes not being rendered by markdownify
and I cant also use .RenderString since Im not on The Page Scope but inside a partial.
Hope there is a switch that will trigger markdownify to render shortcodes
Ive made so many shortcodes but is now useless for clients since the only shortcode that can be rendered properly
is image since it is supported natively by markdown.
Well as far as i can understand shortcodes can only be access by a Page ...
is there a possibility that if i convert my templates to use headless bundle and use that as a page
since we can do {{ $headless := .Site.GetPage "/some-headless-bundle" }}
An individual index and value of $headless there contains a Page
In theory .Content would be accessible ...
and the only purpose of that page is to house that markdown section
kinda complex ive been thinking it wholeday but havent implemented it yet...
Im using netlify CMS, it would require me to create a new collection just to house home/contents
then create a relation to fetch that page for just a specific section...
But i hope someone have already create a shortcodify functions :+1:
@goldcoders you should track this one instead #6703
Most helpful comment
Including @zivbk1, @budparr and I, that's a miminum of 3 馃槃, but I suspect this will grow to most users by the end of the year as more and more clients/editors are getting used to page builders.
When building a page with blocks of data, most of those are saved as Front Matter. It then falls on the developer to range on those blocks and apply the proper data processing/partial loading etc...
In the context of a very nice to have page builder, Hugo shortcodes are currently unusable by the editor and any search-and-replace workaround cooked up by developers (been there) will never match the reliability and usability of Hugo's shortcode API.
Fine by me.