Add a new token for inserting a pager, e.g. " | Page %page" which would become e.g. " | Page 5". Provide a settings page for customizing it.

Original request:


As posted in http://drupal.org/node/1337750#comment-6529578 (screenshot) we need a pager suffix that is only appended, if a pager is shown. The workaround in #1337750: Cache clearing for [current-page:page-number] to avoid duplicate page titles in Views and taxonomy term pages is not really good as it always show a pipe and show a pager number where no pager is shown as documented over there.

Pager Suffix

This feature seems to be the last to get rid of Page Title module that also collide with metatags, so we may be able to take over the code from there.

Comments

Comment from DamienMcKenna at an issue closed as a duplicate of this, Field to control suffix for use on page title fields:

Per couturier's explanation on issue #1337750, there really should be a field for assigning a suffix for use on pages that include a pager, identified by $_GET['page']. It would be best if the API was also extended to allow each meta tag to control whether this suffix was added, e.g. it could be added to the normal Page Title field, the OG:Title field, etc.

I think its not a good idea to add it as a suffix for the title, because not everyone will want to have it at the end, for instance we use this configuration and it works well with the pagination
We use tokens, so that you can put them anywhere in the title.

Also, we use smart paging module to add pagination for nodes: http://ftp.drupal.org/files/projects/smart_paging-7.x-1.x-dev.tar.gz
The link above is for the latest version which features my patch that adds a token for pagination on nodes http://drupal.org/node/1776804
This module is good, because it removes the ?page= from the URL and adds /page/1/0 which is move SEO friendly

Another important bit is that tokens didn't work on every page, and I had to add this patch on http://drupal.org/node/224262#comment-6443384

Can you please try to use the smart paging module from the link above, without applying any patch and apply the patch above for tokens module, with the following metatags configuration:

Global
- Page Title: [current-page:title] | [current-page:page-number] | [site:name]

Global: Front page
- Page Title: [site:name] | [current-page:page-number] | [site:slogan]

Content
- Page Title: [node:title] | [smart-paging:page-number] | [site:name]

Taxonomy Term
- Page Title: [term:name] | [current-page:page-number] | [site:name]

Please let me know how it works for you
We have about 15 sites running on this configuration, for example:

Frontpage: http://www.theweek.co.uk/home/page/1/0
Taxonomy list: http://www.theweek.co.uk/news-opinion/page/2/0
Content: http://www.autoexpress.co.uk/driver-power/page/0/1

This does not work. Pager suffix is only added if a pager is shown and not always. You are also free to keep the field empty.

The tokens use $_GET['page']. If you do not with to display page 1, it can be stripped off on template.php, or you can patch the modules to change the token.

Did you click on the website examples I provided?

Just like marcelovani said, when using the Smart Paging module, before install my URL said:

http://fashionbelle.biz/modest-clothing-reviews/swimsuits?page=3

After following instructions in #2, the same URL reads:

http://fashionbelle.biz/modest-clothing-reviews/swimsuits/page/4/0

However, even with the Tokens module patch, I am not getting page numbers on paginated Views in the TITLE when following all instructions in #2.

Funny, because page numbers for paginated Views in the <title> was working for me a couple of weeks ago. I upgraded to the newest Meta Tags dev version today that has all the latest patches, and now page numbers in the title have disappeared even with tokens asking for them in the settings.

I do understand you token strings. But we do not want to strip anything anywhere on theme level. The module need to handle this and should only append the pager token value if a pager exists.

Maybe you should give page title a try to see how this works to understand what we expect.

Reply to #4 - Huge sites, marcelovani! They look amazing. Yes, I can see you are showing page numbers in your titles. I must be doing something wrong. I'll keep looking at this.

@hass I'm adding more links to pages without pagination, check the title

Node http://www.theweek.co.uk/politics/gategate/49520/plebgate-mitchell-looks...
Taxonomy http://www.theweek.co.uk/pictures
Node http://www.autoexpress.co.uk/ford/mustang/60747/ford-mustang-shelby-gt500

@couturier Thanks, I'm just trying to make a point that it's not necessary to clutter metatag module when you can achieve the same with tokens. Let me know if I can help you with the setup.

@couturier re #5, please apply this on tokens module http://drupal.org/node/224262#comment-6443384

Maybe instead Metatag could provide a new token which could be customized via a settings page? For example, if you add the page title "[current-page:title][metatag:pager] | [site:name]", and you have the pager customized to say " | Page %page", on page 2 it would say e.g. "My important article | Page 2 | My cool site".

@Damien I think this is a great idea, it gives the user the flexibility to decide where to use it.

I like #10.

marcelovani, on #9, I have tried the patch on the current Tokens dev, and it still doesn't work with the Meta Tags dev module released October 11 to make the [current-page:page-number] show up in <title> despite being in the settings. I've removed the Smart Paging module at present to simplify things.

Don't worry about me. I will leave it alone for now. It was working earlier with a previous Meta Tags dev and some patches (which I thought were now all committed to the new dev). If we get #10 going, page numbers in titles should work again.

Title:Add Pager Suffix supportAdd a customizable pager token to extend the normal Token pager
Issue tags:+D7 stable release blocker

Ok, lets refocus the feature request then.

I've just been working for about an hour and a half reviewing the Meta Tags queue and trying different things, and I still don't know why [current-page:page-number] has stopped working for me in the <title> of pages created by Views. I can get the page number to show for plain nodes, but it reverts to an old setting for Views pages, like the cache hasn't been flushed even though I have flushed it many times trying to get the new settings to take effect.

