SEO Plugin MetaKnight Not Working with Subpages?

I was using the Kirby 3 SEO Plugin for a client project, however the client noticed that the plugin wasn’t working with subpages of pages. It’d just display the information for the parent page. I decided to switch over to MetaKnight as I thought it was an issue with the plugin plus it seems more robust.

However, upon testing the new plugin, it’s also throwing errors with subpages of pages! I’ve followed the instructions for setup on the github README and added it to both the parent of a subpage like so:

Parent Page: Projects.yml

title: The Center

extends: layouts/triple-structure

tabs: 
  main:
    sections:
      description:
        type: fields
        fields: 
          text:
            label: The Center Description
          hpfeatured:
            label: Featured Projects
            help: Select projects to feature on the homepage. To choose episodes for each project, visit the project page itself. 
            min: 1
            max: 5
            type: structure
            fields:
                hpoption:
                  type: select
                  options: query
                  query: 
                    fetch: page.children.published
                    value: "{{ page.id }}"
           
  subpage:
    label: Edit Projects
    sections:
      drafts:
        extends: sections/projects

      unlisted:
        extends: sections/projects
        headline: In Review or Unlisted
        status: unlisted
        
      listed:
        extends: sections/projects
        headline: Published Projects
        status: listed

    seotab: seo

and it works properly in that case:

But when it’s instead added to the child page of that subpage like in Project.yml

title: Project

icon: 🖼

status:
  draft: true
  unlisted: true
  listed: true

extends: layouts/triple-structure 

tabs: 
  subpage:
    label: Edit Episodes
    sections:
      drafts:
        extends: sections/episode

      unlisted:
        extends: sections/episode
        headline: In Review or Unlisted
        status: unlisted

      listed:
        extends: sections/episode
        headline: Published Episodes
        status: listed

  main: 
    label: Edit Project Page
    sections:
      description:
        type: fields
        fields:
          text:
            label: Project Description

          featured:
            label: Featured Episode
            help: Select episode to represent the project if selected for the homepage.
            type: select
            options: query
            query: page.children.published

  seotab: seo

It throws an error:
http://kevincadena.com/lcac/public/la-galeria/artist-portraits

When I inspect the subpage, it seems like all the metadata is being transferred from the panel so I don’t understand what the error could be. Does anyone in here have a idea what the issue is?

Hm, you get the error page, but that doesn’t seem to have anything to do with the plugin.

My assumption is that you have some other issue in that page, probably to do with something redirecting somewhere.

Hmm do you have an idea of what like the redirect could look like?

The site also exists in both english and spanish. Could that be the issue since that’s all I can think of that could change the site URL.

Actually, it’s not even redirecting but the weird things is that when I click on the link “Digital programs”, the URL is http://kevincadena.com/lcac/public/#la-galeria whereas http://kevincadena.com/lcac/public/la-galeria without the # doesn’t work. Does that page even exist? Are you using any routes?

This subpage works, however: http://kevincadena.com/lcac/public/la-galeria/la-pastorela-de-sacramento

Oh my god, that just helped me realize what the issue was. :man_facepalming: I was testing SEO on a page on the site that was a draft. That’s why it was throwing the 404 errors because it wasn’t visible.

Yes I’m going through and now it’s working on all other pages.

Thanks for your help on this!

Can you give some info? My plug-in does indeed work with sub pages (i use it on all my own sites and client sites). Was it really just that the page was a draft?

It should display empty meta tags rather than the parent page data. Not quite sure how you managed that.

I’m also using this plugin on several sites without problems

1 Like

Hmm okay, it might’ve been an issue on my end then. Here’s what I did with the plugin:

  • Setup a controller for each template with the code on the github

  • Added the metadata snippet to the php templates

  • added the YAML code to the blueprint for each template and it shows up properly on the panel.

I think the issue was more when sharing on social media platforms? As when I post on this forum the information shows up properly like so:

However on facebook, it just gives me this. Link is the same:

Your right, sorry about that. I just noticed a small mistake in the plugin.

'metatitle'         => $site->title(),
'metaurl'           => $site->url(),

This should of course be using $page instead. I often override thesae in my controllers, so haven’t spotted it myself. Thank you for letting me know. If you had posted a github issue, i would have fixed this pretty quickly and saved you quite a bit of time. :slight_smile:

ah yeah looking back on it now, I should’ve first posted to GH before switching entirely. I hadn’t ever used SEO Plugins so I wasn’t entirely confident in my use of them. Thanks for addressing this :slight_smile: It’ll be helpful with future projects.

@Brighurst no worries.

If any one is reading this in the future, the issue has been fixed. Run composer upgrade or reinstall manually to get the fix.