10

I would like to upload my Jupyter notebook on my website using Blogdown/Netlify?

When I converted my ipynb to md, and added info to the YAML, I was able to upload it. But this upload causes it to follow the specific format/theme of the website. I want the Jupyter notebooks to be rendered in their own format/theme (the HTML file after ipynb convert) (visually).

It uploads like this:

Website theme format: Website theme format

My process for getting the above is:

  • Make jupyter notebook
  • Download as md
  • Copy contents of md into new Rmd
  • Serve site

I want it to upload like this:

Jupyter notebook theme format: Jupyter notebook theme format


As mentioned in comments, when I download ipynb as html, edit the html to include the yaml, and then if I serve site, I get the following, which is not the same as what I want. I want the publish to fit the window, not add a horizontal scroll on its own.

Jupyter notebook format not what I want


So now I have the following choices:

  1. Convert to md, copy paste into Rmd, push.
  2. Convert to html, edit to include yaml, push (don't like display).
  3. Convert to md, add yaml, push (almost same as step 1).
  4. Just link a blog post to my github, where I can render my ipynb.
cderv
  • 6,272
  • 1
  • 21
  • 31
  • Any special reason this is tagged [tag:r]? – Roman Luštrik Mar 10 '18 at 12:45
  • Blogdown can be used via rstudio, I assumed it required r to function. If I'm wrong please correct me. – scientific_explorer Mar 10 '18 at 13:15
  • Have you tried to convert to `html` rather than `md`? – RLesur Mar 12 '18 at 01:18
  • @romles I did. It doesn't show up when I serve site. I will try once again and let you know. – scientific_explorer Mar 12 '18 at 06:22
  • @romles I have tried converting to html and pushing it. It doesn't work. I have to manually edit the html to include the yaml, and then it works the way I want it to be displayed, yet it doesn't fit to the screen properly (adds horizontal scrolling). – scientific_explorer Mar 13 '18 at 15:48
  • This question is really about Hugo for which blogdown is a wrapper. My intuition is that you would want to create a custom page template for your iPython notebooks and render them as pages rather than posts using the iPython css stles. Check out . Otherwise, maybe accept that the formatting is consistent on your website (this is probably a good idea). – grrrck Mar 13 '18 at 16:18
  • @grrrck I really didn't know that this is a Hugo issue. I apologize. Will look into the documentation. Thank you. – scientific_explorer Mar 13 '18 at 16:34

1 Answers1

2

I think this can help you : https://pypi.python.org/pypi/hugo_jupyter/1.0.2
It allows to publish some jupyter notebook on a hugo website.

Basically, you will have a special directory for notebooks and a mechanism to add the front matter that hugo need.

It should be compatible with blogdown that is wrapping hugo. You may have to play with some options to indicate to blogdown how to handle this. Basically, blogdown handles all the Rmd files then uses hugo to build the site. You should be able to skip the first part for your notebook.

If you only uses python and no Rmarkdown files, maybe hugo and hugo-jupyter are enough for you, and no need for blogdown.

cderv
  • 6,272
  • 1
  • 21
  • 31