Skip To Article

In addition to global controls that you can set in the project settings, you can also add metadata to individual notebooks, or on notebook cells, to control how MyST handles them during execution and rendering.

Tags for an entire notebook

The concrete syntax of notebook tags depends on the notebook format.

ipynb notebooks

Using Jupyter Lab, you can use the Property Inspector builtin extension to manage notebook-level metadata.

Using this tool you can add key-value pairs to the notebook metadata. For example, to skip execution of a notebook, you would add the following key-value pair inside the notebook metadata dictionary:

"tags": [
        "skip-execution"
    ]

Markdown notebooks

With Markdown notebooks, you can add notebook-level metadata using the YAML frontmatter at the top of the file. For example, to skip execution of a notebook, you would add the following to the frontmatter:

---
kernelspec:
  name: python3
  display_name: Python 3

skip_execution: true
---

Tags for a cell in a notebook

Tags are a list of strings under the tags key in the cell metadata, which can be set in JupyterLab, VSCode or in a {code-cell} directive. Here again the actual syntax depends on the notebook format.

ipynb notebooks

In the JSON representation of a jupyter notebook, cell tags would look like:

{
  "cell_type": "code",
  "source": ["print('hello world')"],
  "metadata": {
    "tags": ["my-tag1", "my-tag2"]
  }
}

You can use the Property Inspector builtin extension in Jupyter Lab to manage cell metadata, like so:

Markdown notebooks

In addition, MyST also supports the {code-cell} directive for markdown notebooks; here is an example of adding the raises-exception tag on such a code cell:

In Markdown of a jupyter notebook these look like:

```{code-cell} python
:tags: [remove-input]
print("This will show output with no input!")
```

for a single tag, or more generally, if you need to add multiple tags:

```{code-cell} python
:tags: [my-tag1, my-tag2]
print("This will show output with no input!")
```

Table 1:Notebook cell tags with special meanings

TagDescription
remove-cellRemove the cell from the rendered output.
remove-inputRemove the code cell input/source from the rendered output.
remove-outputRemove the code cell output from the rendered output.
hide-cellHides the cell from the rendered output.
hide-inputHides the code cell input/source from the rendered output.
hide-outputHides the code cell output from the rendered output.
remove-stderrRemove the code cell output stderr from the rendered output. See also project config
remove-stdoutRemove the code cell output stdout from the rendered output. See also project config
skip-executionSkip this cell, when executing the notebook
raises-exceptionExpect the code cell to raise an Exception (and continue execution)
MyST MarkdownMyST Markdown
Community-driven tools for the future of technical communication and publication, part of Jupyter.