-
Notifications
You must be signed in to change notification settings - Fork 17
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
Conversation
fe9cf3d
to
4c73dcf
Compare
"dateModified" => presenter.public_updated_at, | ||
"description" => presenter.description, | ||
"publisher" => { | ||
"@type" => "Organization", |
There was a problem hiding this comment.
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"], | ||
}, | ||
} |
There was a problem hiding this comment.
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.
There was a problem hiding this 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).
4c73dcf
to
84bcaa3
Compare
Thanks @cbaines, updated with extra URLs. Still passes validation: 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 |
Good good 👍 |
This implements a minimum of structured data for news articles.
As per Google:
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
https://trello.com/c/zjcEjaii/5-start-experimenting-with-structured-data