Forum

Thread tagged as: Question, Problem

Blog page and archive not displaying Title and Meta info?

Perch: 3.0.14

My blog and archive pages are not displaying meta info such as Page Title and Social attributes?

Below is the code I am using which is pretty much the same and another Perch site where the above issue does not happen.

public/perch/templates/layouts/page-head.php

<!DOCTYPE html>
<html class="no-js" lang="en">
<head>
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta charset="utf-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <meta name="mobile-web-app-capable" content="yes">
  <meta name="apple-mobile-web-app-capable" content="yes">
  <meta name="apple-mobile-web-app-status-bar-style" content="default">

  <?php
    if(perch_layout_has('blog-post'))
    {
      perch_blog_post_meta(perch_get('s'));
    }
    else
    {
      if(perch_layout_has('title'))
      {
        $title = perch_layout_var('title', true);
      }
      else
      {
        $title = perch_pages_title(true);
      }

      echo '<title>' . $title . '</title>';
      perch_page_attributes([
        'template' => 'seo.html'
      ]);
    }
  ?>

public/blog/index.php

<?php include('../perch/runtime.php'); ?>
<?php

perch_content('Company Profile', true);
perch_layout('global/page-head');
perch_layout('global/header');

perch_content('Page Slider'); ?>

<section class="section">
  <div class="container">
    <div class="columns">
      <div class="column is-9">
      <h1 class="is-size-1">Blog</h1>
      <hr />

      <?php
        perch_blog_recent_posts(12);
      ?>

I have also tried...

perch_layout('global/page-head', [
    'page_title' => perch_page_title(true),
]);
Grant Smith

Grant Smith 0 points

  • 3 years ago
Hussein Al Hammad

Hussein Al Hammad 105 points
Registered Developer

Hello Grant,

if(perch_layout_has('title')) checks for a layout variable named title while you're using page_title to pass on the title to the layout.

If you never set the title manually to something different from the actual page title, you don't need to pass a layout variable at all:

if(perch_layout_has('blog-post')) {
    perch_blog_post_meta(perch_get('s'));
} else {
    $title = perch_pages_title(true);
    echo '<title>' . $title . '</title>';

    perch_page_attributes([
    'template' => 'seo.html'
    ]);
}

What doesn't seem to be working here is perch_pages_title(). Do you see the page in the control panel?

Thanks Hussein,

Your reply made me check the location path which wasn't set correctly. Now fixed.

Thanks again