Advertisement

Change H2 to H1 il blog

For Joomla! 5.x Coding related discussions, you could also use: http://groups.google.com/group/joomla-dev-general

Moderators: ooffick, General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
Windows Defender SmartScreen Issues <-- please read this if using Windows 10.
Post Reply
pjuignet
Joomla! Apprentice
Joomla! Apprentice
Posts: 25
Joined: Mon Apr 06, 2015 3:34 pm

Change H2 to H1 il blog

Post by pjuignet » Wed Jan 15, 2025 10:50 am

Hello and Happy New Year,

I would like to change the H2 titles of the blog articles to put them in H1. (and only of the blog not for the other categories). The problem is that all the articles of the blog have the same title H1 which is the title of the blog which is bad for SEO.

Does anyone know in which file to do an overload and which part of the code to locate?

I suppose it is in com_content > blog.php, but I can't find it.

As for the code it should look like ($this->item->title) . '</h2>' to transform into ($this->item->title) . '</h1>' but I'm not sure.

Advertisement
User avatar
AMurray
Joomla! Master
Joomla! Master
Posts: 10488
Joined: Sat Feb 13, 2010 7:35 am
Location: Australia

Re: Change H2 to H1 il blog

Post by AMurray » Wed Jan 15, 2025 12:09 pm

styles like that are done in CSS not PHP. Don't change core files, create overrides.
Regards - A Murray
Global Support Moderator

pjuignet
Joomla! Apprentice
Joomla! Apprentice
Posts: 25
Joined: Mon Apr 06, 2015 3:34 pm

Re: Change H2 to H1 il blog

Post by pjuignet » Wed Jan 15, 2025 1:21 pm

I don't now how I can change H2 to H1 utilizing CCS.
Can you tel me ?

gws
Joomla! Champion
Joomla! Champion
Posts: 6575
Joined: Tue Aug 23, 2005 1:56 pm
Location: South coast, UK
Contact:

Re: Change H2 to H1 il blog

Post by gws » Wed Jan 15, 2025 1:41 pm


pjuignet
Joomla! Apprentice
Joomla! Apprentice
Posts: 25
Joined: Mon Apr 06, 2015 3:34 pm

Re: Change H2 to H1 il blog

Post by pjuignet » Wed Jan 15, 2025 2:28 pm

It is not possible to change an HTML title <h2> to <h1> using CSS, because CSS does not change the HTML structure. CSS can only change the visual appearance of an element.
When you don't know, it is best to keep quiet.

gws
Joomla! Champion
Joomla! Champion
Posts: 6575
Joined: Tue Aug 23, 2005 1:56 pm
Location: South coast, UK
Contact:

Re: Change H2 to H1 il blog

Post by gws » Wed Jan 15, 2025 2:38 pm

pjuignet wrote: Wed Jan 15, 2025 1:21 pm I don't now how I can change H2 to H1 utilizing CCS.
Can you tel me ?
I answered your question. You can be sure Hell will freeze over before I help you in the future.

Mr. Wimpy
Joomla! Guru
Joomla! Guru
Posts: 607
Joined: Fri Dec 02, 2005 10:46 am
Location: The Netherlands

Re: Change H2 to H1 il blog

Post by Mr. Wimpy » Wed Jan 15, 2025 3:12 pm

Can you explain a bit more? Maybe with examples.

Where do you want to change the headings?
On the page with article intros (Category Blog)? Or on the full article?

From what I can understand I think you need to create an override.

User avatar
ceford
Joomla! Hero
Joomla! Hero
Posts: 2979
Joined: Mon Feb 24, 2014 10:38 pm
Location: Edinburgh, Scotland
Contact:

Re: Change H2 to H1 il blog

Post by ceford » Thu Jan 16, 2025 6:20 pm

A page should only contain ONE h1 heading. Joomla sets article titles to h2 in blog layouts but h1 in single article layouts. If you defy the ONE h1 standard your SEO will take a hit - seems to to be the exact opposite of what you want.

User avatar
Pavel-ww
Joomla! Ace
Joomla! Ace
Posts: 1807
Joined: Tue Jun 30, 2020 12:17 pm

Re: Change H2 to H1 il blog

Post by Pavel-ww » Fri Jan 17, 2025 7:41 am

pjuignet wrote: Wed Jan 15, 2025 10:50 am I would like to change the H2 titles of the blog articles to put them in H1. (and only of the blog not for the other categories). The problem is that all the articles of the blog have the same title H1 which is the title of the blog which is bad for SEO.
Hi. Turn OFF page heading in Category Blog menu item settings.
3.jpg
-

Turn ON category discription (if OFF).
2.jpg
--

Use Category Discription editor to add h1 to the category page only.
1.jpg
After that, all main headlines inside the articles will automatically turn into h1.


