Skip to content
Discussion options

You must be logged in to vote

Here's the solution I reached following the pointers suggested by @kamilkrzyskow ✌️ :

  1. Create a hook to access the blog posts by creating a Python file (say recent_post_hook.py) with the following method:
def on_page_context(context, page, config, nav):
    if page.meta.get("template") != "home.html": return

    context["posts"] = config["plugins"]["material/blog"].blog.posts
    return context
  1. Add it to mkdocs.yml:
hooks:
  - recent_post_hook.py
  1. Access blog posts in a template. In my case, I needed to display the 5 recent blog posts (the blog posts seemed to be already in descending order of the creation date) at the end of the home page. I followed https://github.com/squidfunk/mkdo…

Replies: 3 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@kamilkrzyskow
Comment options

Comment options

You must be logged in to vote
1 reply
@kamilkrzyskow
Comment options

Answer selected by kamilkrzyskow
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants