jekyll-archives
jekyll-archives copied to clipboard
Customize generated page title
❤️ to all the contributors for this great plugin.
It seems like this gem is heavily reliant on its ability to set the page title, which prevents us from achieving our preferred page titles:
Is there a workaround? Am I missing something?
Would you like to change the title on all archive pages, or just for specific categories/tags?
I'm not really sure yet. Are there implications to each?
On Thu, May 19, 2016 at 10:12 PM, Nick [email protected] wrote:
Would you like to change the title on all archive pages, or just for specific categories/tags?
— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub https://github.com/jekyll/jekyll-archives/issues/63#issuecomment-220518843
Adam Becker (951) 9-BECKER @AdamJacobBecker
Maybe, although I'm not sure what the implications would be yet.
I'm working on a branch trying to add some support for this, as I have a similar need. jekyll-archives builds the URL for the archive page from title so if you set a custom title for a specific cat/tag it changes the URL. Either we need to build the URL from something other than title or we need to set an alt_title or page_title and provide this data via a tags.yml file in _data. This is approach I'm working on right now. Any thoughts?
I pushed a version where I'm testing customizable tag and category titles. (and descriptions) See fc8af85e/lib/jekyll-archives.rb and fc8af85e/lib/jekyll-archives/archive.rb
You can now set custom title prefixes in _config.yml using:
title_prefix:
tag_title_prefix:
category_title_prefix:
These strings will be added in front of the generated page title. If no tag or cat specific prefix, the plugin falls back to title_prefix, and if no prefix, just the tag/cat title is used.
You can set a custom title per tag/cat using _data files, specifically tags.yml and categories.yml consisting of the following format:
- title: tag title exactly as it appears on on archive page using stock jekyll-archive
custom_title: Modified tag Title, perhaps adding more words, or changing the case
This is handy in tandem with my other commit testing case-insensitive tags/cats https://github.com/jekyll/jekyll-archives/commit/3e3d8193704d974978882c46f6412a718a4d96bd, where I have to downcase all the tags/cats in order to merge them properly. So you could tweak the casing or spelling of specific tags/cats site-wide using data files, while allowing post authors to ignore casing completely within their posts. Authors should be writing, not worrying about correct casing of tags/cats.
Feedback and critiques are greatly appreciated. I feel like the code could be simplified a good bit. :sunglasses:
@ajb using my commit, you'd set the following in _config.yml to achieve the result in your screenshot:
tag_title_prefix: 'Posts tagged with'
And in your tag archive layout, remove everything from <h1></h1> except {{ page.title | smartify }}
Any news on this issue? I would also like to see it fixed.
This is awesome! Any chance we could get a suffix too?
I'd also appreciate the ability to customize the title attribute of the generated pages. Currently it's hard to use this plugin together with jekyll_seo_tag.
Agreed. How would I go about setting a meta description for the archive pages if I'm using this in line with jekyll-seo-tag?
Would it be too complicated if we allowed a Liquid template to be set as a title in _config.yml? I just don't like the idea of prefix
archives:
title: "Posts tagged with {{ page.title }}"
No news on this?
I "fixed" it by adding
<title>{% if page.title %}{% if page.type == "category" %}Category: {% endif %}{{ page.title }} - {{ site.siteName }}{% else %}{{ site.homeMetaTitle }}{% endif %}</title>
did this ever get looked into? I've suddenly discovered I can't use seo in the generated archives pages