Related to Markdown: Reference to section from another file
I have two markdown files:
├── parent.md
└── content/
└── child.md
In parent.md
:
# Main section
## sub-section
I'd like to make a reference to ##sub-section
from child.md
. How do I do that? Note that child.md
is in a sub-folder.
Note that I am using Jupyter book to process the markdown.
Preface
Generally, markdown processors will apply an ID to document headers so that one can create a hyperlink.
Simply doing the following should work for most markdown processors:
The downside to this approach is that when the header text changes, the ID changes, and therefore breaks the anchor link. Depending on the markdown processor you choose, there may be an idiosyncratic way to hardcode the anchor explicitly into the heading.
Jupyter-book
Since the processor you are using is Jupyter book, you can use section labels to cross-reference sections throughout your project.
Example:
Parent
Markdown input:
Jupyterbook build output:
Child
Markdown input:
Jupyterbook build output:
Note: Depending on the size of your project, it may be worthwhile planning out how you would like to namespace your labels in advance.
References
https://jupyterbook.org/en/stable/content/references.html#reference-section-labels
https://jupyterbook.org/en/stable/tutorials/references.html#refer-to-your-label