Change category <title>

Is it possible to change the category page titles from e.g. “Latest %category% topics” to “%category% - latest topics”?

“Latest Programming topics” sounds fine in English, but in Russian “Последние Программирование темы” is not correct and looks weird.

1 Like

Yep, pop over to /admin/customize/site_texts?q=latest topics. :sunglasses:

3 Likes

Which key? I don’t see it here. Also tried to search by categoryName.

You should search for the text you want to change. I’m guessing the js.categories.latest is what you are looking for, but if you can’t find the string directly, you should seek further assistance. :slight_smile:

If this is going to benefit more than your community consider contributing to the Russian translation on Transifex.

Editing local strings is a last resort.

2 Likes

yeah, I usually contribute.

No, it’s the column on the categories page.

I don’t see here anything like Latest {{categoryName}} topics

Instead of posting examples that are “like” what you’re looking for, can you post some of the exact HTML that’s around that text? i.e. knowing attributes may help locate the template.

3 Likes

I was talking about HTML <title>.

e.g. on this forum:

<title>Latest support topics - Discourse Meta</title>

It’s not really related to locales, to make it simpler, let’s say that I want to change it to

<title>support - latest topics - Discourse Meta</title>

js.filters.latest.title is applied to the title, but it is also referred to in other parts of the UI. I recommend fixing it in locale data, as an override may require a theme component to detach that functionality.

That string can not be empty.

Yes, but it’s just one part of the title ({{js.filters.latest.title}} {{categoryName}} ...), that is it’s not possible to change the word order.

What do you mean? As far as I can see there is no string with all 3 parts in the customization admin UI.
So maybe it’s a feature request…

Would be better to do it on the server side, so it would appear correctly in the search engines.

Thanks. Involved files
https://github.com/discourse/discourse/blob/master/app/views/layouts/application.html.erb#L=5

https://github.com/discourse/discourse/blob/master/app/controllers/categories_controller.rb#L37-L41

Though there is no “customize” solution available, there are some possibilities.

  • A theme / component that rewrites the title text
  • A plugin that allows working with the title variable value
  • Make sure there’s a is_homepage and SiteSetting.short_site_description.present ?
1 Like

Looks like I found it: js.filters.with_category in Customize.
e.g. I changed it from %{filter} %{category} topics to %{category} - %{filter} topics ( %{category} - %{filter} темы in Russian).

The second file is for the /categories page, not for category topics. I needed this one:
https://github.com/discourse/discourse/blob/edbc3565933819a9ebe4e80d567c35f5dca061a2/app/controllers/list_controller.rb#L90

2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.