Skip to content
Grav 2.0 is officially stable. Read the announcement →

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Content & Markdown

Re-useable text/ markdown blocks - best practice?

Started by markus mantel 8 years ago · 3 replies · 1833 views
8 years ago

instead of pasting the same page content (pure text/ markdown) on some (but not all) pages i would rather like to outsource it and include it on demand.

what would you suggest how to do that?

i did it using twig:
{{ include('path-to-snippet.html.twig') | markdown }}

with:
twig:true in the frontmatter.

and:
{% verbatim %}
in the path-to-snippet.html.twig

but i don't especially like the markdown-snippet, which is actual content and therefore should be rather located in pages/, residing in the theme/templates directory as twig template.

8 years ago

Hi @oufloued, I am a big fan (and user) of the Page Inject plugin (https://github.com/getgrav/grav-plugin-page-inject), might be something to check-out too?

Examples:
https://raw.githubusercontent.com/hibbitts-design/grav-skeleton-course-hub-site/master/user/pages/mini-home/fullwidthpage.md

https://raw.githubusercontent.com/hibbitts-design/grav-skeleton-course-hub-site/master/user/themes/course-hub-bootstrap/_demo/advanced/01.home/unit-01/item.md

8 years ago

Hi, you may also find this recent discussion relevant: /forum/general/reuse-blocks-of-content-on-different-pages-t521

8 years ago

indeed. thank you!
(pardon me please for the unexcusable delay)

Suggested topics

Topic Participants Replies Views Activity
Content & Markdown · by Jochen, 8 months ago
6 94 8 months ago
Content & Markdown · by Ton Haarmans, 1 year ago
10 184 1 year ago
Content & Markdown · by Jan L'Am, 1 year ago
4 146 1 year ago
Content & Markdown · by Leonardo, 1 year ago
3 60 1 year ago
Content & Markdown · by belthasar, 1 year ago
4 254 1 year ago