Add a favicon to a Phoenix app

:wave:

If you are using the default setup, then replacing assets/static/favicon.ico with your own favicon.ico should be enough.


For adding the bigger sized favicons, you’d also need to include a manifest.json in your static files and serve it with Plug.Static in endpoint.ex:

plug Plug.Static,
    at: "/",
    from: :your_app,
    gzip: true,
-   only: ~w(css fonts images js lib favicon.ico robots.txt)
+   only: ~w(css fonts images js lib favicon.ico apple-touch-icon.png favicon-32x32.png favicon-16x16.png manifest.json robots.txt)

You’d also need to update your templates/layout/app.html.eex to point the browser to that manifest:

+ <link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
+ <link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
+ <link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
+ <link rel="manifest" href="/manifest.json">
20 Likes