Weitere ähnliche Inhalte Ähnlich wie SEO for Developers (20) Kürzlich hochgeladen (20) SEO for Developers1. re al
v
SEO For Developers
SELECT
*
WHERE
clue
>
0;
Date: February 29, 2012
Author: Chris Le (@djchrisle)
1
2. $
whoami
{
name:
“Chris
Le”,
twitter:
“@DjChrisLe”,
occupation:
[
“Internal
app
developer”,
“Project
management”,
“Technical
SEO
support”
]
}
4. re al
v
SEO For Developers
How SEO changed the way I develop
Date: February 29, 2012
Author: Chris Le (@djchrisle)
4
8. #
investments.html.erb
<a
href=”#watchlist”>
<div
id=”container”></div>
<script>
$(“#watchlist”).click
(function()
{
//
=>
sets
loadThis
to
“watchlist”
var
loadThis
=
$.param.fragment($.param.querystring);
$(“#container”).load(“/content?get=”
+
loadThis);
}
</script>
#
content_controller.rb
class
ContentController
<
ActionController::Base
respond_to
:html
def
index
@content
=
Content.find_by_name(params[:get]
respond_with(@content)
end
end
@djchrisle 8
10. Best Practices
• Modularize & reuse code
– DRY principals (Don’t Repeat Yourself)
• Abstract template and view from logic
– Independently change stuff - no problems
• Use async JS loading to reduce load
– Lower server costs
– Fast load time (aka: “site speed”)
@djchrisle 10
12. Q: What is SEO?
A: Help the RIGHT
customers find YOU.
12
24. #
header.html.erb
<title><%=
@company.name
%>
<%=
@page.title_tag
%></title>
#
schema.rb
create_table
“Page”
t.string
“title_tag”
...
end
#
page.rb
Class
Page
<
ActiveRecord::Base
belongs_to
:category
def
title_tag
title_tag.defined?
?
super()
:
self.category.name
end
end
@djchrisle 24
26. Title matches
keyword
+ is what user
is looking for
My Company | Experienced Ruby Programmers in Philadelphia
26
32. This page is about
“Non-breaking space?”
#
my_page.html.erb
<h1> </h1>
....
#
acme.css
h1
{
background-‐image:
‘/img/acme_logo.png’;
background-‐repeat:
no-‐repeat;
}
@djchrisle 32
33. Better use of H1
#
my_page.html.erb
<div
class=”logo”></div>
<h1>
Sensible
Investment
Strategies
</h1>
....
#
acme.css
.logo
{
background-‐image:
‘/img/acme_logo.png’;
background-‐repeat:
no-‐repeat;
}
@djchrisle 33
36. http://www.acme.com/investments#positions
http://www.acme.com/investments#watchlist
http://www.acme.com/investments#menu1
http://www.acme.com/investments#menu2
4 pages .. 1 listing :(
Acme Inc | Financial Portfolio Managers
www.acme.com/investments
@djchrisle 36
37. Uncrawlable URL
#
investments.html.erb
<a
href=”#watchlist”>
<div
id=”container”></div>
<script>
$(“#watchlist”).click
(function()
{
//
=>
sets
loadThis
to
“watchlist”
var
loadThis
=
$.param.fragment($.param.querystring);
$(“#container”).load(“/content?get=”
+
loadThis);
}
</script>
37
38. Crawlable URL
#
investments.html.erb
<a
href=”/investments/watchlist”>
<div
id=”container”></div>
<script>
$(“#watchlist”).click
(function()
{
$(“#container”).load($.param.querystring);
}
</script>
38
39. #
routes.rb
resources
:investments
match
“content/:section”
=>
“content#show”
#
content_controller.rb
class
ContentController
<
ActionController::Base
respond_to
:html
def
show
@content
=
Content.find_by_name(params[:section])
respond_with(@content)
end
end
@djchrisle 39
40. http://www.acme.com/investments/positions
http://www.acme.com/investments/watchlist
http://www.acme.com/investments/menu1
http://www.acme.com/investments/menu2
4 pages .. 4 listings :)
Acme Inc | Financial Portfolio Managers
www.acme.com/investments/positions
@djchrisle 40
44. Defaults as 302 response
#
content_controller.rb
class
ContentController
<
ActionController::Base
respond_to
:html
def
show
redirect_to
:post_path
#
@content
=
Content.find_by_id(params[:id])
#
respond_with(@content)
end
end
@djchrisle 44
45. 301 vs 302 redirect
• RFC 2616, Section 10.3.3
– 302 Found: The requested resource resides
temporarily under a different URI
• RFC 2616, Section 10.3.2
–301 Moved Permanently: The requested resource has
been assigned a new permanent URI and any future
references to this resource SHOULD use one of the
returned URIs
@djchrisle 45
55. re al
v
SEO For Developers
How SEO changed the way I develop
Date: February 29, 2012
Author: Chris Le (@djchrisle)
55