Skip to content

Commit cb9db49

Browse files
authored
Merge pull request #32 from CU-ESIIL/codex/create-tag-system-documentation
Add tag system replication guide
2 parents e9c582c + d788c79 commit cb9db49

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

TAG_SYSTEM_HOWTO.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Tag System Setup Guide
2+
3+
This guide explains how to recreate the Data Library's tag system in another repository. The process centers on a small Python script that scans Markdown documentation, builds tag index pages, and updates the navigation for a MkDocs site.
4+
5+
## 1. Prepare your repository
6+
7+
1. Organize your documentation under a top‑level `docs/` directory. Each dataset or topic should live in a nested folder inside `docs/`.
8+
2. Add a `tags` field to the YAML front matter of each Markdown file or rely on the folder structure to derive tags. Tags should be lowercase and use hyphens for spaces, e.g.
9+
10+
```markdown
11+
---
12+
title: Example dataset
13+
tags: [hazards, remote-sensing]
14+
---
15+
```
16+
17+
3. Ensure Python 3 and the [PyYAML](https://pyyaml.org/) package are available in your environment.
18+
19+
## 2. Copy the tag builder script
20+
21+
1. Copy [`scripts/build_tags.py`](scripts/build_tags.py) from this repository into the `scripts/` directory of your new project.
22+
2. Adjust the `summit_descriptions` dictionary inside the script if you want special descriptions for particular tags. You can also edit the logic that derives tags from paths in the `derive_tags` function.
23+
24+
## 3. Generate tag pages
25+
26+
Run the script from the repository root:
27+
28+
```bash
29+
python scripts/build_tags.py
30+
```
31+
32+
The script will:
33+
34+
- Scan `docs/` for Markdown files and collect their tags.
35+
- Create `docs/tags.md` with an index of all tags and the pages associated with each tag.
36+
- Build a `docs/topic/` directory containing tag‑specific pages for the most common tags.
37+
- Generate a standalone `docs/innovation-summit-2025.md` page when that tag is present.
38+
- Rewrite `mkdocs.yml` to include the new pages in the site navigation.
39+
40+
Commit the generated files (`docs/tags.md`, any files under `docs/topic/`, `docs/innovation-summit-2025.md`, and the updated `mkdocs.yml`) along with your documentation.
41+
42+
## 4. Update your build process
43+
44+
Include the tag generation step in your documentation build workflow or continuous integration pipeline so that tag pages stay in sync with the Markdown sources.
45+
46+
## 5. Customizing the system
47+
48+
- **Different documentation locations**: If your docs are not in `docs/`, change the `docs_dir` variable at the top of the script.
49+
- **Alternate navigation**: Modify the `cfg['nav']` block in the script to match your preferred MkDocs navigation structure.
50+
- **Additional metadata**: Extend the script to read other front‑matter fields if you want more complex tagging logic.
51+
52+
By following these steps, any repository can implement the same automated tag pages used in the Data Library.

0 commit comments

Comments
 (0)