Hi!
I’m using grav-plugin-simplesearch and can’t figure out how to translate the page title in the head <title> section of the search results page.
Title is - Search Results
And I’m certain, that this is not:
Some background:
Plugin SimpleSearch does not manipulate the <title> element inside the <head> of the page. That’s the territory of template base.html.twig from the current theme.
SimpleSearch displays the result of the search in a page pointed at by configuration setting route: /search which is set in config file simplesearch.yaml.
If page /user/pages/search does not exist, the plugin will use fall-back page /user/plugins/simplesearch/pages/simplesearch.md, which contains the hardcoded page title “Search Results” and a few other settings for the search results.
Solution:
So, if you create page /user/pages/search/default.md and add the following frontmatter from the fall-back page, you can set any title you like:
---
title: Your preferred title
order_by: date
order_dir: desc
template: simplesearch_results
---
If you have a multi-language site, you can add multiple pages, each with its own language extension and translated title and slug.
Of course, you can change setting route to any other route and create a page in a folder structure mimicking the route.