It's okay, I don't need a fix now, I just wanted to report it, since this was working with some manually applied patches to a previous Meta Tags dev. I'm using Drupal stable release 7.15, with the October 11 Meta Tags dev, with Tokens dev and marcelovani's patch applied (from #9). I'm looking forward to [metatag:pager] as a solution.

Someone really experienced with SEO talked to me since my last comment and said they use Page Title with Meta Tags for all their sites that have SEO attention. So, I am working now with both together and am finally seeing my pager number showing up on paginated Views. I'm just leaving the title options in Meta Tags blank and formatting all the titles in Page Title.

Since this works already in Page Title, and the two modules seem to peacefully co-exist, do you still want to work to build paging from the ground up into Meta Tags? I'm also seeing a lot of other fine-grained Page Title options there that don't exist in Meta Tags yet. Can the Page Title people get together with the Meta Tags people and just mesh the two modules? Forgive me if I sound over-simplistic, as I'm not a programmer. I'm just wanting to save everyone some work.

I do not like to use page title myself.

Just tried to add the Smart Paging module in addition to using Page Title and Meta Tags, and it improves URLs, but removes the Page Title enumeration in titles, even with the Smart Paging "display content title suffix" unchecked. Like marcelovani is doing, you cannot use Page Title with Smart Paging and make it work. It has to be done through tokens added to Meta Tags, as described in #2.

Currently I'm using metatag + page_title on every website where SEO is important. This is necessary if you care about SEO.

Any update on this?

You still need to use Metatag and Page Title modules together if you want all features important to SEO. Metatag is slowly incorporating the Page Title functions, but you still have much better control in Page Title. Metatag has coding that recognizes when Page Title is being used on the same website and ensures that the functions do not overlap. It could be different in Drupal 8 or 9, so we will have to re-evaluate at that time and see whether more work has been done on Metatag so that you can do everything from that one module.

Thanks.

Is it possible to import/export title tags between the two modules? I have too many custom titles saved in meta tag.

@standingtall: Rather than waste time on that you could maybe try creating a token to fill in the missing gap between the modules?

Thanks DamienMcKenna

Does Meta Tag module generate a token that can be used in Page Title module?

A lot of my titles are modified at individual level.

@standingtall I'll repeat this, that Metatag cannot give you individual control over your page titles like you are asking. It is always good practice on a large website to automate as much as possible. You can use a toke that takes the title of the node to make each page title different. If you have fewer than a thousand titles, it would be worthwhile to open two browser windows and just transfer the titles into Page Title manually. However, I recommend using a token to make things more standard and faster if you ever want to change which module you are using to control the page titles.

@couturier - Metatag does give that much control. All my tags are automated plus I have the flexibility to override them on node level.

I have over 90,000 nodes so manually copy/pasting is not an option.

How do Metatag and Page Title work together? I mean which gets called first by Drupal if both are installed.

@standingtall So, is your question about how to add a pager suffix number? You could also try the Smart Paging module, see this comment. Page Title is called first (if it is activated and configured) when it is installed along with Metatag. The pager suffix number is the last major feature that needs to be moved to Metatag before developers can comfortably stop using both modules together for SEO. If you would like to program something for this feature in Metatag, it would be greatly appreciated.

Also, last I checked in early 2013, the pager token in Metatag did not actually work. Has that been fixed?

Thanks couturier. I installed Smart Paging and it provides great SEO benefit in its own right.

However, I have not been able to make the page titles work (added patches etc. too).

Currently I am getting issues on first page of Taxonomy terms. Ideally, I would only want to the title suffix to appear on second page onwards but it is adding it even on page 1. Example

My terms | 1 | Site Name

while I would Want

My terms | Site Name
My terms | 1 | Site Name
My terms | 2 | Site Name

onwards.

Furthermore, I was achieving this without Smart Paging as well so not sure Smart Paging has any impact here at all. Token [smart-paging:page-number] doesn't work on Taxonomy pages either.

To remove the | 1 | you can add this to your template.php

function template_preprocess_html(&$vars) {
// remove page from title when page = 1.
$vars['head_title'] = str_replace('| 1 |', '|', $vars['head_title']);
}

You can use your theme name instead of the word 'template' i.e. zen_preprocess_html()

Thanks #28 worked like a charm. Issue solved for me.

I am using Smart Paging and the most recent dev of Metatag. I've tried using both tokens, [smart-paging:page-number] [current-page:page-number], and both always return a 1 even when it is not the first page. This is the case on Taxonomy Term pages and Views generated pages.

@standingtall Can you post what patches/versions you are using to get the Page numbers to work on Taxonomy pages?

Or could someone else point me in the right direction? Thanks!

If you are using Smart Paging, I don't think you need a token in Metatag for the URL of Views-generated multi-page displays. Have you tried removing all those tokens in Metatag and seeing what Smart Paging generates on its own?

Issue summary:View changes

Refocusing the request.

We can use Metatag Context, Context and Context Query Parameters to set up metatags on pages with ?page= parameter in url.

For example:

  1. Go to admin/structure/context page.
  2. Click Add and open admin/structure/context/add page
  3. Set up Name - pager, Conditions - Query parameters, Parameter name - page, Operator - must be set and have some value, Parameter value - empty.
  4. Reactions - select Meta Data, Page Title - [current-page:title] - Page [current-page:page-number]

This page title now will be work only on pages with pager (?page=123) exept the first page (without ?page in url).