# Changing favicon with notebook extension

**URL:** <https://discourse.jupyter.org/t/changing-favicon-with-notebook-extension/2721>\
**Category:** JupyterLab\
**Created:** [November 22, 2019, 12:47am UTC](https://discourse.jupyter.org/t/changing-favicon-with-notebook-extension/2721 "2019-11-22T00:47:12Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![bkitej](https://avatars.discourse-cdn.com/v4/letter/b/a9adbd/32.png) [@bkitej](https://discourse.jupyter.org/u/bkitej)\
**Post date:** [November 22, 2019, 12:47am UTC](https://discourse.jupyter.org/t/changing-favicon-with-notebook-extension/2721/1 "2019-11-22T00:47:12Z")

</div>

New to notebook extensions and most all web development concepts here. I’m attempting to change JupyterLab’s favicon using [this cookiecutter theme](https://github.com/jupyterlab/theme-cookiecutter-ts), with the ultimate goal of being able to change the favicon based on a config file. I’m using a slight modification of [this SOF post](https://stackoverflow.com/a/2995536/9585335), included within my `src/index.ts` file.

```auto
let head = document.head || document.getElementsByTagName('head')[0];

function changeFavicon(src: string) {
  let link = document.createElement('link'),
       oldLink = document.getElementById('dynamic-favicon');
  link.id = 'dynamic-favicon';
  link.rel = 'icon';
  link.type = 'image/x-icon';
  link.href = src;
  if (oldLink) {
    head.removeChild(oldLink);
  }
  head.appendChild(link);
}

```

When I call…

`changeFavicon('http://www.google.com/favicon.ico');`

…the favicon changes appropriately. But how would I access a favicon.ico file stored within my very own local extension directory?

A step further, how could I change the path to different favicon files using a config file?

---

<div class="post-metadata">

**Author:** ![Sarunas\_Azna](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/sarunas_azna/32/3543_2.png) [@Sarunas\_Azna](https://discourse.jupyter.org/u/Sarunas_Azna)\
**Post date:** [January 20, 2021, 4:35pm UTC](https://discourse.jupyter.org/t/changing-favicon-with-notebook-extension/2721/2 "2021-01-20T16:35:39Z")

</div>

> [@bkitej](#):
>
> ```auto
> let head = document.head || document.getElementsByTagName('head')[0];
> 
> function changeFavicon(src: string) {
> let link = document.createElement('link'),
> oldLink = document.getElementById('dynamic-favicon');
> link.id = 'dynamic-favicon';
> link.rel = 'icon';
> link.type = 'image/x-icon';
> link.href = src;
> if (oldLink) {
> head.removeChild(oldLink);
> }
> head.appendChild(link);
> }
> 
> ```

Thanks for the snippet! As per how to make my own extension with static files listed - this is a good example [https://gitter.im/jupyterlab/jupyterlab?at=5b3b80d133b0282df4fc6df0](https://gitter.im/jupyterlab/jupyterlab?at=5b3b80d133b0282df4fc6df0).
