Reputation: 151
When I request a specific URL on a website ran on Jekyll, eg. www.mysite.com/blog.html how does Jekyll know what layout it should render to display blog.html?
I used to work with Django, where there was urls.py file that kept pairs of URL and templates to render for each URL. I'm new to RoR and Jekyll and couldn't find anything similar to urls.py in Jekyll.
Upvotes: 2
Views: 780
Reputation: 18203
You can choose which layout to use for a specific generated page using the YAML frontmatter. From the Jekyll documentation:
_layouts
These are the templates which posts are inserted into. Layouts are defined on a post-by-post basis in the YAML front matter, which is described in the next section. The liquid tag
{{ content }}
is used to inject data onto the page.[...]
index.html and Other HTML/Markdown/Textile Files
Granted that this file has a YAML Front Matter section, it will be transformed by Jekyll. The same will happen for any .html, .markdown, or .textile file in your site’s root directory or directories not listed above.
The YAML front-matter is a section at the top of a file that specifies metadata for that file. It looks something like:
---
layout: post
title: Blogging Like a Hacker
---
Upvotes: 3