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

Allow og:image meta tag to be customisable #847

Merged
merged 2 commits into from
Jul 19, 2018

Conversation

kr8n3r
Copy link

@kr8n3r kr8n3r commented Jun 29, 2018

Moving the meta tag into the head block so that it can be overwritten, as the image path for it needs to be an absolute path.

Fixes: #813

@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-847 June 29, 2018 13:09 Inactive
@kr8n3r kr8n3r force-pushed the make-og-image-meta-tag-customisable branch from 00ef166 to 645e77a Compare June 29, 2018 13:12
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-847 June 29, 2018 13:12 Inactive
@kr8n3r kr8n3r force-pushed the make-og-image-meta-tag-customisable branch from 645e77a to 56132d5 Compare July 1, 2018 10:36
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-847 July 1, 2018 10:37 Inactive
@kr8n3r kr8n3r force-pushed the make-og-image-meta-tag-customisable branch from 56132d5 to ff7a345 Compare July 2, 2018 14:24
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-847 July 2, 2018 14:24 Inactive
src/template.njk Outdated
@@ -18,10 +18,11 @@
<link rel="apple-touch-icon" href="{{ assetPath | default('/assets') }}/images/govuk-apple-touch-icon.png">
{% endblock %}

{% block head %}{% endblock %}

{% block head %}
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a breaking change since before even when you set head you'd get the default open graph image.

Could this be solved by something like

<meta property="og:image" content="{{ opengraphAssetPath | default('') }}{{ assetPath | default('/assets') }}/images/govuk-opengraph-image.png">

Copy link
Author

Choose a reason for hiding this comment

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

tru dat. updated so that the variable can just be set

@kr8n3r kr8n3r force-pushed the make-og-image-meta-tag-customisable branch from ff7a345 to 254971a Compare July 2, 2018 15:56
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-847 July 2, 2018 15:56 Inactive
src/template.njk Outdated
{# The default og:image is added below head so that scrapers see any custom metatags first, and this is just a fallback #}
<meta property="og:image" content="{{ assetPath | default('/assets') }}/images/govuk-opengraph-image.png">
{# image path needs to absolute e.g. http://wwww.domain.com/.../govuk-opengraph-image.png #}
Copy link
Contributor

Choose a reason for hiding this comment

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

Path refers to just the part after the domain - i.e. just the /.../govuk-opengraph-image.png bit. How about assetUrl?

Copy link
Author

Choose a reason for hiding this comment

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

sure. updated

@NickColley
Copy link
Contributor

Would you mind raising an issue after this is merged on the Design System repo to include this new feature in the guidance?

{# The default og:image is added below head so that scrapers see any custom metatags first, and this is just a fallback #}
<meta property="og:image" content="{{ assetPath | default('/assets') }}/images/govuk-opengraph-image.png">
{# image url needs to be absolute e.g. http://wwww.domain.com/.../govuk-opengraph-image.png #}
<meta property="og:image" content="{{ assetUrl | default('/assets') }}/images/govuk-opengraph-image.png">
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the default needs to be 'assetPath' otherwise this is a breaking change still?

Copy link
Contributor

Choose a reason for hiding this comment

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

maybe {{ openGraphImagePath | assertPath | default('/assets') }}

not sure

Copy link
Author

Choose a reason for hiding this comment

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

it doesn't work with assetPath anyway, so not sure it's a breaking change

Copy link
Contributor

Choose a reason for hiding this comment

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

Fair point, but consider if someone set their 'assetPath' to a absolute path, it would be working for those users?

Copy link
Author

@kr8n3r kr8n3r Jul 10, 2018

Choose a reason for hiding this comment

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

yeah.
we can set
{% set assetUrl = assetUrl or (assetPath | default('/assets')) %}

so if they do have it set to absolute atm, OG image will still work.

for anyone new, they can assign a new value to assetUrl ?

Copy link
Author

@kr8n3r kr8n3r Jul 10, 2018

Choose a reason for hiding this comment

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

modified so that the default value for assetUrl is assetPath, insuring it is not a breaking change if anyone specified an absolute url for the assets

@kr8n3r kr8n3r force-pushed the make-og-image-meta-tag-customisable branch 2 times, most recently from 57b4d7a to 062c959 Compare July 10, 2018 14:12
Copy link
Contributor

@36degrees 36degrees left a comment

Choose a reason for hiding this comment

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

Given it seems that the opengraph image needs an absolute URL, do we need to document this somewhere? e.g. https://design-system.service.gov.uk/styles/page-template/?

How did this work in GOV.UK Template?

CHANGELOG.md Outdated
@@ -28,6 +28,15 @@
([PR #837](https://github.com/alphagov/govuk-frontend/pull/837) and
[PR #848](https://github.com/alphagov/govuk-frontend/pull/848))

- Use relative line-height
Copy link
Contributor

Choose a reason for hiding this comment

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

This shouldn't be part of this PR.

CHANGELOG.md Outdated
Update typography styles to use relative, unitless line-height
([PR #837](https://github.com/alphagov/govuk-frontend/pull/837))

- Allow og:image meta tag to be customisable
Copy link
Contributor

Choose a reason for hiding this comment

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

It was already customisable by modifying assetPath – I think we need to be clearer as to what the change is here.

@NickColley
Copy link
Contributor

@kr8n3r kr8n3r force-pushed the make-og-image-meta-tag-customisable branch from 062c959 to e01316d Compare July 10, 2018 14:49
@kr8n3r
Copy link
Author

kr8n3r commented Jul 10, 2018

i've updated the wording

@kr8n3r kr8n3r removed this from the v1.1.0 milestone Jul 13, 2018
@NickColley NickColley added feature request User requests a new feature and removed enhancement labels Jul 13, 2018
@kr8n3r kr8n3r force-pushed the make-og-image-meta-tag-customisable branch 2 times, most recently from ae6f29f to 6b7b7dc Compare July 13, 2018 18:39
@NickColley
Copy link
Contributor

Thinking about this more, if this is solved by setting 'assetPath' to an absolute url do we need to do this at all?

@kr8n3r
Copy link
Author

kr8n3r commented Jul 18, 2018

we can't set the absolute path for example in the design system (as we have two different urls)
but if thats not of a concern and we just leave the declaration twice as we have now, then there is no need for this indeed

Jani Kraner added 2 commits July 19, 2018 09:46
Moving the meta tag into the `head`block
so that it can be overwritten with an absolute path
@kr8n3r kr8n3r force-pushed the make-og-image-meta-tag-customisable branch from 6b7b7dc to 912b9f1 Compare July 19, 2018 08:46
Copy link
Contributor

@NickColley NickColley left a comment

Choose a reason for hiding this comment

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

I think this makes sense, assetUrl feels a little vague but it works as intended, as long as we document this well in the Design System.

@kr8n3r kr8n3r added this to the [NEXT] milestone Jul 19, 2018
@kr8n3r kr8n3r merged commit 7509a5d into master Jul 19, 2018
@kr8n3r kr8n3r deleted the make-og-image-meta-tag-customisable branch July 19, 2018 10:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request User requests a new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants