Archived topic
GeneratePress Theme – Broadcast - Home Page H1 Tag
11 replies · Started by HT on May 26, 2021
Hell0 - I could see two H1 Tags on the home page. One is for mobile and another one is for the rest of the devices fleet. Do you know how to avoid this?
<header id="masthead" class="site-header" itemtype="https://schema.org/WPHeader" itemscope>
<nav id="mobile-header" class="main-navigation mobile-header-navigation has-branding" itemtype="https://schema.org/SiteNavigationElement" itemscope>
This is similar to the issue discussed in the navigation menu in the thread https://generatepress.com/forums/topic/mobile-menu-vs-primary-menu-for-desktop-version-of-the-page/
Hi there,
when the home page is set to display latest posts - it switches the site title to a H1 tag ( as there is no H1 in the content ). With the Mobile Header enabled you have 2 x H1's in the markup - but only one of them is ever displayed.
You can disable the Mobile Header to remove the second H1.
Or you can just ignore it - as there is no issue it being there as only one is ever displayed.
Thank you
Ok, so this is similar to the thread ...
Anything we can do to avoid this kind of issue from an SEO perspective in the upcoming updates of the theme?
There isn't an issue from an SEO perspective. Its quite common in responsive design that duplicate elements exist in the markup. It would only be an issue if both of them were being displayed in the browser as it may confuse your users. Might be worth watching this:
https://www.youtube.com/watch?v=zyqJJXWk0gk
However, there are options.
1. Don't use the Mobile Header.
2. Use a Logo instead of Site Title, which you can add just for mobile if required ( so Site Title desktop / logo on mobile ).
3. We can filter out the H1 from the home page site title so its just a <p> tag and you can hook in a H1 Title into your content....
Probably a few other options as well. Let us know if you want to explore any of the above.
Hey - I have already seen John's video about H1 tags.
#3 sounds promising. Can you elaborate a bit more or help me to implement this?
Does this <P> work for MENU issue as well?
Try this PHP Snippet:
add_filter( 'generate_site_title_output', function( $output ) {
return sprintf(
'<p class="main-title" itemprop="headline">
<a href="%1$s" rel="home">
%2$s
</a>
</p>',
esc_url( apply_filters( 'generate_site_title_href', home_url( '/' ) ) ),
get_bloginfo( 'name' )
);
});
The menu issue from the other topic ? - only reliable option there is to disable the mobile header. Other methods could lead to a server caching the page markup and then the wrong navigation ( or navigation element ) being served up.
The PHP snippet removed both the H1 tags from the code it seems.
Now there is no H1 in the home page code
Now you create a Block Element with your our own H1 title for your frontpage
https://docs.generatepress.com/article/block-element-overview/
OK. Do you think there will be any performance impact because of these changes?
No there shouldn't be any performance issue :)
Use a Logo instead of Site Title, which you can add just for mobile if required ( so Site Title desktop/logo on mobile ).
Can I use the logo only for the homepage and Text for the rest of the pages on the website?
Unfortunately, there's no such setting in GP.
You might need some custom solution to achieve this.