I'm wondering if it's possible to export a Jupyter notebook to a different directory than the same directory as the notebook itself? I'm using this to build HTML versions of the notebooks, and I'd like them to reside under docs/
in my GitHub repo (this is to take advantage of GH-pages).
Asked
Active
Viewed 9,232 times
8

ericmjl
- 13,541
- 12
- 51
- 80
1 Answers
15
NBConvert's --output-dir argument does this: https://nbconvert.readthedocs.io/en/latest/config_options.html
You can use it from the command line or from within a Jupyter notebook.
Command line:
jupyter nbconvert --output-dir='./docs' --to html my_notebook_to_be_converted.ipynb
From within a Jupyter Notebook cell:
!jupyter nbconvert --output-dir='./docs' --to html my_notebook_to_be_converted.ipynb
Note that you don't need to use "--to html" to convert a notebook to html because the default output format is html. I've included the argument solely for clarity.

Mehdi LAMRANI
- 11,289
- 14
- 88
- 130

user6481870
- 1,289
- 13
- 9
-
From within a Jupyter notebook, can you "self" `nbconvert` that notebook? – alancalvitti Aug 05 '19 at 14:26
-
Sure. Just precede the command with a ! If you just want it next to the existing notebook you can leave out the output-dir argument. !jupyter nbconvert --to html "my_notebook_to_be_converted.ipynb" – user6481870 Sep 07 '19 at 03:04
-
1Notebook version can generate an infinite loop if the `--execute` option is given – Manuel Montoya Mar 11 '22 at 17:53