Adding custom pages for specific kinds of entries

I'm currently using the diary template and would like to make a few adjustments to the structure of the website.

Filtering content on certain pages

Right now, all the posts (or entries) appear in the home page.

I'd like to create a kind metadata for each entry with either blog or work as possible values. So that only the entries with kind = work would appear on the home page, and the entries with kind = blog would be on a dedicated page called (drumroll...) "Blog".

Note that I don't want to use the tags to achieve this result. Entries in blog and work could share some common tags. Hence the need for an additional kind metadata.

Different page rendering depending on the kind of entry

Last but not least, I was wondering if there was an easy way to differentiate the layout of each entry page. For instance, all kind = blog entries could have a dark background or a "Subscribe to newsletter" button at the bottom. Things like that.

Asked 2 years ago • Improve this question
2 replies

Preliminary note: I broke out one of your questions, How to create a new template view? into a separate page. Hope you can understand

I would recommend using custom metadata to accomplish this. For example, to mark a post as a 'blog' post, I'd do this:

Blog: yes

And to mark a post as a 'work' post, I'd do this:

Work: yes

After you've added this metadata to a few posts, you can then adjust your template. For example, consider the list of entries on your site's homepage, located in entries.html:


   Shows when `Blog: yes` metadata is set.

   Shows when `Blog: yes` metadata is NOT set.



You can use this strategy to inject work-or-blog-specific CSS, or JavaScript, or HTML. You can also use this to filter your list of posts. Here's an example which will render a list of the titles of your posts with Blog: yes metadata:

- {{title}} <br>
Answered 2 years ago · Improve this answer

Thank you very much David ! It does the trick

Answered 2 years ago · Improve this answer

Markdown allowed

Question or feedback?

Contact us
How to password-protect a site? Thumbnails on social media? Title in menu vs title on page? Home Page Alt Text for Images

On this page