Skip to content

Commit

Permalink
Add canonical URLs to indexes
Browse files Browse the repository at this point in the history
  • Loading branch information
vtourraine committed Mar 16, 2020
1 parent 509cddb commit a3f1d92
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 3 deletions.
2 changes: 2 additions & 0 deletions lib/blog/blog.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ def generate_index_year(year, haml_options)
index = Index.new
index.title = year.to_s
index.articles = @articles.select { |a| a.date.year == year }
index.page_path = year.to_s

log_string = 'Generating index year: “' + year.to_s + '” (' + index.articles.count.to_s + ' articles)'
puts log_string.colorize(:light_blue)
Expand All @@ -60,6 +61,7 @@ def generate_index_tag(tag, haml_options)
log_string = 'Generating index tag: “' + tag + '” (' + index.articles.count.to_s + ' articles)'
puts log_string.colorize(:light_blue)
tag_slug = tag.downcase.gsub(' ', '-')
index.page_path = "tags/" + tag_slug
index.generate_index("templates/index-custom.html.haml", RENDERED_DIRECTORY+"tags/" + tag_slug + ".html", haml_options)
end

Expand Down
1 change: 1 addition & 0 deletions lib/blog/index.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ class Index
attr_accessor :articles
attr_accessor :title
attr_reader :blog_url
attr_accessor :page_path

def initialize
@articles = Array.new
Expand Down
1 change: 0 additions & 1 deletion templates/article.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
%link{:rel => "stylesheet", :type => "text/css", :href => "https://fonts.googleapis.com/css?family=Nunito:300,700"}

%link{:rel => "canonical", :href => "#{web_url}"}

%link{:rel => "alternate", :type => "application/atom+xml", :href => "/blog/feed.xml", :title => "Blog (Atom)"}
%link{:rel => "author", :href => "http://plus.google.com/117326560329576507699", :title => "Vincent Tourraine on Google+"}
%link{:rel => "stylesheet", :href => "/blog/highlight/styles/default.css"}
Expand Down
3 changes: 2 additions & 1 deletion templates/index-custom.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
%head
%meta{:charset => "utf-8"}
%title Vincent Tourraine - Blog #{title}

%link{:rel => "stylesheet", :type => "text/css", :href => "#{blog_url}styles/default.css?d4"}
/ %link{:rel => "stylesheet", :type => "text/css", :href => "styles/default.css"}
%link{:rel => "stylesheet", :type => "text/css", :href => "https://fonts.googleapis.com/css?family=Nunito:300,700"}

%link{:rel => "alternate", :type => "application/atom+xml", :href => "#{blog_url}feed.xml", :title => "Blog (Atom)"}
%link{:rel => "canonical", :href => "#{blog_url}#{page_path}"}

%meta{:name => "viewport", :content => "width=device-width, user-scalable=no"}

Expand Down
3 changes: 2 additions & 1 deletion templates/index.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
%head
%meta{:charset => "utf-8"}
%title Vincent Tourraine - Blog

%link{:rel => "stylesheet", :type => "text/css", :href => "#{blog_url}styles/default.css?d4"}
/ %link{:rel => "stylesheet", :type => "text/css", :href => "styles/default.css"}
%link{:rel => "stylesheet", :type => "text/css", :href => "https://fonts.googleapis.com/css?family=Nunito:300,700"}

%link{:rel => "alternate", :type => "application/atom+xml", :href => "#{blog_url}feed.xml", :title => "Blog (Atom)"}
%link{:rel => "canonical", :href => "#{blog_url}"}

%meta{:name => "viewport", :content => "width=device-width, user-scalable=no"}

Expand Down

0 comments on commit a3f1d92

Please sign in to comment.