         (doseq [file files]
           (let [render-fn (:renderer options)
                 html (render-fn file)
-                page-filepath (str (:target options) "/"
+                page-filepath (str (:out-dir options) "/"
                                    (or (:filepath file)
                                        (str (:filename file) ".html")))]
             (perun/create-file tmp page-filepath html)))

            sorted-files (sort-by (:sortby options) (:comparator options) filtered-files)
            render-fn (:renderer options)
            html (render-fn sorted-files)
            page-filepath (str (:target options) "/" page)]
        (perun/create-file tmp page-filepath html)
        (u/info (str "Render collection " page "\n"))
        (commit fileset tmp)))))

        (commit fileset tmp)))))

(def ^:private +collection-defaults+
  {:out-dir "public"
   :filterer identity
   :sortby (fn [file] (:date-published file))
   :comparator (fn [i1 i2] (compare i1 i2))})

(deftask collection
  "Render collection files"
  [o out-dir    OUTDIR     str  "The output directory"
   r renderer   RENDERER   code "Page renderer"
   f filterer   FILTER     code "Filter function"
   s sortby     SORTBY     code "Sort by function"
