This guide explains how to integrate Jupyter notebooks with your Hugo blog posts.
data-patterns/
├── content/
│ └── concepts/
│ ├── polars-01.md
│ ├── polars_data_types_blog.md
│ └── ... (other markdown files)
└── static/
└── notebooks/
└── concepts/
├── polars_data_types_blog.ipynb
└── ... (other notebooks)
static/notebooks/: Hugo serves everything instatic/as-is at the root of your site- Mirror content structure: Keeps notebooks organized the same way as your content
- Easy to maintain: Clear 1:1 mapping between blog posts and notebooks
- Git-friendly: Notebooks are versioned alongside your content
Add this at the beginning of your blog post (after the introduction):
{{< alert icon="📓" >}}
**Interactive Notebook Available!** Follow along with the code examples by downloading the [Jupyter notebook](/data-patterns/notebooks/concepts/your-notebook.ipynb) for this post.
{{< /alert >}}Benefits:
- Eye-catching and professional
- Clearly visible to readers
- Consistent styling across all posts
Add anywhere in your post:
📥 **[Download the Jupyter notebook](/data-patterns/notebooks/concepts/your-notebook.ipynb)** to follow along with the code examples.[](/data-patterns/notebooks/concepts/your-notebook.ipynb)Add a "Resources" section at the end of your post:
## 📚 Resources
- **Jupyter Notebook**: [Download the interactive notebook](/data-patterns/notebooks/concepts/your-notebook.ipynb)
- **GitHub**: [View source code](https://github.com/aakashkh/data-patterns)Add a "Open in Colab" badge:
[](https://colab.research.google.com/github/aakashkh/data-patterns/blob/main/static/notebooks/concepts/your-notebook.ipynb)Requirements:
- Notebook must be pushed to GitHub
- Update the path to match your GitHub repo structure
For fully interactive notebooks in the browser:
[](https://mybinder.org/v2/gh/aakashkh/data-patterns/main?filepath=static/notebooks/concepts/your-notebook.ipynb)Requirements:
- Notebook must be on GitHub
- May need a
requirements.txtin your repo root
For read-only notebook viewing:
[](https://nbviewer.org/github/aakashkh/data-patterns/blob/main/static/notebooks/concepts/your-notebook.ipynb)Work on your notebook in content/concepts/ or a separate working directory.
# From the project root
cp content/concepts/your-notebook.ipynb static/notebooks/concepts/Or use PowerShell:
Copy-Item content\concepts\your-notebook.ipynb static\notebooks\concepts\Add the alert box or download link to your markdown file:
{{< alert icon="📓" >}}
**Interactive Notebook Available!** Follow along with the code examples by downloading the [Jupyter notebook](/data-patterns/notebooks/concepts/your-notebook.ipynb) for this post.
{{< /alert >}}hugo serverVisit your blog post and verify the download link works.
git add content/concepts/your-post.md
git add static/notebooks/concepts/your-notebook.ipynb
git commit -m "Add blog post with notebook: Your Post Title"
git pushYou can customize the alert appearance by using different icons:
{{< alert icon="💻" >}}
**Code Examples**: Download the notebook to run all examples locally.
{{< /alert >}}
{{< alert icon="🔬" >}}
**Experiment**: Try the interactive notebook to explore the concepts hands-on.
{{< /alert >}}
{{< alert icon="📊" >}}
**Data Analysis**: Get the notebook with all datasets and visualizations.
{{< /alert >}}If you have multiple notebooks for a single post:
{{< alert icon="📓" >}}
**Interactive Notebooks Available:**
- [Part 1: Basics](/data-patterns/notebooks/concepts/topic-part1.ipynb)
- [Part 2: Advanced](/data-patterns/notebooks/concepts/topic-part2.ipynb)
- [Part 3: Practice](/data-patterns/notebooks/concepts/topic-part3.ipynb)
{{< /alert >}}- Check the path: Make sure it starts with
/data-patterns/(your baseURL) - Verify file location: Notebook should be in
static/notebooks/concepts/ - Rebuild: Run
hugo serveragain - Check browser console: Look for 404 errors
If your notebook file is very large (>5MB):
- Clear outputs:
jupyter nbconvert --clear-output --inplace your-notebook.ipynb - Use Git LFS: For very large notebooks or datasets
- External hosting: Consider hosting on GitHub and linking directly
For embedding notebook content directly in the blog (not just linking):
- Convert to HTML:
jupyter nbconvert --to html your-notebook.ipynb - Use Hugo shortcode: Create a custom shortcode to embed the HTML
- Or use iframe: Embed the HTML file in an iframe
-
Always clear outputs before committing: Keeps file size small
jupyter nbconvert --clear-output --inplace *.ipynb -
Keep notebooks focused: One notebook per blog post concept
-
Add README cells: Include instructions at the top of each notebook
-
Test notebooks: Ensure they run from top to bottom without errors
-
Version control: Commit notebooks alongside blog posts
-
Consistent naming: Match notebook names to blog post slugs
| Task | Command |
|---|---|
| Copy notebook to static | copy content\concepts\notebook.ipynb static\notebooks\concepts\ |
| Clear notebook outputs | jupyter nbconvert --clear-output --inplace notebook.ipynb |
| Test locally | hugo server |
| View notebook URL | http://localhost:1313/data-patterns/notebooks/concepts/notebook.ipynb |
See polars_data_types_blog.md for a complete example of notebook integration.
Need help? Check the Hugo documentation or open an issue on GitHub.