Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jekyll multiple pages using the same template

Tags:

html

jekyll

I'm aware you can use _layouts and in your pages do something like

---
layout: some_layout
title: Home
---

So say I have 20 pages. All using the same template but slightly different content and stuff inside.

Instead of creating 20 different pages.html files with different names and different permalinks.

Is there a way to create 1 page.html and based on the permalink change what's inside the {{ content }}?

like image 257
pourmesomecode Avatar asked Jan 19 '26 19:01

pourmesomecode


1 Answers

Just create your-slug.md files. Let them all use the same layout, like this:

---
layout: some_layout
title: Your title
---

In the layout file (some_layout.html) you put some logic, like this:

{% if page.url contains '/your-slug' %}Put this on the screen.{% endif %}
like image 86
JoostS Avatar answered Jan 21 '26 11:01

JoostS



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!