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

Update page title with dataset and include metadata title as description #845

Merged
merged 4 commits into from
Jan 22, 2020

Conversation

trvrb
Copy link
Member

@trvrb trvrb commented Jan 21, 2020

Currently, our pages look like this to Google:

ebola

This updates the page title to be auspice / ebola or Nextstrain / ebola. I like this format (it's what I use for https://bedford.io). Here, I mainly want to make it easy to tell which tab is which when there are multiple auspice tabs or Nextstrain tabs open.

The injection of the metadata title, ie "Real-time tracking" as should aid in Google giving less vague search results.

I first started with just setting document.title, but description was more difficult and Stackoverflow recommended React Helmet. This worked really smoothly.

I believe that the extension set up with Nextstrain and https://github.com/nextstrain/nextstrain.org/blob/master/auspice/client/config.json#L13 should still work, but I wasn't able to test this (I couldn't figure out how to get a global auspice CLI from my local auspice src code).

trvrb added 2 commits January 20, 2020 16:23
This changes page title from just "auspice" to "auspice / zika", "auspice / mumps / na", etc...

I think this is generally helpful to find the right tab when multiple tabs are open. It's also recommended for SEO (https://support.google.com/webmasters/answer/7451184?hl=en). Currently, Google gives minimal information when searching for "nextstrain zika" or the like.
Google uses the <meta name="description"/> element to populate search results. Currently pages like Zika give text that reads "This work is made possible by the open sharing of genetic data..." rather than the more intended "Real-time tracking...". This update to description should hopefully resolve. See https://support.google.com/webmasters/answer/7451184?hl=en  for more information.
@trvrb trvrb requested a review from jameshadfield January 21, 2020 00:41
@tsibley
Copy link
Member

tsibley commented Jan 21, 2020

+1 for this!

One small change worth considering is maybe swapping the order of the title pieces, that is, putting "auspice" or "Nextstrain" last instead of first. For example, instead of "auspice / zika" or "auspice / mumps / na" using something similar to "zika / auspice" or "na / mumps / auspice". The idea here is that putting the detail first is useful when you have multiple Auspice/Nextstrain tabs open and want to know which is which. The first part of the title is least likely to be truncated by a small tab width. The site favicon shown on the tab of many browsers also already indicates the site (auspice/Nextstrain).

Tested on nextstrain.org locally resulted in two changes:

(a) moving the component higher up the tree as we want this to run for the Splash page, as well as for datasets. This allows nextstrain.org/groups/blab to show a title of `nextstrain / groups / blab`.

(b) connected it to redux state, as we modify the URL in certain situations (e.g. /flu/avian -> /flu/avian/h5n1/ha) and we want the head to change accordingly here. Note that this URL changes without the `<Main>` (dataset display) component rerunning, and is currently only in  nextstrain.org, not the default auspice server.)
@jameshadfield
Copy link
Member

Thanks @trvrb -- a nice improvement here. We use React Helmet for nextstrain.org as well.

I've tested it on nextstrain.org locally and (i) moved the component higher up the tree and (ii) connected it to redux state. Why?

  1. We want this to run for the Splash page, as well as for datasets. This allows nextstrain.org/groups/blab to show a title of nextstrain / groups / blab.
  2. We modify the URL in certain situations (e.g. /flu/avian -> /flu/avian/h5n1/ha) and we want the head to change accordingly here. Note that this URL changes without the <Main> (dataset display) component rerunning.

but I wasn't able to test [nextstrain.org]

This is harder to do now that we import auspice as a normal dep in nextstrain.org, and hopefully we can improve this over time. You can do it following https://github.com/nextstrain/nextstrain.org#using-a-different-version-of-auspice:

# nextstrain.org directory
npm link ${path_to_auspice_src}
npm link ${path_to_auspice_src}/node_modules/react
npm run build -- auspice # rebuild auspice
npm run server -- --verbose # start nextstrain.org server

Note that this breaks my global install of auspice -- i.e. I can no longer run auspice -- and so I have to run these commands to restore that, but doing so will break the nextstrain.org setup 😱

# auspice src directory
npm i --global .

One small change worth considering is maybe swapping the order of the title pieces

Agreed that this would be better for multiple tabs (although multiple flu / seasonal / ... ones would still be somewhat indistinguishable). I think it's important to keep nextstrain (or auspice) front and center, especially for search results, and so I've decided to keep it as is.

@trvrb
Copy link
Member Author

trvrb commented Jan 22, 2020

Thanks James. I agree with all the changes you've made. I also think that keeping Nextstrain / zika, etc.. is better for Google results display.

While multiple calls to `<Helmet>` aren't problematic, it's conceptually simpler to manage this all from one place (the `<Head>` component in `head.js`). No changes in behavior.
@jameshadfield
Copy link
Member

Yup. This is a nice improvement 👍
Just added one final commit to just centralise all the usage of (no change in behavior) as I missed it's usage in the component to set the description.

@jameshadfield jameshadfield reopened this Jan 22, 2020
@jameshadfield jameshadfield merged commit 8a1c456 into master Jan 22, 2020
@jameshadfield jameshadfield deleted the seo branch January 22, 2020 02:21
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

Successfully merging this pull request may close these issues.

3 participants