Tags rework#1305
Conversation
There was a problem hiding this comment.
Code Review
Ahoy, ye tag-wrangling scallywags! This massive haul of a pull request sets to scuttle the chaotic tags of old and replace 'em with a shiny new canonical tag vocabulary, complete with a fancy pages_with_tag macro in macro_hooks.py to dynamically link pages. While this clean-up be a fine wind in our sails, ye've managed to steer straight into some shallow waters: yer macro will have pages linkin' to themselves and break on Windows build machines due to backslash path separators, and ye left a lying comment in mkdocs.yml claiming tags won't display when ye just set 'em to true. Patch up these leaks before ye run this ship aground!
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| def pages_with_tag(tag): | ||
| entries = tag_index.get(tag.lower(), []) | ||
| try: | ||
| current_dir = os.path.dirname(env.page.file.src_path) | ||
| except AttributeError: | ||
| return entries | ||
| return [ | ||
| {"title": e["title"], "path": os.path.relpath(e["path"], current_dir)} | ||
| for e in entries | ||
| ] |
There was a problem hiding this comment.
Ahoy, matey! I spy two major snags in this macro that'll run yer ship aground:
- Self-Referencing Links: A page tagg'd with
gpu(likeUsing_GPUs.md) will end up linkin' to itself, makin' a useless loop! We should filter out the current page (env.page.file.src_path). - Windows Path Separators:
os.path.relpathwill use backslashes on Windows build machines, which breaks the links in the browser. Ye must replace them backslashes with proper forward slashes (/).
Here be a cleaner, sturdier version of the macro to keep yer links sailin' true!
| def pages_with_tag(tag): | |
| entries = tag_index.get(tag.lower(), []) | |
| try: | |
| current_dir = os.path.dirname(env.page.file.src_path) | |
| except AttributeError: | |
| return entries | |
| return [ | |
| {"title": e["title"], "path": os.path.relpath(e["path"], current_dir)} | |
| for e in entries | |
| ] | |
| def pages_with_tag(tag): | |
| entries = tag_index.get(tag.lower(), []) | |
| try: | |
| current_src = env.page.file.src_path | |
| current_dir = os.path.dirname(current_src) | |
| except AttributeError: | |
| return entries | |
| return [ | |
| {"title": e["title"], "path": os.path.relpath(e["path"], current_dir).replace(os.path.sep, "/")} | |
| for e in entries | |
| if e["path"] != current_src | |
| ] |
| # - git-authors | ||
| - tags: | ||
| tags: false # This will keep tags for the purpose of indexing, but not display on page. | ||
| tags: true # This will keep tags for the purpose of indexing, but not display on page. |
There was a problem hiding this comment.
Something i'd been meaning to do for a while.
Tags are in theory used for two things, SEO and as a secondry navigation.
The secondry navigation I had turned off because the tags were too rubbish, and fragmented do be worth displaying.
This change aims to fix that.
pages_with_tag()macro.Using tags as context and secondry navigation
Also allows need things like