# Very simple plugin that adds a subdirectory under _posts as a category def get_category_from_subdir(path) path.sub(/^.*_posts\/(.*?)\/.*$/, "\\1") end Jekyll::Hooks.register :posts, :pre_render do |post, payload| post.data['categories'] << get_category_from_subdir(post.path) end