ONSdigital/sdg-indicators

Goal tabs should reflect the Goal title

Closed this issue · 18 comments

The ‘3 Good Health and Well-being’ page shares the same page title as the home page and does not uniquely reflect the contents of page. Page titles that do not uniquely describe or introduce the page content means that some users may not be able to identify the purpose or topic of the page content. “When I activated the third goal ‘good health and wellbeing’ link, I was confused by the fact that the URL changed, even though the page title did not.
<title>U.K. Indicators For The Sustainable Development Goals</title>

Description

The site Goal pages have a tab which reads 'U.K. Indicators...', whereas it should read 'Goal 3 - Education' (for example). All indicator tabs already have the format Indicator – Goal – description so it’s just a case of removing indicator - from the head.html.

Testing page: https://sdg.mango-solutions.com/a11y-goal-tab/

Screenshots

Before
image

After
image

Successfully tested on...

  • Windows: IE11
  • Windows: Chrome
  • Windows: Firefox
  • Windows: Edge
  • macOS: Chrome
  • macOS: Firefox
  • iOS: Safari 9.3
  • iOS: Chrome
  • Samsung: Chrome
  • Samsung: Samsung Internet

User feedback and problems encountered...

Chrome on Mac

The tab successfully shows Goal 1 - No poverty when a goal is selected:

image

However: it seems to break when an indicator is selected:

image

And it seems that it affects the colouring of the indicator page and also the heading image disappears (not sure if this is related):

image

@SavvasStephanides Yes I noticed this too. Think it occurs on all browsers. Trying to fix it now.

Indicator pages already have a specific tab - just remove the 'Indicator .._' preface and leave the Goal details when browsing the Goal pages.

@brockfanning Succeeded in changing the Goal icon with your help - no details though. Any thoughts?
Test branch: https://sdg.mango-solutions.com/a11y-goal-tab/3/
bee4525
Many thanks,
Chris

image

I believe that means that {{ goal_number }} and {{ goal.short }} variables do not exist on goal pages. It looks like they only get set for indicator pages, in this file. I guess that file does not get included on goal pages.

Unable to use open-sdg remote_theme branches, so overriding _layouts/goal.html locally for now.

  • 5c4b440 (added line 2 - {%- include indicator-variables.html -%})

This has resulted in the Goal tab reading "Goal 2 - ".
An improvement, but I'll see if I can get the short description too.

This is working as hoped! Ready to be tested @LucyGwilliamAdmin @SavvasStephanides

This update also caused the indicator tab and Goal icon to break. Attempted fix: 60dada9

This added the description but the icon is still broken and the tab number is missing. Reverting to the original tags as in #3195 fixes the indicator page but breaks the goal page. How to get both working?

@brockfanning What is the flag that indicates that a goal page is currently open? We have page.indicator to check when an indicator page is open, but not sure about a goal page. Thanks!

page.indicator tells us that the page has that variable. You can look at the _indicators directory. You see that it has (e.g.)

---
indicator: 1.2.1
layout: indicator
permalink: /1-2-1/
---

I wonder if a better way would be to switch (or case-when) on the page.layout variable because this always exists and is more clear in the code (IMO). So something like:

<title>
{% case page.layout %}
  {% when 'indicator' %}
    {{ page_title | escape }}
  {% when 'goal' %}
    Goal {{ page.sdg_goal }} - {{ page.short }}
  {% else %}
    {{ site.title | escape }}
{% endcase %}
</title>

Or we could make title a function somehow. Might need to capture variables, I'm not sure. We could also code this logic somewhere else so that the page_title variable always works.

To directly answer the question as to what's the equivalent to page.indicator for a goal. I'd say page.sdg_goal. If that exists it's a goal page because that's not stored in the indicator page header. Goal headers currently look like this:

---
title: Ensure inclusive and equitable quality education and promote lifelong learning
  opportunities for all
short: Quality Education
permalink: /4/
redirect_from: /quality-education/
sdg_goal: '4'
color: '#c5192d'
layout: goal
---

@dougmet So could we have...?
if page.sdg_goal = f4859c6 + 29b4426
elsif page.indicator = https://github.com/ONSdigital/sdg-indicators/pull/3195/files

Thanks @dougmet, I think that answers my question. The way to do this (I think) is:

if page.indicator exists
    title = "Indicator <indicator number> - Goal <goal number>
else if page.sdg_goal exists
    title = "Goal <goal number> - <Goal description>"
else
    title = "<Site name>"

EDIT: yes I think this should have been better coded to reflect that if page.indicator means that the current page is an indicator page etc. Not sure if we can do this with capture.

This is fixed in Open SDG v0.8.0 so closing this.