For better SEO, the site name should be an h1 tag on the frontpage.
Would be nice as an option that's turned on by default.

Comments

stephthegeek’s picture

Project: Acquia Prosper » Fusion
Version: 6.x-1.0-beta4 »

We'll look at doing this in Fusion itself in D7 -- too late for the current version.

stephthegeek’s picture

Version: » 7.x-1.x-dev
Assigned: Unassigned » stephthegeek
Status: Active » Needs review
Issue tags: +SEO, +Accessibility, +markup
StatusFileSize
new2.87 KB

Lack of an h1 on pages is also an accessibility problem. Patch attached for h1 on pages without titles, with some slightly updated CSS to standardize across div vs h1.

stephthegeek’s picture

Assigned: stephthegeek » Unassigned
Status: Needs review » Fixed

In the dev release

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

asb’s picture

Priority: Minor » Normal
Status: Closed (fixed) » Active

Is there any chance to get this "backported" to the 6.x release, or should we hack the Fusion core templates ourselves? As far as I can see, lots of us a re stuck with D6 for a long time...

Various validators complain about the lack of h1 tags in Fusion subthemes as well, including SEO, accessibility, and semantic/structural aspects, and this is not limited to the frontpage, but affects constructs like this as well, I believe (example from ./sites/all/themes/fusion/fusion_core/node.tpl.php:

    <?php if ($page == 0): ?>
    <h2 class="title"><a href="<?php print $node_url ?>" title="<?php print $title ?>"><?php print $title ?></a></h2>
    <?php endif; ?>

(I'm currently trying to figure out how "valid" templates are supposed to be built and I'm not claiming to be an expert on correct structural markup; however, an analysis of Fusion-based sites with tools as provided by seitwert.de and the like indicate structural problems I'm trying to understand and to correct).

asb’s picture

To overcome the mentioned deficiencies, I made the following modifications to my templates:

page.tpl.php:

...
         <div id="content-inner" class="content-inner block">
           <div id="content-inner-inner" class="content-inner-inner inner">
             <?php if ((!$node) && $title): ?>
               <h1 class="title"><?php print $title; ?></h1>
             <?php endif; ?>
             <?php if ($content): ?>
             <div id="content-content" class="content-content">
               <?php print $content; ?>
...

node.tpl.php:

...
  <div class="inner">
    <?php print $picture ?>
  
    <?php if ($page == 0): ?>
      <h1 class="title"><a href="<?php print $node_url ?>" title=<?php print $title ?>"><?php print $title ?></a></h2>
      <h2 class="subheadline"><?php print content_format('field_subheadline', $field_subheadline[0]); ?></h2>
    <?php else: ?>
      <h1 class="title"><?php print $title ?></h2>
      <h2 class="subheadline"><?php print content_format('field_subheadline', $field_subheadline[0]); ?></h2>
    <?php endif; ?>

    <?php if ($unpublished): ?>
      <div class="unpublished"><?php print t('Unpublished'); ?></div>
    <?php endif; ?>
...

This gives me proper a) uniqe per page
headlines for nodes, views, and other page types, and b) a semi-semantic subheadline (with an CCK text field). I believe this preserves the hierarchical structure of the rendered page, and gets rid of validation errors because of missing
tags.

Please advise if this is proper procedure or breaks something else important in Fusion subthemes.

Thanks!

aquariumtap’s picture

Version: 7.x-1.x-dev » 6.x-1.x-dev
StatusFileSize
new16.09 KB

Hi asb, thanks for the feedback.

The attached patch for Fusion 6.x-1.x makes two changes:

  • The node.tpl.php template will use H1 instead of H2 for the title
  • If there's no $title, page.tpl.php will use the site title for its H1 tag.
  • That latter change makes me hesitant to include this patch into a D6 release. The issue is that any sites relying on Fusion's page.tpl.php will see the size of their site title change as a result of the new H1 tag. Thoughts on that (@stephthegeek, @sheena_d)?

aquariumtap’s picture

Status: Active » Needs review
asb’s picture

@aquariumtap: Thanks, the patch looks good to me.

However I'm still quite interested to understand why the original node temple is using <h2>.

aquariumtap’s picture

@asb, I'm not quite sure. I wasn't the original creator of the template, but I think we all agree that the change to <h1> is the best path.

sheena_d’s picture

The title on the original node.tpl.php should only print out when the node is being displayed in teaser form. When on the node's page, the node's title becomes the page title and is not printed out via the node.tpl.php. Thus, the node title on node.tpl.php being wrapped in an </h2>. I think with this change you will have an issue of multiple </h1> tags on a single page.

I haven't tested the patch, though, it would not apply for me. Was this patch rolled before or after the other changes were committed to dev today?

asb’s picture

@sheena_d: Yes, with my modifications from #6 I'm getting multiple h1 headlines under certain circumstances (nor for nodes, but in some Panels pages). Probably it's the same with the patch from #7.

I'm not sure it it is worse to have no h1 tags at all, or multiple h1 tags. At least logically a document might have multiple top-headlines (e.g. sections), but it can not have no top-headline.

sheena_d’s picture

@asb - best practice is that a page should always have exactly one h1 tag. Having zero or multiple h1's is believed to be detrimental to SEO efforts.

The issue here isn't in using h1 as the site name on the homepage, just that the node's title should be left to the page template rather than the node template on the node's pag. This is the expected way for things to be handled in Drupal and it makes sense that Panels would be outputting multiple titles on node page panels.

aaaand, I just realized the patch wasn't working for me because I was trying to apply it to the D7 branch. lulz.

brb with new patch.

sheena_d’s picture

StatusFileSize
new1.83 KB

Ok, I confirmed that the patch in #7 will cause multiple h1 tags on pages that list multiple node teasers.

To solve the problem of needing an h1 on every page (i.e. making the site name the h1 if there is not page title) there is no need to edit the node template. Not only was the previous edit causing multiple h1s, but this change to the node template could potentially have negative effects on already existing sub themes.

Attached is a patch that *only* uses an h1 tag for the site name if there is no page title, and makes no other changes to title handling.

@aquariumtap - I'm torn on whether this should be committed in 6.x-1.x or just left as a patch for those who want to use it. I think most of our custom sub-themes override the page template anyway (thus won't be affected by a change to Core's page template), but it could potentially cause problems for other custom Fusion sub-themes (but still, only a minor problem).

asb’s picture

Thanks for the new patch. There seem to be very recent changes in the page template from 6.x-1.12 to 6.x-dev anyway; appying the patch against 6.x-1.12 fails, also I can not apply the patch against 6.x-dev from 2011-Sep-01 (the most recent release I can get through Drush), neither without nor with -p0 parameter.

mgifford’s picture

Version: 6.x-1.x-dev » 7.x-2.x-dev
Issue summary: View changes

Was this done in the D7 version? If so I think we could close this.

Poieo’s picture

Status: Needs review » Closed (fixed)

This was committed to D7 long ago and no development is being done on D6.