serverjekyllwebrick

How underscored directories are filtered in Jekyll/Webrick?


Update: Check my answer below.


I just realized that in Jekyll Webrick server, directories starting with underscores(_includes, _layouts etc.) can't be accessed and are not listed when jekyll serve --show-dir-listing option is turned on. I wonder how Jekyll does that, as Webricks shows underscored directories on default. I did a quick search in the source code, I checked lib/jekyll/commands/serve.rb and similar files, but could not find the exact reason. It might be something related to fancy_listing?

Example: enter image description here It is there!:

enter image description here


Solution

  • Update: I found the relevant code in jekyll/reader.rb, which has a filter function and it is defined in jekyll/entry_filter.rb! :) Here is the code:

     SPECIAL_LEADING_CHAR_REGEX = %r!\A#{Regexp.union([".", "_", "#", "~"])}!o.freeze
    
    def special?(entry)
      SPECIAL_LEADING_CHAR_REGEX.match?(entry) ||
          SPECIAL_LEADING_CHAR_REGEX.match?(File.basename(entry))
    end