Ghost: Title/Meta Description not working if custom Routes.yaml Collection in my custom template

Created on 25 Nov 2019  路  13Comments  路  Source: TryGhost/Ghost

Issue Summary

Title / Meta Description not working for custom Routes.yaml Collection in my custom template.
I see "Blog title (Page 1)" in the post list in custom template.

To Reproduce

Routes.yaml

routes:
  /rss/turbo-page/:
    template: turbo-page
    content_type: text/xml
  /: home

collections:
  /cases/:
    permalink: /cases/{slug}/
    template: cases
    filter: primary_tag:cases
    data: tag.cases
  /blog/:
    permalink: /blog/{slug}/
    template: blog
    filter: primary_tag:blog
    data: tag.blog

taxonomies:
  tag: /tag/{slug}/
  author: /blog/author/{slug}/

I see "Blog title (Page 1)" by url: http://site.com/cases/
and http://site.com/blog/
Same in the title and meta tags (twitter&og).
But in the tag admin interface - description, meta description and meta title i set another value.
Image of tags admin

Technical details:

  • Ghost Version: 3.0.3
  • Node Version: v10.16.2
  • Browser/OS: Debian 4.19.67-2+deb10u2
  • Database: MariaDB
bug help wanted stale themes / frontend

Most helpful comment

@Edd-G & @jeffdaley I see what the problem is now.

For some reason assumed the issue is the same as in linked one where the problem was for pages accessed through routes configuration.

For this instance, the problem is a little different it has to do with collections configuration. Might be related to update to metadata generation we did lately - https://github.com/TryGhost/Ghost/pull/11068, specifically this change - https://github.com/TryGhost/Ghost/pull/11068/files#diff-b1da6b1605d94d5819bea1f7adb1f603L6.

Dynamic routing was left from the rules taken into account :grimacing:

Think the correct behavior in this situation should be a following rule for fallback condition:

{settings.meta_title || settings.title} (Page x)

Fyi, @kevinansfield

All 13 comments

I _think_ this is the same as #10082

@vikaspotluri123 maybe you're right. Then why #10082 the status closed?

Hey @Edd-G. Did a little spin to it but wasn't able to reproduce. Used the same 'blog' entry in routes.yaml (the template is exact copy of page.hbs):

collections:
  /blog/:
    permalink: /blog/{slug}/
    template: home
    filter: primary_tag:blog
    data: tag.blog

And it worked just fine for me:
Screenshot from 2019-11-26 11-24-05

What theme are you using? I tried it on slightly modified Lyra.

Then why #10082 the status closed?

If the issue is not causing big 'pain' to most of the users we usually leave it for the community itself to pick up :slightly_smiling_face: It wasn't picked up, so after a while got closed due to other priorities.

Hi! @gargol
I use https://github.com/eddiesigner/liebling
but i have the same problem with Liebling and Lyra theme.

I tryed use Lyra, did what you described.

  1. Install Lyra
  2. Copy themes/Lyra-master/page.hbs to themes/Lyra-master/blog.hbs
  3. Upload my Routes.yaml
routes:
  /rss/turbo-page/:
    template: turbo-page
    content_type: text/xml
  /: home

collections:
  /cases/:
    permalink: /cases/{slug}/
    template: cases
    filter: primary_tag:cases
    data: tag.cases
  /blog/:
    permalink: /blog/{slug}/
    template: blog
    filter: primary_tag:blog
    data: tag.blog

taxonomies:
  tag: /tag/{slug}/
  author: /blog/author/{slug}/

and see blank page, show only header & footer template.
Exact copy of page.hbs don't work.
Works only after small changes. But i still see "Site title (Page 1)" in title url http://mysite/blog/

I also checked the demo site https://lyra.ghost.io/tag/getting-started/
I can鈥檛 see the tag <meta name=descruption> there, as you have in the screenshot.

I'm also getting (Page 1) in the <title> and no meta description.

@Edd-G & @jeffdaley I see what the problem is now.

For some reason assumed the issue is the same as in linked one where the problem was for pages accessed through routes configuration.

For this instance, the problem is a little different it has to do with collections configuration. Might be related to update to metadata generation we did lately - https://github.com/TryGhost/Ghost/pull/11068, specifically this change - https://github.com/TryGhost/Ghost/pull/11068/files#diff-b1da6b1605d94d5819bea1f7adb1f603L6.

Dynamic routing was left from the rules taken into account :grimacing:

Think the correct behavior in this situation should be a following rule for fallback condition:

{settings.meta_title || settings.title} (Page x)

Fyi, @kevinansfield

@gargol those changes only went out in 3.1.0. I'm a little confused as to what the status of this issue is now, OP is not using the updated meta data rules, are you testing against the updated rules or the old rules?

Dynamic routing was left from the rules taken into account 馃槵

Which contexts are missing?

are you testing against the updated rules or the old rules?

Was testing against master - current 3.1.0

Which contexts are missing?

Not a specific context but a "fallback" condition mentioned above - https://github.com/TryGhost/Ghost/blob/master/core/frontend/meta/title.js#L52 is not behaving the same way anymore :)

The fallback there is irrelevant. The issue is that the tag's meta data (specified with data: tag.blog) is not being used on the collection index page - it should never be hitting the fallback.

In so far as the fallback goes it's now following the intended behaviour as far as I'm aware. The meta data set via the settings screen (this is what it sounds like you are referring to - please correct me if I'm wrong!) is intended for the homepage not as a fallback everywhere.

The fallback there is irrelevant.

@kevinansfield in the case described in the issue, where your route config contains a collection like such:

  /cases/:
    permalink: /cases/{slug}/
    template: index
    filter: primary_tag:cases
    data: tag.cases

The context which is passed into title helper is ["cases"]. It can be more than one filter that defines the collection, so it wouldn't be correct to put a "tag" context on it. We could put in detection of cases where just one tag defines a collection and add "tag" context to it, but that's not a current expectation I believe.

To hit the "tag" context condition you can access taxonomy tag: /tag/{slug}/ through e.g /tag/green/ which then behaves as you described :)

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

What is the status of this? and is there a workaround?

@agustinv there were no updates to this issue and no known workaround. Feel free to pick it up in case you are interested :wink:

Was this page helpful?
0 / 5 - 0 ratings