Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions README.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,13 @@ You can attach extra data to generated tag pages by specifying <tt>tag_page_data
tag_page_data:
sitemap: false

==== Page title including the tag name

Specifically for the generated pages, there is an option to include the tag name into the title via `%{tag}`, for example:

tag_page_data:
title: "Posts tagged #%{tag}" # will generate title 'Posts tagged #news'

=== Example tag page layout

(Save this to <tt>_layouts/tag_page.html</tt> if using the <tt>_config.yml</tt> snippet above.)
Expand Down
6 changes: 6 additions & 0 deletions lib/jekyll/tagging.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ def new_tag(tag, posts)
if layout = site.config["tag_#{type}_layout"]
data = { 'layout' => layout, 'posts' => posts.sort.reverse!, 'tag' => tag }
data.merge!(site.config["tag_#{type}_data"] || {})
# interpolate optional tag in the title
if (data['title'])
data['title'] = data['title'] % { 'tag': data['tag'] }
else
data['title'] = "Posts tagged #%{tag}" % { 'tag': data['tag'] }
end

name = yield data if block_given?
name ||= tag
Expand Down