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

Add structured data for news articles #876

Merged
merged 1 commit into from
Apr 16, 2018
Merged

Conversation

tijmenb
Copy link
Contributor

@tijmenb tijmenb commented Apr 13, 2018

This implements a minimum of structured data for news articles.

As per Google:

Structured data is a standardized format for providing information about a page and classifying the page content; for example, on a recipe page, what are the ingredients, the cooking time and temperature, the calories, and so on.

https://developers.google.com/search/docs/guides/intro-structured-data

We use the JSON-LD (JSON "Linked Data", https://json-ld.org) here. It's Google's recommended way of implementing this and avoids a lot of the hassle involved with Microdata, which interleaves the structured data with HTML.

Unfortunately, the "publisher" attribute needs a logo. I've chosen the Opengraph image for this because it's not likely to change and will probably stay around for a long time. If we're going to implement more structured data, we'll have to come up with an alternative (and a better image).

Testing

The output of this is tested with the Structured data testing tool:

https://search.google.com/structured-data/testing-tool#url=https%3A%2F%2Fgovernment-frontend-pr-876.herokuapp.com%2Fgovernment%2Fnews%2Fasian-hornet-identified-in-lancashire

screen shot 2018-04-13 at 17 38 30


https://trello.com/c/zjcEjaii/5-start-experimenting-with-structured-data

@tijmenb tijmenb temporarily deployed to government-frontend-pr-876 April 13, 2018 15:21 Inactive
@tijmenb tijmenb temporarily deployed to government-frontend-pr-876 April 13, 2018 15:42 Inactive
@tijmenb tijmenb force-pushed the add-structured-data branch from fe9cf3d to 4c73dcf Compare April 13, 2018 16:29
@tijmenb tijmenb temporarily deployed to government-frontend-pr-876 April 13, 2018 16:29 Inactive
@tijmenb tijmenb changed the title [Don't merge] Add structured data for news articles Add structured data for news articles Apr 13, 2018
"dateModified" => presenter.public_updated_at,
"description" => presenter.description,
"publisher" => {
"@type" => "Organization",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The indentation looks a little off here.

"@type" => "Organization",
"name" => publishing_organisation["title"],
},
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm no expert on this linked data stuff, but I'd have expected to find at least some URIs in this... maybe that's a future improvement.

Copy link
Contributor

@cbaines cbaines left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've made a couple of comments, but generally this looks good 👍

This implements a minimum of structured data for news articles.

 As per Google:

> Structured data is a standardized format for providing information
about a page and classifying the page content; for example, on a recipe
page, what are the ingredients, the cooking time and temperature, the
calories, and so on.

https://developers.google.com/search/docs/guides/intro-structured-data

We use the JSON-LD (JSON "Linked Data", https://json-ld.org) here. It's
Google's recommended way of implementing this and avoids a lot of the
hassle involved with Microdata, which interleaves the structured data
with HTML.

The output of this is tested with the Structured data testing tool:

https://search.google.com/structured-data/testing-tool

Unfortunately, the "publisher" attribute needs a logo. I've chosen the
Opengraph image for this because it's not likely to change and will
probably stay around for a long time. If we're going to implement more
structured data, we'll have to come up with an alternative (and a
better image).
@tijmenb
Copy link
Contributor Author

tijmenb commented Apr 16, 2018

@cbaines
Copy link
Contributor

cbaines commented Apr 16, 2018

Thanks @cbaines, updated with extra URLs.

Good good 👍

@tijmenb tijmenb merged commit 7f72d4c into master Apr 16, 2018
@tijmenb tijmenb deleted the add-structured-data branch April 16, 2018 12:41
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.

2 participants