In my Jekyll project I have a layout file named default. This file is aimed to hold code that is common for any other layout, which helps me to maintain such code more easily.
There are "holes’ ’ in this code that must be filled with content that is specific to the layout file that is calling the default. I need a way to detect which file is calling the default layout, so the proper action is taken.
To understand what I want to do, please consider the (simplified) example bellow:
_includes/post_metadata.html:
<!-- Lines of code to be loaded in the <head> element
of the post_layout.html -->
<link rel="stylesheet" type="text/css" href="post.css">
_layouts/default.html
<!-- Code to be reused in several layouts -->
<html>
<head>
{% if <is_post_layout> %}
{% include post_metadata.html %}
{% endif %}
</head>
<body>
{{ content }}
</body>
</html>
_layouts/post_layout.html
---
layout: default
---
<!-- Contains article-specific HTML structure, but uses the
default layout as a base-->
<article>
{{ content }}
</article>
_posts/2021-09-22-post.md:
---
layout: post_layout
---
<!-- Post content -->
[...]
The final page generated by Jekyll should contain:
<html>
<head>
<link rel="stylesheet" type="text/css" href="post.css">
</head>
<body>
<article>
[...]
</article>
</body>
</html>
So, what code should I use to replace <is_post_layout> to make it work?