   end
 
   defp genpage(contents, ctx) do
-    template = getglobal "template_base"
+    template = Agent.get Global, &(Map.get &1, "template_base")
     contents = process_links contents, ctx
-    render template, ctx ++ [contents: contents, navigation: getglobal :navstub]
+    render template, ctx ++ [contents: contents, navigation: Agent.get(Global, &(Map.get &1, :navstub))]
   end
 
   defp render(template, assigns) do

      ["base", "list", "page", "post", "nav"]
      |> Enum.each(fn x ->
        tree = EEx.compile_file("#{dir}templates/#{x}.html.eex")
        putglobal "template_#{x}", tree
      end)

      File.mkdir_p! "#{dir}site/"

      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/")