Or if you want to make override
4.jpg

-------------------

I want to note that the Page Heading option in the aspect of categories and the addition of it to the article pages is not SEO and user friendly. This behavior should be corrected for a long time, but continues to remain in Joomla for decades. Therefore, we have to look for workarounds.
You do not have the required permissions to view the files attached to this post.

pjuignet
Joomla! Apprentice
Joomla! Apprentice
Posts: 25
Joined: Mon Apr 06, 2015 3:34 pm

Re: Change H2 to H1 il blog

Post by pjuignet » Fri Jan 17, 2025 10:01 am

Hello Pavel Wimpy and ceford,

I give an exemple. The blog "News" has 10 articles named "news 1", 2, 3, 4, etc...
Each article has for H1 "News" and for H2 "news1", "news 2", etc.
Having 10 H1 titles "News" seems bad for SEO.
It seems to me that it would be better to delete "News" and have "news1", "news 2", etc. as H1 titles.

to Pavel-ww
I have already tried as you say by going through the Joomla interface. The problem remains the same: all the articles of the blog have an identical H1 title and the specific titles of each article remain in H2.

Yes, I want to do an override. The method you give seems the right one. But, I am afraid that by going through default.php it will apply to the whole site.
Wouldn't it be better to modify blog.php ?

User avatar
Pavel-ww
Joomla! Ace
Joomla! Ace
Posts: 1807
Joined: Tue Jun 30, 2020 12:17 pm

Re: Change H2 to H1 il blog

Post by Pavel-ww » Fri Jan 17, 2025 3:34 pm

pjuignet wrote: Fri Jan 17, 2025 10:01 am to Pavel-ww
I have already tried as you say by going through the Joomla interface. The problem remains the same: all the articles of the blog have an identical H1 title and the specific titles of each article remain in H2.

Yes, I want to do an override. The method you give seems the right one. But, I am afraid that by going through default.php it will apply to the whole site.
Wouldn't it be better to modify blog.php ?
Now you confused me :D . Provide a link to the site and screenshot that you want to change. It is better to see once than guess.

pjuignet
Joomla! Apprentice
Joomla! Apprentice
Posts: 25
Joined: Mon Apr 06, 2015 3:34 pm

Re: Change H2 to H1 il blog

Post by pjuignet » Fri Jan 17, 2025 4:25 pm

The site is a French university site:
https://philosciences.com

The home page is "Actualités". It is a blog of "Actualités" category that has 195 articles. If I let the category name be displayed, there are 195 identical H1 titles "Actualités". In my opinion, this is not good for SEO.
It seems to me that it would be better if the titles of each article were H1.

By exemple, on the current page, the title of the article "Artificial Intelligence and its political, cultural and societal implications" is H2. It is better if it is H1.

I would like the 195 titles of the 195 articles to be H1.

This may be impossible if Joomla is configured to put the blog title in H1 and the article titles in H2 ?

Image
You do not have the required permissions to view the files attached to this post.

Mr. Wimpy
Joomla! Guru
Joomla! Guru
Posts: 607
Joined: Fri Dec 02, 2005 10:46 am
Location: The Netherlands

Re: Change H2 to H1 il blog

Post by Mr. Wimpy » Fri Jan 17, 2025 4:53 pm

Ah, I see...

As it is at this moment I would:

Create an override for:
- blog.php
- blog_item.php

Rename them to:
- actualites.php
- actualites_item.php

Open actulites_item.php and change <h2></h2> to <h1></h1>

In Joomla administrator:
Open the cateogory Actualites
Go to tab: Options and set Layout to Actualites

User avatar
Pavel-ww
Joomla! Ace
Joomla! Ace
Posts: 1807
Joined: Tue Jun 30, 2020 12:17 pm

Re: Change H2 to H1 il blog

Post by Pavel-ww » Sat Jan 18, 2025 7:36 am

Mr. Wimpy wrote: Fri Jan 17, 2025 4:53 pm Create an override for:
- blog.php
- blog_item.php

Rename them to:
- actualites.php
- actualites_item.php
Hi Mr. Wimpy.

Note: You can’t just override the category blog layout by copy and renaming files only. Additionally, it is necessary to create an alternative menu item and make changes to XML.

But in OP's case, the creation of an override for the blog does not make sense.

And that's why...

Hi @pjuignet.

... You use the blog category to display full articles through pagination. This is fundamentally wrong. The blog category should be listing of articles with introtext, links to full articles, read more buttons, etc.

Joomla works absolutely correctly. But you are trying to break it. :)

Should looks like this.

Image


Now you have no links to individual articles, but there are links that Google perceives as an element of pagination and glues such pages. This is worse for SEO than problems with headlines. And even critically bad.

