Jump to content

Is it possible to shorten the page title or make an alias for it?


Boost
 Share

Recommended Posts

Hi,

Due to SEO, my page titles are somewhat lengthy and are being cropped in the 'Pages -> Tree' menu. Additionally, they are verbose, making it difficult to quickly locate the pages. Is there a plugin that allows me to create an alias for the page title that would only be used in the backend, not the frontend?

Cheers

Link to comment
Share on other sites

You Can change what Field is Shown inside of the Admin Panel, you can find it in the Modules -> Core -> Page List -> Config

It is also possible to change this setting for each template individually, Just Go to your template and Open the Advanced tab, there‘s a config for this 😉 

Just add a „Short Title“ field to your template and Show it in the Page tree…

Link to comment
Share on other sites

An alternative approach using native PW is to make your titles the shorter version and use a field, eg 'headline' for the lengthy version. In your templates use:

<h1><?=$page->get('headline|title')?></h1>

This will output the headline if it's available and if not, the title. You can then also use the shorter version in front end menus, etc.

In the admin page list, it will default to the shorter 'title' field.

If you need the front end page URL to be the longer version for SEO, you could add a hook in templates/ready.php, eg (untested):

<?php

$wire->addHookBefore('Pages::saved', function(HookEvent $event) {
  $page = $event->arguments(0);
  
  // ensure it meets the requirements
  if (empty($page->headline) || $page->template !== 'your-template-name') return;
  
  // regenerate the page url from the headline field
  $page->url = wire('sanitizer')->pageName('headline');

  // Populate back arguments 
  $event->arguments(0, $page);
});

And another way....

In your template, Advanced tab, under "List of fields to display in the Admin Page List", simply enter {name-of-your-shorter-field}

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...