# Activate Codefolding on Binder

**URL:** <https://discourse.jupyter.org/t/activate-codefolding-on-binder/12185>\
**Category:** Binder\
**Tags:** how-to\
**Created:** [December 13, 2021, 1:00pm UTC](https://discourse.jupyter.org/t/activate-codefolding-on-binder/12185 "2021-12-13T13:00:51Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![pt93](https://avatars.discourse-cdn.com/v4/letter/p/3da27b/32.png) [@pt93](https://discourse.jupyter.org/u/pt93)\
**Post date:** [December 13, 2021, 1:00pm UTC](https://discourse.jupyter.org/t/activate-codefolding-on-binder/12185/1 "2021-12-13T13:00:51Z")

</div>

Hey notebook fellows!

I have a public github repo with some notebooks and want to install the codefolding extension to increase readability and fold some config cells. However, I can’t manage to do so.

Here is what I’ve tried. In my repo there is a **requirements.txt** with this line:  
`jupyter_contrib_nbextensions`  
Furthermore, there is a **postBuild** with

```auto
jupyter contrib nbextension install --user
jupyter nbextension enable codefolding/main

```

When I start Binder, I see that the extension is succesfully loaded:

```auto
Enabling notebook extension codefolding/main...
      - Validating: OK

```

However, after binder is launching, I don’t see any effect of enabling the extension. I don’t see how I can fold cells now - it rather seems to me that the extension is not fully enabled somehow:

 ![sc2](https://canada1.discourse-cdn.com/flex031/uploads/jupyter/original/2X/0/06cb71767411a82df4d93c9769b7d323521c3c20.png)

Do you guys have any ideas?

---

<div class="post-metadata">

**Author:** ![psychemedia](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/psychemedia/32/24_2.png) [@psychemedia](https://discourse.jupyter.org/u/psychemedia)\
**Post date:** [December 13, 2021, 3:02pm UTC](https://discourse.jupyter.org/t/activate-codefolding-on-binder/12185/2 "2021-12-13T15:02:34Z")

</div>

> [@pt93](#):
>
> jupyter\_contrib\_nbextensions

These extensions are designed to work with classic notebook, not JuptyerLab or RetroLab notebooks.

---

<div class="post-metadata">

**Author:** ![pt93](https://avatars.discourse-cdn.com/v4/letter/p/3da27b/32.png) [@pt93](https://discourse.jupyter.org/u/pt93)\
**Post date:** [December 13, 2021, 4:06pm UTC](https://discourse.jupyter.org/t/activate-codefolding-on-binder/12185/3 "2021-12-13T16:06:35Z")

</div>

thanks for the hint. I see…

Is there a way launch binder by default with the classic notebook option without setting in manually every time?

---

<div class="post-metadata">

**Author:** ![fomightez](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/fomightez/32/495_2.png) [@fomightez](https://discourse.jupyter.org/u/fomightez)\
**Post date:** [December 13, 2021, 4:27pm UTC](https://discourse.jupyter.org/t/activate-codefolding-on-binder/12185/4 "2021-12-13T16:27:13Z")

</div>

First to follow-up on something you said in your original post.

> [@pt93](#):
>
> I don’t see how I can fold cells now

Current JupyterLab, which was the first image you posted, has code folding ability built-in by default. To fold a cell:  
Click on a code cell to highlight it as active and then click on the blue bar to the left. The code cell will ‘fold’ and be represented by three dots where the code cell was previously. You can ‘unfold’ it by clicking on the dots or on the blue bar again.  
If you’d like to see the behavior in the current version, go to [Try Jupyter](https://jupyter.org/try), and click on `Try JupyterLab` in the center top row. A good notebook to open to try it is the ‘Lorenz.ipynb’ file you’ll see listed on the left after the sessions spins up. (At least that is presently what happens; I think it used to open an example notebook automatically after the session started and perhaps that will return.)

> [@pt93](#):
>
> Is there a way launch binder by default with the classic notebook option without setting in manually every time?

Yes, there is a way to open a Binder session launched via the [MyBinder.org](http://MyBinder.org) system with any interface you choose that is installed. The approach is to specify the correct URL and present that to the user.

By default, both the classic notebook interface and JupyterLab are installed and ready to use in MyBinder-launched sessions.  
For opening with the classic notebook interface, you need to edit the URL that is now generated by using the form on the [MyBinder.org](http://MyBinder.org) page. It formerly defaulted to generating a link for the classic notebook interface; however, now the default is to open the more modern and full-featured JupyterLab from the links generated by that form. It remains possible though to edit the URL provided after filling out the form there to the pattern that will specify launching the classic notebook interface.  
In summary, to do this you take what the form on the [MyBinder.org](http://MyBinder.org) page gives you for a link to a specific notebook and change the `?labpath=` part to read `?filepath=`.  
NOTE that the basis of this approach had been discussed in-depth [in as series of replies here](https://discourse.jupyter.org/t/classic-notebook-instead-of-jupyterlab-on-mybinder-org/10714/2), **although now the default URL currently displays `?labpath=`**. And so you switch `labpath` to `filepath` at present. (There were some issues to work out when that original series of posts of the new way to specify the classic interface. Unfortunately, I can no longer edit my posts there.)  
In fact, [the README there](https://github.com/fomightez/communication_voila/blob/3581f0ab00e9de034014c2c18ed1dd5d950f8181/README.md) has a number of examples of opening with various interfaces by editing the URL that the [MyBinder.org](http://MyBinder.org) site provides by default at the present time. (Note there are some ways that still work to preserve various ‘legacy’ paths so you may notice there’s some variations on that page, but some of the shortest ways possible now are featured in the approach described first in this reply.)

---

<div class="post-metadata">

**Author:** ![krassowski](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/krassowski/32/1685_2.png) [@krassowski](https://discourse.jupyter.org/u/krassowski)\
**Post date:** [December 14, 2021, 10:26am UTC](https://discourse.jupyter.org/t/activate-codefolding-on-binder/12185/6 "2021-12-14T10:26:36Z")

</div>

> [@pt93](#):
>
> `codefolding/main`

equivalent functionality (of a gutter with code-folding arrows) is built-in into JupyterLab (certainly in version 3.x and likely earlier) - no need to install anything. Just go to `Settings` → `Advanced Settings Editor`, select notebook and add:

```json
{
    "codeCellConfig": {
        "codeFolding": true
    }
}

```

For instructions on how to enable it in text editor and other types of cells see [this SO question](https://stackoverflow.com/questions/65532002/how-to-enable-code-folding-in-jupyter-lab)

---

<div class="post-metadata">

**Author:** ![Tina\_Yang](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/tina_yang/32/8044_2.png) [@Tina\_Yang](https://discourse.jupyter.org/u/Tina_Yang)\
**Post date:** [September 27, 2022, 12:23pm UTC](https://discourse.jupyter.org/t/activate-codefolding-on-binder/12185/7 "2022-09-27T12:23:13Z")

</div>

hello  
Whether this configuration can be written to the configuration in a container, every time it starts

---

<div class="post-metadata">

**Author:** ![krassowski](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/krassowski/32/1685_2.png) [@krassowski](https://discourse.jupyter.org/u/krassowski)\
**Post date:** [September 27, 2022, 12:38pm UTC](https://discourse.jupyter.org/t/activate-codefolding-on-binder/12185/8 "2022-09-27T12:38:35Z")

</div>

Yes, using [`overrides.json`](https://jupyterlab.readthedocs.io/en/stable/user/directories.html#overrides-json).
