Home > database >  Setting a title and favicon for non-html files on a website
Setting a title and favicon for non-html files on a website

Time:05-15

Is there a way to set a title and favicon for non-html files on a website? For example, a link like https://example.com/files/image-or-something.png. By default Chrome just sets the title as the URL of the file, and doesn't use the original website's favicon.

This is only relevant for files that can be shown in the browser, like .png, .txt, etc, since other files are just downloaded automatically (at least on Chrome)

I'm using an Express (Node.js) server, in case there's a server-side solution

CodePudding user response:

From what I know, this isn't currently possible.

A .png file, .txt, and anything besides .html and .htm are not websites. They just store what they need to (for example, .png stores the image, and only the image). And the only things that can have an image are .html and .htm, because only websites can have icons and titles.

If you see something other than .html and .htm with an icon or title, that's the browser parsing the file and turning it into HTML.

CodePudding user response:

Most browsers will by default look for a favicon in the root directory for example: http://example.com/favicon.ico. You can use this for a favicon for your images.

  • Related