Jon
Jon

Reputation: 1347

Clean URLs from pages in a custom Jekyll folder

I'm building a Jekyll site made of static pages (e.g. nothing in the _posts directory), and rather than keeping each page in the root directory, I'd like to keep it in a custom pages directory (for organization's sake).

However, I don't want this structure reflected in my URLs, so in my _config.yml I have:

permalink: /:title

With this configuration, my desired URL would be site.com/pagename, but I don't get a rendered page unless I hit site.com/pages/pagename.html.

Could anyone help me configure my build to achieve the former? Thanks!

Upvotes: 4

Views: 639

Answers (2)

Carlos Agarie
Carlos Agarie

Reputation: 4002

Have you tried adding YAML Front Matter to these static pages? For example:

---
title: "pagetitle"
---

This way, Jekyll should recognize it as a Page (instead of a StaticPage) and would use your permalink configuration.

Upvotes: 1

RobertKenny
RobertKenny

Reputation: 3596

These are static pages so the entry in _config.yml is going to be ignored.

From the sounds of it you will need to create a URL rewrite rule. How to do this will depend on the web server that is servering up the pages.

Upvotes: 0

Related Questions