Before I knew about this file called .htaccess, I was trying to figure out a way to stop people from visiting my asset directory pages. If you don’t know what I mean, have you ever seen a page that looks like this?
Many servers, by default, allow a user to browse the files of whatever directory they specify, unless there is an index.html file in that directory. If the index file exists, that will be shown instead. My original idea was to make a build script that would automatically generate and place these index files in places where no index files existed. I got it working, too! However, shortly after I finished the script, I learned that I could add this line to my .htaccess file and get the exact same effect:
Crazy, right? Well, if you don’t have access to a .htaccess file on your website, and you use Jekyll (or you just want to see how it works), here’s the source.
You can also find the source for the plugin on Github.