Skip to content

Commit 0cb57d5

Browse files
committed
Allow search engines to crawl /offline &co
1 parent 6f75f3c commit 0cb57d5

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

assets/javascripts/lib/page.coffee

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ page.show = (path, state) ->
4141
currentState = context.state
4242
page.dispatch(context)
4343
context.pushState()
44+
updateCanonicalLink()
4445
track()
4546
context
4647

@@ -50,6 +51,7 @@ page.replace = (path, state, skipDispatch, init) ->
5051
currentState = context.state
5152
page.dispatch(context) unless skipDispatch
5253
context.replaceState()
54+
updateCanonicalLink()
5355
track() unless init or skipDispatch
5456
context
5557

@@ -177,6 +179,10 @@ onclick = (event) ->
177179
isSameOrigin = (url) ->
178180
url.indexOf("#{location.protocol}//#{location.hostname}") is 0
179181

182+
updateCanonicalLink = ->
183+
@canonicalLink ||= document.head.querySelector('link[rel="canonical"]')
184+
@canonicalLink.setAttribute('href', "http://#{location.host}#{location.pathname}")
185+
180186
track = ->
181187
ga?('send', 'pageview', location.pathname + location.search + location.hash)
182188
_gauges?.push(['track'])

public/robots.txt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,2 @@
11
User-agent: *
2-
Disallow: /about
3-
Disallow: /news
4-
Disallow: /tips
5-
Disallow: /help
6-
Disallow: /offline
2+
Allow: /

0 commit comments

Comments
 (0)