diff --git a/lib/jekyll-pandoc-multiple-formats/generator.rb b/lib/jekyll-pandoc-multiple-formats/generator.rb
index bf4a8395e2000dd297cffd09b576a8c47fcfacd9..86a44c6e79fc5659c78b3ddef44210af51cff70d 100644
--- a/lib/jekyll-pandoc-multiple-formats/generator.rb
+++ b/lib/jekyll-pandoc-multiple-formats/generator.rb
@@ -1,4 +1,4 @@
-# Copyright (c) 2012-2015 Nicolás Reynolds <fauno@endefensadelsl.org>
+# Copyright (c) 2012-2018 Nicolás Reynolds <fauno@endefensadelsl.org>
 #               2012-2013 Mauricio Pasquier Juan <mpj@endefensadelsl.org>
 #               2013      Brian Candler <b.candler@pobox.com>
 # 
diff --git a/lib/jekyll-pandoc-multiple-formats/pandoc_file.rb b/lib/jekyll-pandoc-multiple-formats/pandoc_file.rb
index 75b2f723309bb0d0715190ccb85aac732faeb4cc..e7ff91f0cf3de9cbe6b09391aea84c9e85d6a636 100644
--- a/lib/jekyll-pandoc-multiple-formats/pandoc_file.rb
+++ b/lib/jekyll-pandoc-multiple-formats/pandoc_file.rb
@@ -26,7 +26,7 @@ module Jekyll
     include Convertible
 
     attr_reader :format, :site, :config, :flags, :posts, :slug, :title, :url
-    attr_reader :papersize, :sheetsize, :signature
+    attr_reader :papersize, :sheetsize, :signature, :sources
 
     def initialize(site, format, posts, title = nil, extra = {})
       @site   = site
@@ -184,6 +184,12 @@ module Jekyll
     end
 
     def write
+      unless rebuild?
+        Jekyll.logger.info "#{relative_path} doesn't need to be rebuilt"
+        Jekyll.logger.debug sources.join(' ')
+        return true
+      end
+
       FileUtils.mkdir_p(File.dirname(path))
       # Remove the file before creating it
       FileUtils.rm_f(path)
@@ -332,6 +338,27 @@ module Jekyll
       @signature ||= find_option 'signature'
     end
 
+    # Finds the source files for this pandoc file
+    def sources
+      return @sources if @sources
+
+      @sources = ['_config.yml']
+      @sources << flags.split(' ').map do |flag|
+        file = File.join(@site.config['source'], flag.split('=').last)
+        file if File.exist? file
+      end
+
+      @sources << posts.map(&:path)
+
+      @sources = @sources.flatten.compact
+    end
+
+    def rebuild?
+      !File.exist?(path) || sources.map do |f|
+        File.ctime(f) > File.ctime(path)
+      end.any?
+    end
+
     private
 
     def single_post
diff --git a/lib/jekyll-pandoc-multiple-formats/version.rb b/lib/jekyll-pandoc-multiple-formats/version.rb
index 8f589753becf5b648969e0620c660c2909e83418..e77c69e13ecf497a252f3ec91afcab2e5cd31510 100644
--- a/lib/jekyll-pandoc-multiple-formats/version.rb
+++ b/lib/jekyll-pandoc-multiple-formats/version.rb
@@ -1,3 +1,3 @@
 module JekyllPandocMultipleFormats
-  VERSION = '0.3.0'
+  VERSION = '0.4.0'
 end