Skip to content

Commit 4bd1993

Browse files
committed
Use h1 for guide titles
Currently the guides use the h1 tag for the guides logo instead of the guides title. As the guides title is more important in describing the content of a guide, the title should use the h1 instead. This also move every other heading to a more important heading (h3 becomes h2, etc.). This change should improve SEO for the guides.
1 parent f7a4022 commit 4bd1993

File tree

5 files changed

+19
-32
lines changed

5 files changed

+19
-32
lines changed

guides/assets/stylesheets/main.css

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -530,53 +530,46 @@ a, a:link, a:visited {
530530
--------------------------------------- */
531531

532532
h1 {
533-
font-size: 2.5em;
534-
line-height: 1;
535-
margin: 0.6em 0 .2em;
536-
font-weight: bold;
537-
}
538-
539-
h2 {
540533
font-size: 2.1428em;
541534
line-height: 1;
542535
margin: 0.7em 0 .2333em;
543536
font-weight: bold;
544537
}
545538

546539
@media screen and (max-width: 480px) {
547-
h2 {
540+
h1 {
548541
font-size: 1.45em;
549542
}
550543
}
551544

552-
h3 {
545+
h2 {
553546
font-size: 1.7142em;
554547
line-height: 1.286;
555548
margin: 0.875em 0 0.2916em;
556549
font-weight: bold;
557550
}
558551

559552
@media screen and (max-width: 480px) {
560-
h3 {
553+
h2 {
561554
font-size: 1.45em;
562555
}
563556
}
564557

565-
h4 {
558+
h3 {
566559
font-size: 1.2857em;
567560
line-height: 1.2;
568561
margin: 1.6667em 0 .3887em;
569562
font-weight: bold;
570563
}
571564

572-
h5 {
565+
h4 {
573566
font-size: 1em;
574567
line-height: 1.5;
575568
margin: 1em 0 .5em;
576569
font-weight: bold;
577570
}
578571

579-
h6 {
572+
h5 {
580573
font-size: 1em;
581574
line-height: 1.5;
582575
margin: 1em 0 .5em;
@@ -600,15 +593,15 @@ h6 {
600593
:where(body[dir="rtl"]) #topNav strong { margin-left: 0.5em; }
601594
#topNav strong a {color: #FFF;}
602595

603-
#header h1 {
596+
#header .header-logo {
604597
background: url(../images/rails_guides_logo_1x.png) no-repeat;
605598
width: 297px;
606599
text-indent: -9999em;
607600
margin: 0;
608601
padding: 0;
609602
}
610-
:where(body[dir="ltr"]) #header h1 { float: left; }
611-
:where(body[dir="rtl"]) #header h1 { float: right; }
603+
:where(body[dir="ltr"]) #header .header-logo { float: left; }
604+
:where(body[dir="rtl"]) #header .header-logo { float: right; }
612605

613606
@media
614607
only screen and (-webkit-min-device-pixel-ratio: 2),
@@ -617,19 +610,19 @@ only screen and ( -o-min-device-pixel-ratio: 2/1),
617610
only screen and ( min-device-pixel-ratio: 2),
618611
only screen and ( min-resolution: 192dpi),
619612
only screen and ( min-resolution: 2dppx) {
620-
#header h1 {
613+
#header .header-logo {
621614
background: url(../images/rails_guides_logo_2x.png) no-repeat;
622615
background-size: 160%;
623616
}
624617
}
625618

626619
@media screen and (max-width: 480px) {
627-
#header h1 {
620+
#header .header-logo {
628621
float: none;
629622
}
630623
}
631624

632-
#header h1 a {
625+
#header .header-logo a {
633626
text-decoration: none;
634627
display: block;
635628
height: 77px;

guides/rails_guides/markdown.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,17 +98,17 @@ def generate_structure
9898
hierarchy = []
9999

100100
doc.children.each do |node|
101-
if /^h[3-6]$/.match?(node.name)
101+
if /^h[2-5]$/.match?(node.name)
102102
case node.name
103-
when "h3"
103+
when "h2"
104104
hierarchy = [node]
105105
@headings_for_index << [1, node, node.inner_html]
106-
when "h4"
106+
when "h3"
107107
hierarchy = hierarchy[0, 1] + [node]
108108
@headings_for_index << [2, node, node.inner_html]
109-
when "h5"
109+
when "h4"
110110
hierarchy = hierarchy[0, 2] + [node]
111-
when "h6"
111+
when "h5"
112112
hierarchy = hierarchy[0, 3] + [node]
113113
end
114114

@@ -117,7 +117,7 @@ def generate_structure
117117
end
118118
end
119119

120-
doc.css("h3, h4, h5, h6").each do |node|
120+
doc.css("h2, h3, h4, h5").each do |node|
121121
node.inner_html = "<a class='anchorlink' href='##{node[:id]}'>#{node.inner_html}</a>"
122122
end
123123
end

guides/rails_guides/markdown/epub_renderer.rb

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,6 @@ def link(url, title, content)
2525
end
2626

2727
def header(text, header_level)
28-
# Always increase the heading level by 1, so we can use h1, h2 heading in the document
29-
header_level += 1
30-
3128
header_with_id = text.scan(/(.*){#(.*)}/)
3229
unless header_with_id.empty?
3330
%(<h#{header_level} id="#{header_with_id[0][1].strip}">#{header_with_id[0][0].strip}</h#{header_level}>)

guides/rails_guides/markdown/renderer.rb

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,6 @@ def link(url, title, content)
3333
end
3434

3535
def header(text, header_level)
36-
# Always increase the heading level by 1, so we can use h1, h2 heading in the document
37-
header_level += 1
38-
3936
header_with_id = text.scan(/(.*){#(.*)}/)
4037
unless header_with_id.empty?
4138
%(<h#{header_level} id="#{header_with_id[0][1].strip}">#{header_with_id[0][0].strip}</h#{header_level}>)

guides/source/layout.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
</div>
4343
<div id="header">
4444
<div class="wrapper clearfix">
45-
<h1><a href="index.html" title="Return to home page">Guides.rubyonrails.org</a></h1>
45+
<div class="header-logo"><a href="index.html" title="Return to home page">Guides.rubyonrails.org</a></div>
4646
<ul class="nav">
4747
<li><a class="nav-item" href="index.html">Home</a></li>
4848
<li class="guides-index guides-index-large">

0 commit comments

Comments
 (0)