jupyter-book icon indicating copy to clipboard operation
jupyter-book copied to clipboard

Download of `ipynb` files broken

Open michaelweinold opened this issue 1 year ago • 2 comments

Instead of downloading the Jupyter Notebook, the source of the file is openes on a new page.

For example, on this page of the Jupyter Book documentation:

{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "(file-types:notebooks)=\n",
    "# Jupyter Notebook files\n",
    "\n",
    "You can create content with Jupyter notebooks.\n",
    "For example, the content for the current page is contained in {download}`this notebook file <./notebooks.ipynb>`.\n",
    "\n",
    "```{margin}\n",
    "If you'd like to write in plain-text files, but still keep a notebook structure, you can write\n",
    "Jupyter notebooks with MyST Markdown, which are then automatically converted to notebooks.\n",
    "See [](./myst-notebooks.md) for more details.\n",
    "```\n",
    "\n",
    "Jupyter Book supports all Markdown that is supported by Jupyter Notebook.\n",
    "This is mostly a flavour of Markdown called [CommonMark Markdown](https://commonmark.org/) with minor modifications.\n",
    "For more information about writing Jupyter-flavoured Markdown in Jupyter Book, see [](./markdown.md).\n",
    "\n",
    "## Code blocks and image outputs\n",
    "\n",
    "Jupyter Book will also embed your code blocks and output in your book.\n",
    "For example, here's some sample Matplotlib code:"

michaelweinold avatar Oct 23 '24 06:10 michaelweinold

I believe this is an issue with ReadTheDocs, which may or not be their intended behavior: https://github.com/readthedocs/readthedocs.org/issues/11728

afeld avatar Oct 30 '24 13:10 afeld

I am having this issue above (wasn't a problem until a couple of weeks ago, but now I get the problem above even when trying to download ipynb from the Jupyterbook documentation pages and students have started emailing me that they can't download my teaching materials so I think it is not just me...).

Is there any chance of a fix within JupyterBook or something we can include in our book source code to fix it? I realise we can right click and save the file but this is clunky, and as the download button is present by default (can't even be removed, I think?) it would be great if it worked as expected.

By the way, I'm not a developer but use Jupyterbook for my teaching materials (which has been great, thanks) - any advice on a similar technical level as the JupyterBook docs would be much appreciated.

Thanks so much!

jillxoreilly avatar Jun 16 '25 22:06 jillxoreilly

I'm having this problem now too, just in the last few weeks.

zingale avatar Jul 30 '25 12:07 zingale

I think the recent reason for this change is that a Jupyter notebook mime-type was added to mime-db in March, and that's what GitHub pages uses. See: https://github.com/jshttp/mime-db/pull/282

So this change means that the browser opens the file as JSON, in the browser.

zingale avatar Aug 24 '25 17:08 zingale

also, this is likely a sphinx-book-theme issue and not a jupyter-book issue.

zingale avatar Aug 24 '25 18:08 zingale

https://github.com/executablebooks/sphinx-book-theme/issues/863

afeld avatar Oct 24 '25 21:10 afeld

sadly this fix does not seem to work for me.

zingale avatar Oct 24 '25 23:10 zingale

https://github.com/orgs/TeachBooks/discussions/44#discussioncomment-14425186

zamkorus avatar Oct 24 '25 23:10 zamkorus

I agree this issue can be closed, as it's something that needs to be handled at the theme (or extension) level.

afeld avatar Oct 25 '25 12:10 afeld