HEPData / hepdata

Repository for main HEPData web application
https://hepdata.net
GNU General Public License v2.0
40 stars 11 forks source link

theme: use record-specific `<title>` for record pages #689

Closed GraemeWatt closed 1 year ago

GraemeWatt commented 1 year ago

Suggestion from @agbuckley:

I just noticed an awkward aspect of the HepData site when trying to chase back through my browser history in search of a record: the title of every page is just "HEPData", which makes it virtually impossible to know what a given history entry corresponds to.

Would it be possible to add some record-specific info to the title, e.g. "HEPData -- <experiment>, <year>, <paper title>, <journal ref>"? Doesn't really matter that it's long, if the most important stuff comes first. Thanks for considering: hopefully easy and definitely useful!

The current title "HEPData" seems to come from the THEME_SITENAME variable, which is set as the title by invenio-theme. There's some existing code in publication_record.html dating from 2015/2016 that tries to include the paper title in the <title> tag: https://github.com/HEPData/hepdata/blob/18881a42b8e4b62e5c6dc20790b3437d3c0c6806/hepdata/modules/records/templates/hepdata_records/publication_record.html#L28-L30

But this doesn't seem to be working. I think the corrected code would be something like:

 {% block head_title %} 
     <title>HEPData | {{ ctx.record.title }}</title>
 {% endblock %} 

There's also some commented-out code that sets the title: https://github.com/HEPData/hepdata/blob/18881a42b8e4b62e5c6dc20790b3437d3c0c6806/hepdata/modules/records/templates/hepdata_records/publication_record.html#L22-L24

I'm going to use the latter method to set page-specific <title> tags for records and other pages.

agbuckley commented 1 year ago

Thanks! Just copying in a comment that I made by private email:

It'd be nice if it was easy to include the collaborations (e.g. joined with a ", " or "+" string) if non-null, as I think that's the most distinctive piece of info. It also teds to be short, as is the year, hence my suggestion of putting them at the start so they'll be visible in a cut-off title display, regardless of the title length. But if getting the collab name(s) is awkward in the templating, then having the title and year is also great: I would just suggest putting them in the opposite order for the reason above. Thanks!