-
-
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
Allow inclusion of other content in a content file #247
Comments
Happy to take a pull request for this. You would need to create a template function like the list here… which would take a template and content file as input, then render them. Perhaps call it RenderContent(TemplateName, ContentFile) We may want a new template type for these reusable snippets/block/whatever we call them Once that function is written, then we would need to expose it via a custom short code so we can use it in the content files. A good example of this is the highlight short code, defined here Best, -- From: iwishicouldcode notifications@github.com A non-uncommon use case for me is the need to reuse content (say a set of links, or a particular FAQ or etc.) I know one could create a layout for this, but that seems hacky and unintuitive. It would be nice if content files could contain something like {{% "name_of_simple_layout_file" "path_to_some_other_content_file" %}} that would render the mentioned content file with some layout, then include the result. What do you think? — |
This looks like something I may would like to put my hands on. |
See #534
|
👍 |
@cabello did you "put your hands on this"? |
@bep I have not but I am not sure I am the person you intended to message. |
@cabello you are correct ... I think @cburgdorf raised his hands ... |
This issue has been automatically marked as stale because it has not been commented on for at least four months. 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 If this is a feature request, and you feel that it is still valuable, please open a proposal at https://discuss.gohugo.io/. This issue will automatically be closed in four months if no further activity occurs. Thank you for all your contributions. |
Note/Update: This issue is marked as stale, and I may have said something earlier about "opening a thread on the discussion forum". Please don't. If this is a bug and you can still reproduce this error on the latest If this is a feature request, and you feel that it is still relevant and valuable, please tell us why. |
A shortcode with the |
Anyone that stumbles across this issue this is what I did and it seems to work great :
Markdown file : |
I think including content out of the box, without adding any shortcodes, is a valuable addition for a site generator tool. |
@ctron A site generator can only do so much. It's the limitation of the markup language you choose rather than the site generator. Markdown doesn't have a syntax for including whole file contents. But Org mode does. But then, what's wrong with adding a shortcode to get around that Markdown limitation? Please continue this discussion to the Hugo Discourse forum if you are interested. |
Well I don't think using a short code is wrong. I just think that it should be provided as a standard short code. Like |
I'm using a slight modification of @StephenBe's solution:
One thing to note, the paths passed to the shortcode should be relative to the |
The big problem of this way is , the headings of included markdown file will NOT be put into the TOC, that's too bad. |
Works great but it also renders the yaml, is there a way to make it ignore it? |
@crisrojas there is a help forum at discourse.gohugo.io. And if you use the original, not the "slightly modified" version of the code that was shown AFTER the issue was closed three years ago then the yaml is not parsed and displayed. Use Please don't comment on closed issue. Just refer to them in the forum. |
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. |
A not-uncommon use case for me is the need to reuse content (say a set of links, or a particular FAQ or etc.)
I know one could create a layout for this, but that seems hacky and unintuitive. It would be nice if content files could contain something like {{% "name_of_simple_layout_file" "path_to_some_other_content_file" %}} that would render the mentioned content file with some layout, then include the result.
What do you think?
The text was updated successfully, but these errors were encountered: