I need to hide the page title in Views but still have it appear as the page title on the browser's window tab (for SEO). Could someone help me with that? I've looked around many times for answers but I haven't had any luck yet.
4 Answers
This sounds like something that should be pretty easy to do with a CSS selector. The user won't see the title but all functionality outside of seeing it on the page will still work.
More specifically, you could add a rule to your css file like:
#page-title {
display:none;
}
-
but that's going to affect ALL views... what if I just want a specific views not to show the title?– sly-gdkCommented May 20, 2014 at 17:16
-
Each page has a class associated with it attached to the body tag, think the css class is based on the url. So for a page with url mysite.com/mypage you could make your CSS selector more specific like:
body.page-mypage #page-title { display:none };
Commented May 20, 2014 at 17:17
The CSS solution might not be the best for SEO purposes...
Another better alternative is to write in the page title field :
<No Title>
or : to leave it blank
And the title wont be displayed
-
This will disable the title tag as well, so I can't tell what's worst. Commented Jan 4, 2016 at 8:27
-
2This is the best and easiest solution by far...I'm perplexed as to why others are even trying other solutions... Commented Mar 14, 2016 at 8:03
function module_block_view_alter(&$data, $block){
if($block->delta == 'your view name or id'){
$data['title'] = 'my new title';
}
}
unset the title in page preprocess hook
-
1My experience has been that unsetting the title with the preprocess hook unsets all instances of the title and thus the page behaves as if there's no title at all so meta data is affected.– RobCommented May 20, 2014 at 17:11