diff options
author | Achilleas Pipinellis <axil@gitlab.com> | 2018-03-19 10:59:26 +0300 |
---|---|---|
committer | Achilleas Pipinellis <axil@gitlab.com> | 2018-03-19 10:59:26 +0300 |
commit | c45d65f0210bc74b8691cd942c69b84a5fba8ef7 (patch) | |
tree | afcaf0f87f12ba0a0393a4705af798ff63e666df /layouts | |
parent | 0f51fa38dc25c8615bdae6128ce843caa701e3ec (diff) | |
parent | eb1182215466e8b19c23f424c2c65224576f1665 (diff) |
Merge branch 'canonical-urls' into 'master'
Use canonical URLs
Closes #171
See merge request gitlab-com/gitlab-docs!211
Diffstat (limited to 'layouts')
-rw-r--r-- | layouts/head.html | 33 |
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 %>"> |