       IO.write device, html
     end
 
-    tagmap = getglobal :tags
     File.rm_rf! "#{dir}site/tags/"
+    tagmap = Enum.reduce metalist, %{}, fn m, a ->
+      tmp = Enum.reduce m.tags, %{}, &(Map.put &2, &1, (Map.get &2, &1, []) ++ [m])
+      Map.merge a, tmp, fn _, u, v -> MapSet.to_list(MapSet.new u ++ v) end
+    end
     Enum.each tagmap, fn {k, v} ->
       tagdir = "#{dir}site/tags/#{k.name}/"
       pt = "Posts Tagged \"#{k.name}\""

    File.rm_rf! dstdir
    File.mkdir_p! dstdir

    putglobal :tags, %{}
    metalist = mkmeta(dir, proj, files, [])
    Enum.each metalist, fn meta ->
      Enum.each meta.tags, fn t ->
        tagmap = getglobal :tags
        posts = Map.get tagmap, t, []
        tagmap = Map.put tagmap, t, posts ++ [meta]
        putglobal :tags, tagmap
      end

      [y, m, d] = meta.raw_date
      dow = elem @dowstr, :calendar.day_of_the_week(y, m, d)
      datestr = "#{dow}, #{meta.date}"

      date: "#{day} #{elem @monabbr, month} #{year}",
      raw_date: [year, month, day],
      tags: tags,
      url: "#{Keyword.get proj, :base_url}posts/#{h}.html"
    }])
  end

