I’m following the cookbook recipe to add a load more button on a blog page. I’ve done this before on another site, but wanted to use the updated version.
The problem is, ‘/blog.json’ is returning the same as ‘/blog’ despite all of the templates and controllers being setup correctly (it’s just loading the blog page as normal). What could be causing this? There’s nothing unusual about my Kirby setup.
Here is my setup. Nothing special about it really. I’m just really puzzled as to why the .json isn’t displaying at all, even if I change the data to a string instead of the snippet.
LGTM. No idea what could be going wrong unless you have set up a redirect somewhere in a route or .htaccess. Maybe a route to remove the blog part from articles or something like that?
When using placeholders like (:any) and (:all) or regex patterns, make sure that they are not too greedy and you accidentally catch routes you want left intact, resulting in things not working as expected anymore.
Example: A pattern like (:any) will not only catch routes with a URL part like notes or photography , but also their JSON content representations notes.json or photography.json . In this case, using (:alphanum) can be more suitable.
:alphanum doesn’t work in my case though as some of the URLs I need to catch have hyphens in them. What’s the best way to omit the blog page from this route?