Skip to content

feat(server): tag pages, so a recipe can belong to several collections #785

Done

Description

@LeMyst

Problem

Folders give each recipe exactly one place. A recipe like "red sauce pasta" belongs in lunch, dinner, pasta and easy meals all at once, and moving or copying the file is not an answer. This came up on Discord: someone wanted "collections" in cook server that can reference the same recipe file more than once.

Tags already cover the writing side. tags: [dinner, pasta] (or tags: dinner, pasta) in the frontmatter is parsed, and the server shows tags on the recipe cards (templates/recipes.html) and on the recipe page (templates/recipe.html). They are plain text, though, and no page lists "every recipe tagged dinner".

Proposal: tag pages

  1. Writing stays the same. Frontmatter tags, on .cook and .menu files.
  2. /tag/dinner shows every recipe and menu tagged dinner, from every folder, in one flat grid with the same cards as the home page. Each card shows its folder (Pasta/), so two recipes with the same name can be told apart. Sorted by name.
  3. /tags lists every tag with its count (dinner · 14). The home page and the small-screen menu link to it.
  4. Tags become links. On the recipe page, #dinner links to /tag/dinner. The tags on listing cards stay plain text for now, because each card is already a single <a> and a link cannot sit inside another link.
  5. Matching ignores case and surrounding spaces: Dinner and dinner are the same tag, shown with the spelling seen first. There is no hierarchy, so meal/dinner is just a name.
  6. Static sites: cook build web also renders tags.html and tag/<name>.html.

Not in a first version, but possible follow-ups: combining tags (?tag=dinner&tag=easy), filter chips on folder pages, and cook search --tag.

Implementation sketch
  • Collect: walk cooklang_find::build_tree(base_path) once, as src/build/index.rs::collect already does (recipe.tags(), URL stem from file_name()). Factor that walk into a shared helper in src/web/builders.rs that both the new builders and the static search index use.
  • Templates: move the card markup out of templates/recipes.html into an include, so the tag page renders the same cards. Add tags.html and tag.html with structs in src/web/templates.rs, reusing RecipeItem with an added folder: Option<String>.
  • Routes: GET /tags and GET /tag/{*tag} in src/server/ui.rs, following the recipes_handler pattern. Both are read-only GETs, so auth::middleware::required_capability needs no change and the reader role can see them.
  • Static build: render_tags / render_tag in src/build/renderer.rs, called from src/build/mod.rs next to render_directory. File names are percent-encoded for tags containing spaces or /. Add the pages to sitemap.rs.
  • i18n: a few new strings in all locales/*/.
  • API: /api/recipes already returns normalised tags, so API clients can filter today. No new endpoint is needed.
  • Tests: unit tests for the collector (case folding, menus, the same tag in two folders, untagged recipes); a cook server integration test through common::with_isolated_config; a Playwright test going from a recipe's tag to the tag page; cook build web output.

Activity

  1. added a commit that references this issue on Oct 27, 2026
    3d7435c
  2. added a commit that references this issue on Nov 29, 2026
    3aa2dd3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions