Skip to content

Commit

Permalink
improved : [SEO] allow site title to be wrapped in a H1 tag when home…
Browse files Browse the repository at this point in the history
… is a static page
  • Loading branch information
nikeo committed Jan 18, 2021
1 parent c370f5f commit a25b677
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 3 additions & 1 deletion functions/init-front.php
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,9 @@ function hu_get_logo_title( $is_mobile_menu = false ) {
function hu_print_logo_or_title( $echo = true, $is_mobile_menu = false ) {
// June 2020 => never write the mobile site-title in a h1 heading to avoid multiple h1 detected by SEO analyzers
// @see https://github.com/presscustomizr/hueman/issues/906
$wrap_in_h_one = is_home() && !$is_mobile_menu && hu_booleanize_checkbox_val( hu_get_option('wrap_in_h_one') );
// option "wrap_in_h_one" should applyg when home is a static page or the blog page
// When home is a static page, the blog page heading should be set to H1 ( see parts\page-title.php )
$wrap_in_h_one = hu_is_real_home() && !$is_mobile_menu && hu_booleanize_checkbox_val( hu_get_option('wrap_in_h_one') );
$logo_or_title = hu_get_logo_title( $is_mobile_menu );
// => If no logo is set and !hu_is_checked( 'display-header-title' ), the logo title is empty.
ob_start();
Expand Down
6 changes: 5 additions & 1 deletion parts/page-title.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@
<div class="page-title hu-pad group">
<?php //prints the relevant metas (cat, tag, author, date, ...) for a given context : home, single post, page, 404, search, archive... ?>
<?php if ( is_home() && hu_is_checked('blog-heading-enabled') ) : ?>
<h2><?php echo hu_blog_title(); ?></h2>
<?php if ( ( hu_is_real_home() && hu_booleanize_checkbox_val( hu_get_option('wrap_in_h_one') ) ) || !hu_is_real_home() ) : ?>
<h2><?php echo hu_blog_title(); ?></h2>
<?php elseif ( hu_is_real_home() && !hu_booleanize_checkbox_val( hu_get_option('wrap_in_h_one') ) ) : ?>
<h1><?php echo hu_blog_title(); ?></h1>
<?php endif; ?>
<?php // For a regular post, we display the category and comments ?>
<?php elseif ( is_single() && 'post' === $post_type ): ?>
<ul class="meta-single group">
Expand Down

0 comments on commit a25b677

Please sign in to comment.