Reputation: 318
I have a problem which doesnt seem documented at all. When you type a custom url from a Jekyll blog, you can explore the site directory :
http://example.com/category/article (shows the article) -> If someone enters http://example.com/category/ which is not referenced in Jekyll, he can find this :
I would like Jekyll (or htaccess i guess) to only display the pages i actually published. Maybe return a custom 404 page to reroute users. The main problem here is the SEO with Google which indexes this kind of content and it's ugly :)
Upvotes: 2
Views: 816
Reputation: 52829
This because you don't have an index.html file in you folder.
On github pages, you will get a 404 error, not the directory listing.
On another type of host, you can use jekyll-redirect-from and make a 404.html page like this :
---
layout: default
title: 404 Not Foune
permalink: /404.html
redirect_from:
- /category/
- /other/folder/to/protect/
---
<h2>This is a 404 !</h2>
This will then create /category/index.html and /other/folder/to/protect/index.html files that redirect to the 404 page.
.htaccess
Options -Indexes
ErrorDocument 403 /path/from/root/404.html
This is ugly (return a 404 page for a 403 forbiden) but it does the trick.
Upvotes: 3