We are trying to use the blog feature as an readily available mechanism to store “news” items (event announcements, information on papers published etc.). On our homepage, we would thus like to show a short list of say, the latest 5-6 posts with just the title and maybe a date, similar to this
Specifically, I want this list to appear on a website with several other static and dynamic items.
Is there an easy way to achieve this with Grav? And is it possible to do it just in Markdown (such that it can be easily positioned in relation to other entries on a page) or would I have to create a special HTML template for it? I’ve read about twigs being able to do something like this (e.g., Twig Recipes | Grav Documentation), but I am too unfamiliar with Grav/Twigs yet to know exactly how and where I can use such a code.
@MichaelSL,
Is there an easy way to achieve this with Grav?
Sure. See how a blog is build in skeleton Blog Site. The blog/news collection does not need to be shown by the Blog page itself. The collection defined in blog.md, can be accessed from any Twig template and sliced and looped through.
{% set news = page.find('/news').collection() %}
{% if news|length > 0 %}
<ul>
{% for item in news %}
{# display blog items #}
{% endfor %}
</ul>
{% endif %}
And is it possible to do it just in Markdown (such that it can be easily positioned in relation to other entries on a page) […]
Markdown isn’t created to ‘position’ entries. It is very simple tool to create content.
Twig snippets van be embedded into Markdown. However, I wouldn’t embed Twig inside Markdown. Markdown is created to edit content. Twig is being created to design page layout.
There is also is possibility of using so called ‘shortcodes’ with which Markdown can be ‘enriched’. Not sure if the is a shortcode plugin that allows the listing of a collection though.
[…] or would I have to create a special HTML template for it?
I think that would be the best option. And templates can easily be reused and included in Twig or Markdown.