2
votes

From the Jekyll docs it says (using .md format):

Clean URLs can also be achieved using the permalink front matter variable. In the example above, using the first method, you can get URL http://example.com/other for the file other.md by setting this at the top of the file: permalink: /other

Here is an example my page front matter:

---
layout: page
title: Contact
permalink: /contact
---

Everything works fine when I'm using jekyll serve but when I build and upload to my static host it doesn't work. The file structure Jekyll outputs doesn't make sense for the functionality it claims from the docs.

.
|-- css/
|-- index.html    # => http://example.com/
└── contact.md    # => http://example.com/contact.html

I want to be able to go to http://example.com/contact and have it show contact.md. I know I could have similar functionality by manually putting my files in folders (and then renaming them all to index.html) like it says in the docs here, but I don't want to have to go through the extra step and I don't prefer the trailing / e.g. http://example.com/other/.

I am using Jekyll 3.0.1


I have found these questions but they don't address the problem I'm facing.

How to link to a page with page.url without the html extension in Jekyll?

How to make all posts have a permalink with custom format "domain.com/blog/title"?

Can Jekyll omit index.html from folder URLs?

2
Have you tried this solution? having permalinks: /:title in the _config.yml, looks like a similar case as my previous answer: stackoverflow.com/questions/31791004/… If it works i'll post an answer :) I have my site set up similar to what you want, where a folder contact will be created in the folder, inside it is an index.htmlmatrixanomaly

2 Answers

2
votes

I think you are doing it correctly, it is just a matter of configuring your webserver properly (assuming it supports removing the extension). It works properly locally cause the built in jekyll webserver can do it by default. The docs have info on this here:

http://jekyllrb.com/docs/permalinks/#extensionless-permalinks

On AWS S3 it says you can host with extensionless urls by uploading files with no extension at all, and then setting the content type to text/html. I don't think it is possible to get jekyll to output contact.html as just contact with no extension. So you get the web server to remove the extension, if it supports that (on s3 I use the trailing /).

This has some interesting info too: https://github.com/jekyll/jekyll/issues/3345

1
votes

I am also using clean permalink in my jekyll blog.

Here is my frontmatter:

---
layout: directory
title: About
permalink: about/
---

Got any different? , it is trailing slash at the end of URL. I know, you don't want to see any trailing slash at the end of URL, but for that you need to use nginx, because Jekyll generate all post/page like this /folder/index.html.