How do I create a Joomla 4 template overide that converts H2 to H1 ?
Moderator: General Support Moderators
Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting.
Forum Post Assistant - If you are serious about wanting help, you should use this tool to help you post.
Windows Defender SmartScreen Issues <-- please read this if using Windows 10
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting.
Forum Post Assistant - If you are serious about wanting help, you should use this tool to help you post.
Windows Defender SmartScreen Issues <-- please read this if using Windows 10
- woodyf4u
- Joomla! Intern
- Posts: 72
- Joined: Tue Aug 12, 2008 7:04 pm
- Contact:
How do I create a Joomla 4 template overide that converts H2 to H1 ?
Hi,
I'm checking a website for WCAG standards.
One of the important things that matters to screen reader users is the layout of the headings.
By default, Joomla makes an article title an H2, while someone with a screen reader expects an H1 here.
I found 3 topics for Joomla with tips for template overides.
But the path to the file to edit does not exist in Joomla 4.
Anyone know how to make an overide for Joomla 4 that converts the H2 to H1 ?
I'm checking a website for WCAG standards.
One of the important things that matters to screen reader users is the layout of the headings.
By default, Joomla makes an article title an H2, while someone with a screen reader expects an H1 here.
I found 3 topics for Joomla with tips for template overides.
But the path to the file to edit does not exist in Joomla 4.
Anyone know how to make an overide for Joomla 4 that converts the H2 to H1 ?
Best regards / vriendelijke groeten,
Wouter (WoodyF4u)
Wouter (WoodyF4u)
- AMurray
- Joomla! Exemplar
- Posts: 9711
- Joined: Sat Feb 13, 2010 7:35 am
- Location: Australia
Re: How do I create a Joomla 4 template overide that converts H2 to H1 ?
For such a simple thing, I would suggest something like Regular Lab's RePlacer.
https://extensions.joomla.org/extension/db-replacer/
it can replace any text you specify, including HTML tags so you say, search for H2 and replace with H1.
Just be sure H1 is not already being used in the page e.g. as the general site's title as I think the general rule is no more than 1 H1 tag on the page, (as that would effect SEO).
https://extensions.joomla.org/extension/db-replacer/
it can replace any text you specify, including HTML tags so you say, search for H2 and replace with H1.
Just be sure H1 is not already being used in the page e.g. as the general site's title as I think the general rule is no more than 1 H1 tag on the page, (as that would effect SEO).
Regards - A Murray
General Support Moderator
General Support Moderator
- brian
- Joomla! Master
- Posts: 12785
- Joined: Fri Aug 12, 2005 7:19 am
- Location: Leeds, UK
- Contact:
Re: How do I create a Joomla 4 template overide that converts H2 to H1 ?
DO NOT USE db replacer for this - it wont work as the code you are looking to change is NOT in the database.
You are using joomla 4 and the template overrides should be almost the same as in joomla 3.
However Joomla 4 is already coded to change the article title to H1 if there is not already a page title with an H1.
Do you perhaps already have a template override in place that does not include that code? Or maybe you already have a page title which is an H1 in which case joomla is correctly setting the article title to H2
You are using joomla 4 and the template overrides should be almost the same as in joomla 3.
However Joomla 4 is already coded to change the article title to H1 if there is not already a page title with an H1.
Do you perhaps already have a template override in place that does not include that code? Or maybe you already have a page title which is an H1 in which case joomla is correctly setting the article title to H2
"Exploited yesterday... Hacked tomorrow"
Blog http://brian.teeman.net/
Joomla Hidden Secrets http://hiddenjoomlasecrets.com/
Blog http://brian.teeman.net/
Joomla Hidden Secrets http://hiddenjoomlasecrets.com/
- woodyf4u
- Joomla! Intern
- Posts: 72
- Joined: Tue Aug 12, 2008 7:04 pm
- Contact:
Re: How do I create a Joomla 4 template overide that converts H2 to H1 ?
Hi Brian,
DB Replacer didn't seem the best solution to me either, because the article construction is done through php files and not in the database.
You wrote that Joomla 4 creates an H1 heading for an article title by default. But I can't reproduce that.
Even on a clean Joomla 4 installation an article title gets an H2.
Are you sure it should be programmed like this in Joomla 4?
Looking here: https://www.itoctopus.com/how-to-change ... -in-joomla
then you see that the file default.php has a section about the H1 and the H2. But that's in Joomla 3.
When I look up the file in Joomla 4 that I think is the most similar, I don't see a line in it for both.
So I still suspect I need to create an override, but don't know how and in which file for Joomla 4.
DB Replacer didn't seem the best solution to me either, because the article construction is done through php files and not in the database.
You wrote that Joomla 4 creates an H1 heading for an article title by default. But I can't reproduce that.
Even on a clean Joomla 4 installation an article title gets an H2.
Are you sure it should be programmed like this in Joomla 4?
Looking here: https://www.itoctopus.com/how-to-change ... -in-joomla
then you see that the file default.php has a section about the H1 and the H2. But that's in Joomla 3.
When I look up the file in Joomla 4 that I think is the most similar, I don't see a line in it for both.
So I still suspect I need to create an override, but don't know how and in which file for Joomla 4.
Best regards / vriendelijke groeten,
Wouter (WoodyF4u)
Wouter (WoodyF4u)
- brian
- Joomla! Master
- Posts: 12785
- Joined: Fri Aug 12, 2005 7:19 am
- Location: Leeds, UK
- Contact:
Re: How do I create a Joomla 4 template overide that converts H2 to H1 ?
No you dont need to create an override. As I wrote if you display a page title then that is h1 and the article title is h2. If you do not display a page title then the article title is h2.
Just look at the sample date eg https://cassiopeia.joomla.com/
This page has no page title so the article title is h1 https://cassiopeia.joomla.com/typography
This page has a page title so the article title is h2 https://cassiopeia.joomla.com/blog/about-your-home-page
The actual code for this is in https://github.com/joomla/joomla-cms/bl ... efault.php
Just look at the sample date eg https://cassiopeia.joomla.com/
This page has no page title so the article title is h1 https://cassiopeia.joomla.com/typography
This page has a page title so the article title is h2 https://cassiopeia.joomla.com/blog/about-your-home-page
The actual code for this is in https://github.com/joomla/joomla-cms/bl ... efault.php
"Exploited yesterday... Hacked tomorrow"
Blog http://brian.teeman.net/
Joomla Hidden Secrets http://hiddenjoomlasecrets.com/
Blog http://brian.teeman.net/
Joomla Hidden Secrets http://hiddenjoomlasecrets.com/
- woodyf4u
- Joomla! Intern
- Posts: 72
- Joined: Tue Aug 12, 2008 7:04 pm
- Contact:
Re: How do I create a Joomla 4 template overide that converts H2 to H1 ?
I don't use page titles.
So the article title should be an H1.
Solved by creating an override in the backend of com_content/article
Editing a file was not necessary.
The H2 heads are now neatly displayed as H1 heads.
So the article title should be an H1.
Solved by creating an override in the backend of com_content/article
Editing a file was not necessary.
The H2 heads are now neatly displayed as H1 heads.
Best regards / vriendelijke groeten,
Wouter (WoodyF4u)
Wouter (WoodyF4u)
- brian
- Joomla! Master
- Posts: 12785
- Joined: Fri Aug 12, 2005 7:19 am
- Location: Leeds, UK
- Contact:
Re: How do I create a Joomla 4 template overide that converts H2 to H1 ?
there is no need for the override!!
"Exploited yesterday... Hacked tomorrow"
Blog http://brian.teeman.net/
Joomla Hidden Secrets http://hiddenjoomlasecrets.com/
Blog http://brian.teeman.net/
Joomla Hidden Secrets http://hiddenjoomlasecrets.com/
- Per Yngve Berg
- Joomla! Master
- Posts: 30890
- Joined: Mon Oct 27, 2008 9:27 pm
- Location: Romerike, Norway
Re: How do I create a Joomla 4 template overide that converts H2 to H1 ?
This does not make any sense unless you have overwritten an override already existing in your template with the core file.