           menu: true,
           menu_text: "Home",
           menu_icon: ""}
-      ], pretty: true, indent: 2
-      IO.write f, tmp
-    end
+      ], pretty: true, indent: 2)
+      IO.write(f, tmp)
+    end)
     IO.puts "Generated `#{dir}pages/pages.json`."
+    dir
   end
 
-  defp init(:templates, dir) do
+  defp init(dir, :templates) do
     %{base: template_base,
       nav:  template_nav,
       list: template_list,

        date_format: "{WDFull}, {D} {Mshort} {YYYY}",
        preview_length: 200}
      |> Poison.encode!(pretty: true, indent: 2)
    File.open! "#{dir}serum.json", [:write, :utf8], fn f ->
      IO.write f, projinfo
    end
    IO.puts "Generated `#{dir}serum.json`."
  end

  defp init(:page, dir) do
    File.open! "#{dir}pages/index.md", [:write, :utf8], fn f ->
      IO.write f, "*Hello, world!*\n"
    end
    File.open! "#{dir}pages/pages.json", [:write, :utf8], fn f ->
      tmp = Poison.encode! [
        %Serum.Pageinfo{
          name: "index",
          type: "md",

      post: template_post}
    |> Enum.each(fn {k, v} ->
      File.open! "#{dir}templates/#{k}.html.eex", [:write, :utf8], fn f ->
        IO.write(f, v)
      end
    end)
    IO.puts "Generated essential templates into `#{dir}templates/`."
    dir
  end

  defp init(dir, :gitignore) do
    File.open!("#{dir}.gitignore", [:write, :utf8], fn f ->
      IO.write(f, "site\n")
    end)
    IO.puts "Generated `#{dir}.gitignore`."
    dir
  end
end