For Google all pagination links are the same page only with different GET parameters. Single articles do not have a separate SEF URLs.

You are mistaken that before that you had hundreds of H1. You had only one H1 on one page divided by pagination.

Trying to change articles headings from h2 to h1 you will receive hundreds of h1 on one page. That is, you will get exactly what you wanted to get rid of.

Image

You should redo this using the category for its intended purpose. And then you can use the tips from my post above.

But if you want to stay on the wrong way, to create override follow the advice of Mr. Wimpy with the exception of file renaming

pjuignet
Joomla! Apprentice
Joomla! Apprentice
Posts: 25
Joined: Mon Apr 06, 2015 3:34 pm

Re: Change H2 to H1 il blog

Post by pjuignet » Sat Jan 18, 2025 8:40 am

OK Pavel.
I undertand, it is not a good way.

In a first time, what I do, is to suppress the 195 blog title H1, and put <p>Actualités</p>. I have no more are 195 identical H1 titles "Actualités".
I let article tittle as h2.

In a second time what can I do ? One solution i to return to classic blog as you said.

But I want to have something like a book, we turn the pages. This is why I am trying to hijack the blog. Maybe I should give up. When you modify the code in Joomla, there are unintended effects that appear.

Thank you for your help.

pjuignet
Joomla! Apprentice
Joomla! Apprentice
Posts: 25
Joined: Mon Apr 06, 2015 3:34 pm

Re: Change H2 to H1 il blog

Post by pjuignet » Sat Jan 18, 2025 11:12 am

Pavel,
I think about you said about
Trying to change articles headings from h2 to h1 you will receive hundreds of h1 on one page. That is, you will get exactly what you wanted to get rid of.
You are right, even if I manage to modify the blog in the blog.php code, there will still be the problem of the urls that will mislead search engines.

I put everything back in classic blog.

Thank you very much. :)

User avatar
Pavel-ww
Joomla! Ace
Joomla! Ace
Posts: 1807
Joined: Tue Jun 30, 2020 12:17 pm

Re: Change H2 to H1 il blog

Post by Pavel-ww » Sat Jan 18, 2025 11:26 am

pjuignet wrote: Sat Jan 18, 2025 8:40 am But I want to have something like a book.
You can use this option

Image

It adds prev/next buttons to the each single article

Mr. Wimpy
Joomla! Guru
Joomla! Guru
Posts: 607
Joined: Fri Dec 02, 2005 10:46 am
Location: The Netherlands

Re: Change H2 to H1 il blog

Post by Mr. Wimpy » Sat Jan 18, 2025 12:55 pm

Pavel-ww wrote: Sat Jan 18, 2025 7:36 amYou can’t just override the category blog layout by copy and renaming files only. Additionally, it is necessary to create an alternative menu item and make changes to XML.
You are correct: you would need an alternative menu item in this case...

Though you can just override the layout of a category by copying and renaming.
The override would only apply if the category is not linked to a menu item.


Anyway, back to the solution...

If it should read like a book:
Yes, you should use the navigation option, suggested by Pavel.

Also I would recomend using the category list menu item and/or the articles module.
So readers can go straight to an article of interest or continue reading without having to click through all articles/pages.

pjuignet
Joomla! Apprentice
Joomla! Apprentice
Posts: 25
Joined: Mon Apr 06, 2015 3:34 pm

Re: Change H2 to H1 il blog

Post by pjuignet » Sat Jan 18, 2025 3:10 pm

Navigation > Show
Thanks, I already did it.

Still, if a blog named BLOG has 100 pages, there will be 100 titles <h1> BLOG </h1>. Isn't that a problem for seo ?

pjuignet
Joomla! Apprentice
Joomla! Apprentice
Posts: 25
Joined: Mon Apr 06, 2015 3:34 pm

Re: Change H2 to H1 il blog

Post by pjuignet » Sat Jan 18, 2025 6:32 pm

Anyway, it doesn't matter, we'll deal with it.

A problem has appeared: All the article pages now have the title News which is the title of the blog on the home page.

div class="page-header">
<h1> News </h1>
Capture d’écran 2025-01-18 184041.png
If somebody has an idea ?
You do not have the required permissions to view the files attached to this post.

pjuignet
Joomla! Apprentice
Joomla! Apprentice
Posts: 25
Joined: Mon Apr 06, 2015 3:34 pm

Re: Change H2 to H1 il blog

Post by pjuignet » Sat Jan 18, 2025 7:06 pm

By chance, I found the solution: In the home blog hide the page header and it is reflected on all the pages of the site which are then rid of the untimely title.
Joomla has some oddities!

Advertisement

Post Reply

Return to “Joomla! 5.x Coding”