Implements custom Kirby routes and content representations (.json/.xml/.rss), including redirects, sitemap endpoints, and URL pattern filtering. Use when building endpoints, redirects, or representation templates that change how URLs resolve.
name: kirby-routing-and-representations
description: Implements custom Kirby routes and content representations (.json/.xml/.rss), including redirects, sitemap endpoints, and URL pattern filtering. Use when building endpoints, redirects, or representation templates that change how URLs resolve.
Route patterns that shadow .json or .rss representations.
Expecting kirby:kirby_render_page to execute route logic.
Workflow
Clarify the URL pattern, HTTP methods, response type, and language behavior.
Call kirby:kirby_init and read kirby://roots to locate config and template roots.
Read kirby://config/routes to understand current route configuration.
If runtime is available, call kirby:kirby_routes_index to see registered patterns; otherwise run kirby:kirby_runtime_status and kirby:kirby_runtime_install first.
Inspect existing templates/controllers to avoid collisions:
kirby:kirby_templates_index
kirby:kirby_controllers_index
For content representations, add site/templates/<template>.<type>.php and optional site/controllers/<template>.<type>.php.
For routes, add or adjust routes in site/config/config.php or a plugin. Avoid greedy patterns that shadow .json/.rss representations.
Validate output:
use kirby:kirby_render_page(contentType: json|xml|rss) for representations
manually hit route URLs for router behavior (render does not execute the router)
Search the KB with kirby:kirby_search (examples: "custom routes", "json content representation", "filtering via routes", "sitemap.xml", "trailing slash").