Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Customize generated page title #63

Open
ajb opened this issue May 12, 2016 · 11 comments
Open

Customize generated page title #63

ajb opened this issue May 12, 2016 · 11 comments

Comments

@ajb
Copy link

ajb commented May 12, 2016

❤️ 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:

img

Is there a workaround? Am I missing something?

@ghost
Copy link

ghost commented May 20, 2016

Would you like to change the title on all archive pages, or just for specific categories/tags?

@ajb
Copy link
Author

ajb commented May 20, 2016

I'm not really sure yet. Are there implications to each?

On Thu, May 19, 2016 at 10:12 PM, Nick notifications@github.com 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
#63 (comment)

Adam Becker
(951) 9-BECKER
@AdamJacobBecker

@ghost
Copy link

ghost commented May 20, 2016

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?

@ghost
Copy link

ghost commented May 20, 2016

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 3e3d819, 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. 😎

@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 }}

@ulrichsg
Copy link

Any news on this issue? I would also like to see it fixed.

@aarongustafson
Copy link

This is awesome! Any chance we could get a suffix too?

@swsnr
Copy link

swsnr commented Nov 1, 2017

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.

@mckeever02
Copy link

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?

@pathawks
Copy link
Member

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 }}"

@quicoto
Copy link

quicoto commented Jul 20, 2018

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>

@TerminalAddict
Copy link

did this ever get looked into?
I've suddenly discovered I can't use seo in the generated archives pages

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants