Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-docs.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAchilleas Pipinellis <axil@gitlab.com>2018-03-15 16:10:59 +0300
committerAchilleas Pipinellis <axil@gitlab.com>2018-03-19 10:54:16 +0300
commiteb1182215466e8b19c23f424c2c65224576f1665 (patch)
tree18c2ca6daa1f983701a51adccb34a11e10e2af6b /layouts
parentb6cab2a6895399229ee98b5772ff3632f9ab185b (diff)
Use canonical URLs
Fixes https://gitlab.com/gitlab-com/gitlab-docs/issues/171
Diffstat (limited to 'layouts')
-rw-r--r--layouts/head.html33
1 files changed, 33 insertions, 0 deletions
diff --git a/layouts/head.html b/layouts/head.html
index 09c8b5c9..6211623a 100644
--- a/layouts/head.html
+++ b/layouts/head.html
@@ -5,6 +5,39 @@
<% else %>
<meta name="description" content="Documentation for GitLab Community Edition, GitLab Enterprise Edition, Omnibus GitLab, and GitLab Runner.">
<% end %>
+<% if false %>
+This is a comment!
+Implement canonical links https://gitlab.com/gitlab-com/gitlab-docs/issues/167
+We want to:
+- All index.html and README.html files stripped
+- Replace ce/ with ee/
+------------------
+if the link ends with README.md or index.md
+ if the link starts with ce
+ replace it with ee and strip README.md or index.md
+ if the link doesn't start with ce
+ strip README.md or index.md
+if the link doesn't end with README.md or index.md
+ if the link starts with ce
+ replace it with ee
+ if the link doesn't start with ce
+ use its initial path
+<% end %>
+<% if ENV['NANOC_ENV'] == 'production' %>
+ <% if (@item.identifier =~ /(index|README)\.md$/) == 0 %>
+ <% if @item.identifier.to_s.split('/')[1] == 'ce' %>
+ <link rel="canonical" href="<%= @config[:base_url] %>/ee/<%= @item.identifier.to_s.split('/')[2..-2].join('/') %><% unless @item.identifier.to_s.split('/')[2..-2].join('/').length == 0 %>/<% end %>" />
+ <% else %>
+ <link rel="canonical" href="<%= @config[:base_url] %><%= @item.identifier.to_s.split('/')[0..-2].join('/') %>/" />
+ <% end %>
+ <% else %>
+ <% if @item.identifier.to_s.split('/')[1] == 'ce' %>
+ <link rel="canonical" href="<%= @config[:base_url] %>/ee/<%= @item.identifier.without_ext.to_s.split('/')[2..-1].join('/') + '.html' %>" />
+ <% else %>
+ <link rel="canonical" href="<%= @config[:base_url] %><%= @item.identifier.without_ext + '.html' %>" />
+ <% end %>
+ <% end %>
+<% end %>
<link rel="stylesheet" href="<%= @items['/assets/stylesheets/bootstrap.min.*'].path %>">
<link rel="stylesheet" href="<%= @items['/assets/stylesheets/font-awesome.min.*'].path %>">
<link rel="stylesheet" href="<%= @items['/assets/stylesheets/stylesheet.*'].path %>">