Search code examples
serverjupyter-notebookhtmlreveal.js

Host reveal.js slides (.html) [Jupyter notebook export] as webpage on non local server


I am currently working on a Jupyter Notebook. I managed to export it as reveal.js slides (.html) and host it on my local server. I used the following command line in the terminal:

jupyter nbconvert <mynotebookname>.ipynb --to slides --post serve

It generates a <mynotebookname>.slides.html file and opens it in my browser, where I can navigate properly through the slides (as seen in this example on https://revealjs.com).

However, if I upload this file to my 'web' folder at my University's server (where I usually upload any html files that I want to see as a webpage) I get a single scrollable page with the content of my notebook. It doesn't present the same slide perspective as on the local server.

I would like to make it available as a webpage so that I can share it with other people. What am I missing?


Solution

  • I finally managed to find the solution by using the command below:

    jupyter nbconvert <mynotebookname>.ipynb  --to slides --reveal-prefix "https://cdn.jsdelivr.net/npm/[email protected] "
    

    This way the generated slides.html file will render the slides correctly in your browser, whether the file is on your local machine as a standalone file or at a webserver/github/bitbucket being displayed as a webpage.

    I wasn't aware that when not using --post serve it is necessary to point the reveal-prefix to some reveal.js library available at a CDN (content delivery network). Apparently --post serve does that for you. As an alternative it is also possible to point to a local reveal.js library.

    Here are some links that helped me reach this solution. They contain some additional commands that may be useful while converting your notebook to slides.

    https://github.com/jupyter/nbconvert/issues/157

    https://medium.com/learning-machine-learning/present-your-data-science-projects-with-jupyter-slides-75f20735eb0f

    https://github.com/jupyter/nbconvert/blob/master/docs/source/usage.rst

    http://www.damian.oquanta.info/posts/using-a-local-revealjs-library-with-your-ipython-slides.html