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

Better meta tags for third parties #878

Merged
merged 2 commits into from
Apr 19, 2018
Merged

Better meta tags for third parties #878

merged 2 commits into from
Apr 19, 2018

Conversation

tijmenb
Copy link
Contributor

@tijmenb tijmenb commented Apr 18, 2018

This adds a number of new metatags for third parties to use.

It makes the most difference to pages that have images, like news articles and images.

Facebook

Linter output

Before:

screen shot 2018-04-18 at 17 49 09

After:

screen shot 2018-04-18 at 17 54 22

Slack

Before:

before

After:

screen shot 2018-04-19 at 12 02 43

Twitter

Tested with https://cards-dev.twitter.com/validator.

Before:

screen shot 2018-04-19 at 12 08 31

After:

screen shot 2018-04-19 at 12 08 59

Whatsapp

Before:

before 2

After:

screen shot 2018-04-19 at 12 13 46

@tijmenb tijmenb temporarily deployed to government-frontend-pr-878 April 18, 2018 13:46 Inactive
@tijmenb tijmenb temporarily deployed to government-frontend-pr-878 April 18, 2018 13:59 Inactive
@tijmenb tijmenb temporarily deployed to government-frontend-pr-878 April 18, 2018 14:10 Inactive
@tijmenb tijmenb temporarily deployed to government-frontend-pr-878 April 18, 2018 14:14 Inactive
@@ -49,6 +49,11 @@ def content_id
content_item["content_id"]
end

def web_url
# Plek.current.website_root + content_item["base_path"]
"https://government-frontend-pr-878.herokuapp.com" + content_item["base_path"]
Copy link
Contributor

Choose a reason for hiding this comment

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

just a suggestion: You could try to make Plek.current read the env variable from heroku

https://stackoverflow.com/questions/12570579/how-to-get-heroku-app-name-url-from-inside-the-app

@tijmenb tijmenb temporarily deployed to government-frontend-pr-878 April 18, 2018 16:43 Inactive
@tijmenb tijmenb temporarily deployed to government-frontend-pr-878 April 18, 2018 16:57 Inactive
@tijmenb tijmenb temporarily deployed to government-frontend-pr-878 April 19, 2018 08:43 Inactive
tijmenb added a commit to alphagov/slimmer that referenced this pull request Apr 19, 2018
When combining the template and application HTML, the `TagMover` will
take the meta and script tags from the application HTML and move them
to the bottom of the `<head>` tag.

`TagMover` moves them to the bottom, so that the CSS of the application
can override the CSS of the template (there's even a test in this gem
to make sure it does it like this).

However, the desired behaviour for meta tags is the reverse. In
particular, we want the `og:image` from the application to be higher
than the `og:image` from the template. This is because services like
Slack will choose the first `og:image` tag and not the more appropriate
custom one.

I tried to do this in
alphagov/govuk_template#349, but I forgot that
life isn't easy and Slimmer exists.

Will enable alphagov/government-frontend#878 to
work properly.
@tijmenb tijmenb changed the title WIP: Better meta tags Better meta tags for third parties Apr 19, 2018
@tijmenb tijmenb temporarily deployed to government-frontend-pr-878 April 19, 2018 11:52 Inactive
@tijmenb tijmenb temporarily deployed to government-frontend-pr-878 April 19, 2018 11:52 Inactive
@tijmenb tijmenb temporarily deployed to government-frontend-pr-878 April 19, 2018 13:41 Inactive
This adds a number of meta tags for use by third parties like Facebook,
Slack and Twitter.

It makes the most difference to pages that have images like news
articles and case studies.

- Opengraph (`og`) tag are used by most services. You can read the spec
here http://ogp.me.
- The `twitter` tags are service-specific but are also used by Slack
and possibly others
(https://medium.com/slack-developer-blog/everything-you-ever-wanted-to-k
now-about-unfurling-but-were-afraid-to-ask-or-how-to-make-your-e64b4bb92
@tijmenb tijmenb merged commit 208167d into master Apr 19, 2018
@tijmenb tijmenb deleted the better-meta-tags branch April 19, 2018 14:06
tijmenb added a commit to alphagov/govuk_publishing_components that referenced this pull request May 22, 2018
tijmenb added a commit to alphagov/govuk_publishing_components that referenced this pull request May 23, 2018
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