Topic-icon Set OpenGraph Title for Article (com_content) with Page Title

Active Subscriptions:

None
8 years 8 months ago - 8 years 8 months ago #54458 by altitudes
Hello

Here is what we have in content.php for Content opengraph plugin:
$this->addOpenGraphTag('title', $article->title, false);
So, once you have installed the plugin, the page title is not used anymore to set the OpenGraph title on articles. Am I right?

Would it be possible to introduce an option in this plugin to define how the OpenGraph title should be set? The option could be "Title Type = Page Title / Article Title", just like we have an option "Description Type = Meta / Intro Words / Intro Characters" for OpenGraph description.
This would allow a better control on the article OpenGraph titles. In my case, I set the page title using sh404SEF, and want JFBConnect to reuse it for OpenGraph title.

Thank you
Last edit: 8 years 8 months ago by altitudes.
The topic has been locked.
Support Specialist
There isn't actually a meta title tag in the HTML spec. There are meta description, keyword and other tags, but title is a standalone element.

While some SEO tools can set a meta name="title" tag, it's not a standard and search engines, to my knowledge, don't recognize additional meta title tags and use the standard <title> tag instead (or use an algorithm to select a better title from the page contents). For reference, you can see Google's own Mega tags that Google understands info.

I hope that helps explain, but if you need anything else, please let us know.

Thanks,
Alex
The topic has been locked.
Active Subscriptions:

None
Yes, you are right. In fact what I had in mind was page title, not meta title.

I have updated my message accordingly, can you please read it again and provide an updated answer? ;)
The topic has been locked.
Support Specialist
Thanks for clarifying. Right now, JFBConnect does use the article title for the Open Graph title. Joomla also, by default, uses the article title as the title element for the page. We don't have any support for sh404SEF specifically, but something you could try is updating the code you mention above to:
$document = JFactory::getDocument();
$title = $document->getTitle();
$this->addOpenGraphTag('title', $title, false);
The problem with that is that the document title may not be set properly by sh404SEF at that point. Many times, sh404SEF alters the page output right at the very last second, which means there's no way for JFBConnect to easily access any updates sh404SEF has performed. In general, we don't like the idea of supporting one meta tag management solution over another as it opens a huge can of worms (and compatibility issues).

The other option, of course, is to set the article title to whatever you want the page title to be. Is there a reason you don't want to do this? Not pushing you to do so, but understanding your needs helps us understand our customers.

Thanks,
Alex
The topic has been locked.
Active Subscriptions:

None
Hello

sh404SEF has a develoment version that is compliant with Joomla API and sets page title and description according to it (i.e. not "at the last second"). Problem is: even if page title is output correctly, JFB doesn't pick it up because it does not use the Joomla API for that but rather get the title directly from the article. Using the code mentioned above indeed fixes the problem, but it would be better having an option that allows to define where JFBConnect should get the title from (previously suggested option "Title Type = Page Title / Article Title").

Another problem will be that at this time, there is no way to specify how JFBConnect should set the OpenGraph tags for com_content by default (i.e. if no OpenGraph object was defined in JFBConnect). I think that's something missing: being able to define the default behaviour, and then only the specific behaviour through OpenGrah objects (e.g. for article in a given category etc.).

Regarding you suggestion "The other option, of course, is to set the article title to whatever you want the page title to be":
I've set sh404SEF to add the article category and site name to the page title, and that's what I want to have in the OpenGraph title too. Article authors should not have to handle it.
The topic has been locked.
Support Specialist

Problem is: even if page title is output correctly, JFB doesn't pick it up because it does not use the Joomla API for that but rather get the title directly from the article. Using the code mentioned above indeed fixes the problem, but it would be better having an option that allows to define where JFBConnect should get the title from (previously suggested option "Title Type = Page Title / Article Title").

I'm glad to hear the code fix above fixes the issue. The purpose of sending it to you was to test. We understand we don't do that now. You're the first user to bring this issue up though, so we just hadn't ever tried a different way.

I'm adding a to-do to our issue tracker to add an option like you recommend in the future.

Another problem will be that at this time, there is no way to specify how JFBConnect should set the OpenGraph tags for com_content by default (i.e. if no OpenGraph object was defined in JFBConnect). I think that's something missing: being able to define the default behaviour, and then only the specific behaviour through OpenGrah objects (e.g. for article in a given category etc.).

You're correct. The only defaults are what JFBConnect ships with. Again, this is ok with us as 99%+ users don't have issues with our defaults. If you need to override our defaults, you can create one object and set it on the parent category of your articles. That will apply to all sub-articles. Then, you can create objects for any sub-categories that you want to have different settings for.

Regarding you suggestion "The other option, of course, is to set the article title to whatever you want the page title to be":
I've set sh404SEF to add the article category and site name to the page title, and that's what I want to have in the OpenGraph title too. Article authors should not have to handle it.

Thank you for explaining your use case. It really does help. As noted, we added this to investigate in the future. I'm honestly not sure if we'll make it an option (article title vs title tag) or just use the title tag always. For most users that don't use sh404SEF or other title tag managers, the option would be redundant and we don't want to add more confusion to the process.

Thanks again,
Alex
The topic has been locked.
Active Subscriptions:

None
8 years 8 months ago - 8 years 8 months ago #54480 by altitudes

If you need to override our defaults, you can create one object and set it on the parent category of your articles. That will apply to all sub-articles. Then, you can create objects for any sub-categories that you want to have different settings for.

How will JFBConnect handle this? It will use the last object found? If so, it means that the objects need to be in a precise order. It will get a bit tricky as JFBConnect does not allow to change the objects order (so they must be created in the right order from the start!).
So I must add another feature to my request ;) : ability to reorder OpenGraph objects.

For most users that don't use sh404SEF or other title tag managers, the option would be redundant and we don't want to add more confusion to the process.

I think it's not only for sh404SEF or other title tag managers, as Joomla itself allows to define the page title in menu items...

I understand that, even if my requests may be relevant, as no other customer had the same ones before, it's not high priority ;)
Last edit: 8 years 8 months ago by altitudes.
The topic has been locked.
Support Specialist
No, ordering isn't required. Objects are applied by the best category they apply to. JFBConnect looks 'up' from the current category to find the first object that would apply. So, if there's an object for the current article's category, it will apply. If not, JFBConnect will look for an object for the category's parent and apply it. If not, it will keep going up to find the first object that is a parent of the current article until it reaches the root. If none is found, then the JFBC defaults will be used. Ordering would be terrible :)

Good point on the menu item title. I was trying to think where else the title could be set within Joomla and was only looking in the category manager.

As noted, I think the best, immediate, solution is to update to use the document->getTitle call. That seems like a much better default. Then, we'll investigate whether to add an option for article title instead, which can be applied on a per-category basis.

Thanks again!
The topic has been locked.
Active Subscriptions:

None
Thank you. I think everything is clear now.
The topic has been locked.
Support Specialist
Fantastic! If you have any other questions, please let me know.

Thanks,
Alex
The topic has been locked.