Serve static files/directories in Phoenix
Phoenix will by default server some files and directories from priv/static
. More specifically css/
, fonts/
, images/
, js/
, favicon.ico
and robots.txt
. If you need to add a new directory however simply creating it in priv/static
will not make Phoenix serve it. You need to explicitly add it.
Say your project is called ChicagoElixir
you will need to go to your endpoint configuration, typically in: lib/chicago_elixir/web/endpoint.ex
. There you will find the following configuration:
plug Plug.Static,
at: "/", from: :chicago_elixir, gzip: false,
only: ~w(css fonts images js favicon.ico robots.txt)
Simply add the new folder or file name to the list in only
and restart your Phoenix server.