Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
It might be nice to add a setting so that the page title tag can also modify the actual title on the pages, available as $title on most themes. It's probably an easy addition for who knows the module best and a nice addition to the module. I realize it might be a bit above "metatag" but it's simple and good enough.
If willing to consider something like this, and if I can find some time, I might try to work it out, however, it's probably simpler for the devs.
Comments
Comment #1
DamienMcKennaThis isn't something that we're going to handle inside Metatag, you're better off using something that's controlling the actual page display, e.g. Panelizer, Panels, Views, etc.
Comment #2
hanoiiIt's a pity, because most of the time, the SEO title tag should be very close to the actual h1 page title, and having to maintain the same logic on several other modules is not the best approach, but I understand and appreciate the time.
I am changing this into a support question then, I am trying to do this on a theme level, but I can't seem to get around to properly query the title tag from the HOOK_preprocess_page(), I tried a lot of things, but I can't seem to get the metatags no matter what I do. HOOK_preprocess_html() where all happens runs after the page, is there a way to do this? Any idea/help? Thanks!
While I was writing this, I just tried something that worked, but it's a bit strange, I am setting a static var in HOOK_metatag_metatags_view_alter() in a helper module with the head title which can then pull it from the HOOK_preprocess_page() and use it, but there must be a better way, right?
Thanks
Comment #3
hanoiiOk, this really doesn't work, it works the first time, but as metatags get cached, the alter is not run on every page load and then I miss to set the static variable on subsequent refreshes, any help then?
Thanks,
a.=
Comment #4
DamienMcKennaI still think you're going about this the wrong way. Usually it's the content title that gets sucked into the page title, not the other way around; the reason for this is that you usually append the site's name to the page title, e.g. "A funny article | My silly site" would be the page title for content with the title "A funny article" on a site named "My silly site". Can you approach it from this perspective, i.e. get the content title the way you want and then pull that into Metatag?
Comment #5
hanoiiNow that you put it this way, it really make more sense. Already worked it out that way without that many trouble, the only issue was to where to properly set title, but that was beyond your module. Thanks for the help.