How to set a favicon for a markdown page

I would like to serve a favicon when my markdown page is accessed. Any recommendations? Or should this be a feature request??

I did this by adding to the javascript file that I had already specified in the js argument in the markdown directive:

window.onload = function() {
  var link = top.document.createElement("link");
  link.type = "image/x-icon";
  link.rel = "shortcut icon";
  link.href = "/wiki.ico";

Until there is a favicon directive for markdown, I guess this might be the easiest way.

Don’t browsers request /favicon.ico if you don’t offer an icon link tag? Try rewriting that to /wiki.ico and see if your browser picks it up.

1 Like

Haha, brilliant! Just put a favicon.ico in the directory and it works without any other setting necessary! I guess I thought caddy would be really secure and not serve files with other extensions.

Anyway, I removed my javascript and renamed wiki.ico to favicon.ico!

1 Like

What do you mean by this?

(Browsers will request favicon.ico regardless.)

Caddy will serve any files you put in the webroot, by virtue of being a web server, which is pretty much expected (and ubiquitous) behaviour. How else would someone get your favicon anyway? Don’t put stuff in your webroot if you don’t want it served :stuck_out_tongue:

Muddled thinking… Of course a web server will try to serve files requested.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.