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?
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
special?
function is defined:def special?(entry)
SPECIAL_LEADING_CHAR_REGEX.match?(entry) ||
SPECIAL_LEADING_CHAR_REGEX.match?(File.basename(entry))
end
And special?
function is used in the filter function to detect and filter those files matching the regex.
And the Reader
class is using this filtering function in various places.
To be honest, I still did not get how jekyll bring those things together but I think I'll try to figure them out myself.