Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>While it is best to put your images folder at the root of your Jekyll site, you can make use of a plugin that will make Jekyll recognize your images folder inside <code>_posts</code>. Prefix your image files with the same date format as what you use for your posts and they'll be copied over to <code>_site</code> in the directory structure you want.</p> <pre class="lang-rb prettyprint-override"><code># _plugins/post_images.rb module Jekyll POST_IMAGES_DIR = '_posts/imgs' DEST_IMAGES_DIR = 'imgs' class PostImageFile &lt; StaticFile def destination(dest) name_bits = @name.split('-', 4) date_dir = '' date_dir += "#{name_bits.shift}/" if name_bits.first.to_i &gt; 0 date_dir += "#{name_bits.shift}/" if name_bits.first.to_i &gt; 0 date_dir += "#{name_bits.shift}/" if name_bits.first.to_i &gt; 0 File.join(dest, date_dir + DEST_IMAGES_DIR, name_bits.join('-')) end end class PostImagesGenerator &lt; Generator def generate(site) # Check for the images directory inside the posts directory. return unless File.exists?(POST_IMAGES_DIR) post_images = [] # Process each image. Dir.foreach(POST_IMAGES_DIR) do |entry| if entry != '.' &amp;&amp; entry != '..' site.static_files &lt;&lt; PostImageFile.new(site, site.source, POST_IMAGES_DIR, entry) post_images &lt;&lt; entry.gsub(File.extname(entry), '') end end # Remove images considered to be "actual" posts from the posts array. site.posts.each do |post| if post_images.include?(post.id[1..-1].gsub('/', '-')) site.posts.delete(post) end end end end end </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload