Remove page header from front page?

What’s the best way to remove the page title from the front page?

I can do it in page-header.php like this:

<?php if(!is_front_page() ) { ?>
<div class="page-header">
    <?php echo roots_title(); ?>
<?php } ?>

But I’d rather do it with templates somehow. I still don’t understand how Roots templates work but can I create an alternative page-header.php for the home page? Like page-header-home.php or something?


You could copy page.php to front-page.php and remove get_template_part('templates/page', 'header'); - but if you’re not doing any further customizations within that template then I think the conditional statement is better.

I use conditional statements all the time in template files to avoid having to create new templates.


Thanks for the fast reply. I’ll just stick with the conditional if that’s what you suggest. I had it in my head that it was bad practice for some reason.

I am not if this is a recommended way or not, but I change the condition in the lib/titles.php (Sage 8.5.3)

if (is_home() || is_front_page()) {
    return; // Remove homepage title 

This would remove the text of the title, but not the HTML surrounding it. I wouldn’t do it this way.

1 Like