Can't translate the page title of simplesearch plugin

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:

  PLUGIN_SIMPLESEARCH:
    SEARCH_RESULTS:

variable

In languages.yaml the first few lines need to be something like:

en:
  PLUGIN_SIMPLESEARCH:
    SEARCH_PLACEHOLDER: 'Search …'
    SEARCH_RESULTS: 'Search Results Test'

That gives me the correct placeholder and the test heading indicated.

@01K,

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.

Thank you guys!
@zfiddler, pardon me, I’ve forgotten to display my all strings with correct translations. It was with language prefix:

lt:
  PLUGIN_SIMPLESEARCH:
    SEARCH_PLACEHOLDER: 'Ieškoti...'
    SEARCH_RESULTS: 'Paieškos rezultatai'

So, it wasn’t working from the beginning…

I had to create a separate page, as @pamtbaau suggested

1 Like