# Open files with extension different from .ipynb as a notebook?

**URL:** <https://discourse.jupyter.org/t/open-files-with-extension-different-from-ipynb-as-a-notebook/7635>\
**Category:** JupyterLab\
**Created:** [January 25, 2021, 6:59am UTC](https://discourse.jupyter.org/t/open-files-with-extension-different-from-ipynb-as-a-notebook/7635 "2021-01-25T06:59:43Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![arogozhnikov](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/arogozhnikov/32/2535_2.png) [@arogozhnikov](https://discourse.jupyter.org/u/arogozhnikov)\
**Post date:** [January 25, 2021, 6:59am UTC](https://discourse.jupyter.org/t/open-files-with-extension-different-from-ipynb-as-a-notebook/7635/1 "2021-01-25T06:59:43Z")

</div>

I wrote a custom ContentsManager to help storing/loading notebooks in a bit different format.  
As visible from screenshot, jupyter is informed that file is a notebook though with a different extension.

![Screen Shot 2021-01-24 at 10.56.19 PM](https://canada1.discourse-cdn.com/flex031/uploads/jupyter/original/2X/d/df26d058b8a3a5fede50a6753adf77f9f3af3200.png)

However when clicking on it, it opens file as a text, not a notebook.  
Why front-end keeps requesting text file (unless I use open with \> Notebook) and how can I change this?

---

<div class="post-metadata">

**Author:** ![arogozhnikov](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/arogozhnikov/32/2535_2.png) [@arogozhnikov](https://discourse.jupyter.org/u/arogozhnikov)\
**Post date:** [January 25, 2021, 6:12pm UTC](https://discourse.jupyter.org/t/open-files-with-extension-different-from-ipynb-as-a-notebook/7635/2 "2021-01-25T18:12:49Z")

</div>

Minor addition: jupyter notebook works correctly (i.e. opens as a notebook). It’s jupyterlab to misbehave

---

<div class="post-metadata">

**Author:** ![jasongrout](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/jasongrout/32/371_2.png) [@jasongrout](https://discourse.jupyter.org/u/jasongrout)\
**Post date:** [January 25, 2021, 6:29pm UTC](https://discourse.jupyter.org/t/open-files-with-extension-different-from-ipynb-as-a-notebook/7635/3 "2021-01-25T18:29:10Z")

</div>

Currently the component in jlab is chosen based on the file extension. For now, I think you’d need to make a jlab extension that would register the notebook extension as the default viewer for your new extension.

---

<div class="post-metadata">

**Author:** ![arogozhnikov](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/arogozhnikov/32/2535_2.png) [@arogozhnikov](https://discourse.jupyter.org/u/arogozhnikov)\
**Post date:** [April 9, 2021, 2:14am UTC](https://discourse.jupyter.org/t/open-files-with-extension-different-from-ipynb-as-a-notebook/7635/4 "2021-04-09T02:14:25Z")

</div>

@jasongrout can you point me to some example or directions how do I register new extension with jlab extension?

---

<div class="post-metadata">

**Author:** ![jasongrout](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/jasongrout/32/371_2.png) [@jasongrout](https://discourse.jupyter.org/u/jasongrout)\
**Post date:** [April 12, 2021, 5:36pm UTC](https://discourse.jupyter.org/t/open-files-with-extension-different-from-ipynb-as-a-notebook/7635/5 "2021-04-12T17:36:45Z")

</div>

I think you might be able to just do this to add a new extension to the existing notebook file type:

```auto
app.docRegistry.getFileType('notebook')?.extensions.push('.newpy');

```

In order to make sure that filetype is defined, you probably want your extension to require the notebook extension tracker, to make sure you are initialized after the core notebook extension.
