An update to a post I wrote in July of 2020 about embedding Jupyter Notebooks on WordPress. The original post is located here.
I continued along utilizing the nbconvert shortcode for a while and encountered a huge amount of problems with https://nbviewer.jupyter.org/. Essentially – I believe there is some sort of bug with the system. Normally it takes 1-2 days for nbviewer to “recognize” something that is dropped into github – which isn’t a huge deal but a big annoyance. In addition – I’ve had multiple workbooks go 1-2 weeks without being recognized, and a few that were fine and then dropped into a 404 error on the site.
Either way – I’m looking at using a great little utility called “nb2wp” and located on github here. All it really does is perform the same conversion, but drops it locally to a .html file with CSS inline, along with saving all of the images (and embeds the links to those images as if you’re going to upload to github and host them there). Then you upload the images to github (along with the notebook for posterity), and copy/paste the html code into a custom HTML block on your WordPress post.
Big downside here is that the HTML is static and no longer linked to github. But I’ll probably convert all my existing posts over – it’s just too scary to have them all relying on a third-party host. The only problem I’ve found is that it does sometimes generate an off character or two, and sometimes it doesn’t look “perfect” overall, but I think it’s probably a more reliable solution.