# How can I hide the code cells of an ipynb file when building a website with Jupyter book?

**URL:** <https://discourse.jupyter.org/t/how-can-i-hide-the-code-cells-of-an-ipynb-file-when-building-a-website-with-jupyter-book/31260>\
**Category:** JupyterHub\
**Created:** [December 28, 2024, 2:12pm UTC](https://discourse.jupyter.org/t/how-can-i-hide-the-code-cells-of-an-ipynb-file-when-building-a-website-with-jupyter-book/31260 "2024-12-28T14:12:15Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Xinm\_wang](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/xinm_wang/32/16569_2.png) [@Xinm\_wang](https://discourse.jupyter.org/u/Xinm_wang)\
**Post date:** [December 28, 2024, 2:12pm UTC](https://discourse.jupyter.org/t/how-can-i-hide-the-code-cells-of-an-ipynb-file-when-building-a-website-with-jupyter-book/31260/1 "2024-12-28T14:12:16Z")

</div>

如何在使用Jupyter book搭建网站时隐藏 ipynb 文件代码单元格？How can I hide the code cells of an ipynb file when building a website with Jupyter book?  
这样有利于我复习。This is beneficial for my review.  
下面设置后仍然不起作用。The following settings still don’t work.

config：  
html:  
use\_repository\_button: false # 去掉 GitHub 按钮  
use\_issues\_button: false # 去掉问题按钮  
use\_download\_button: false # 去掉下载按钮  
favicon: favicon.ico # 网站图标  
theme:  
name: furo # 主题名称pydata\_sphinx\_theme  
static\_dir:  
- \_static # 静态文件目录  
css\_files:  
- \_static/custom.css # 自定义 CSS 文件  
search:  
enabled: true # 启用搜索功能  
interactive: true # 启用交互支持  
pygments\_style: monokai # 指定代码高亮样式

# script\_files:

# - \_static/hide\_code.js

nb\_render:  
hide\_code: true # 隐藏所有代码单元格  
hide\_output: false # 显示输出  
hide\_prompt: true # 隐藏提示符

myst\_enable\_extensions:  
- “html\_image” # 启用 HTML 图像扩展  
- “colon\_fence” # 启用冒号围栏语法  
- “dollarmath” # 启用 LaTeX 数学公式支持

## Sphinx 配置

sphinx:  
extra\_extensions:  
- myst\_nb # 启用 MyST-NB 扩展  
# - \_extensions.print\_config # 加载调试扩展  
myst\_nb:  
execute:  
cache: true # 启用缓存  
remove\_code\_source: true # 隐藏代码单元格  
remove\_code\_outputs: false # 显示输出  
code\_cell\_tags:  
- “hide-input” # 隐藏输入  
- “scroll-output” # 滚动输出
