Newsletter
Join the Community
Subscribe to our newsletter for the latest news and updates
A Jekyll plugin that copies static files from the _posts to the _site folder
Jekyll Postfiles is a Jekyll plugin that copies static files (images, PDFs, and other assets) placed in the same folder as your Markdown posts into the generated site, so you can reference them with simple relative paths like .
Jekyll Postfiles is an open-source Ruby gem that extends Jekyll's static site generator. Its core function is to take any file that lives in a post's folder (e.g. _posts/2016-06-09-cloudflare/) and copy it to the folder where the post's HTML output is generated. It takes static files (images, PDFs, etc.) as input and produces a site structure where those files sit next to the corresponding rendered post page.
 instead of /assets/..., making posts easier to read and maintain.2016/06/09/title/index.html plus files); with a .html permalink they sit alongside the .html file._drafts/ to _posts/ without changing any asset paths.This plugin is for Jekyll users who are tired of maintaining a separate global assets folder. Bloggers and content creators who attach images, PDFs, or other files to individual posts will benefit from co-locating assets with their Markdown. It's also useful for users who frequently draft and publish posts, since the plugin removes the need to rewrite asset paths when moving a draft into the _posts/ folder.
_drafts/ with attached assets; the plugin copies files only on build, so the draft assets won't leak into the built site until you publish.The plugin hooks into Jekyll's build process. For each post, it scans the post's directory for any static files (not Markdown) and copies them into the output directory for that post, determined by your permalink configuration. For example, with permalink: /:year/:month/:day/:title/, the files end up in the same folder as index.html; with permalink: /:year/:month/:day/:title.html, they are placed next to title.html.
Jekyll Postfiles is not supported by GitHub Pages because GitHub Pages only runs a fixed set of plugins. To use it, host your site on a service that supports third-party Jekyll plugins, such as Netlify.
Yes, it is open-source software released under the MIT License, so you can use it without cost.
Add gem 'jekyll-postfiles' to the jekyll_plugins group in your Gemfile and run bundle. Then start Jekyll as usual.
No. GitHub Pages does not support third-party plugins, so you need to build your site elsewhere (e.g. Netlify) or use a pre-built output.
Yes. The plugin only affects files stored in posts folders; you can continue using full paths like /assets/ for assets shared across multiple posts.
Since your Markdown uses relative paths, the plugin recalculates the destination based on the post's URL, so you don't need to update references manually.
