       ["base", "list", "page", "post", "nav"]
       |> Enum.each(fn x ->
         tree = EEx.compile_file("#{dir}templates/#{x}.html.eex")
-        putglobal "template_#{x}", tree
+        Agent.update Global, &(Map.put &1, "template_#{x}", tree)
       end)
 
       File.mkdir_p! "#{dir}site/"

  def build_posts(dir, proj) do
    srcdir = "#{dir}posts/"
    dstdir = "#{dir}site/posts/"
    template_post = getglobal "template_post"
    template_list = getglobal "template_list"

    files = File.ls!(srcdir)
            |> Enum.filter(&(String.ends_with? &1, ".md"))

      IO.puts "Your website is now ready to be served!"
      IO.puts "Copy(move) the contents of `#{dir}site/` directory"
      IO.puts "into your public webpages directory."
    end
  end

  def compile_nav(proj, meta) do
    IO.puts "Compiling main navigation HTML stub..."
    template = Agent.get Global, &(Map.get &1, "template_nav")
    html = render template, proj ++ [pages: Enum.filter(meta, &(&1.menu))]
    Agent.update Global, &(Map.put &1, :navstub, html)
  end

  def build_pages(dir, proj, meta) do
    template = Agent.get Global, &(Map.get &1, "template_page")

    IO.puts "Cleaning pages..."
    File.ls!("#{dir}site/")
