Add image meta tags to De-risking Guide pages #713
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Changes proposed in this pull request:
Summary
og:imageandog:image:altmeta tags that are configurable per guide. Details are in the updated development doc.og:imagewith empty alt text for the de-risking guide.Resolves #705 .
Approach
For the guide-level configuration, I added a new
_data/meta_images.yamlfile whose contents are available to Eleventy as key/value data during the build process. A guide will default to the current production behavior unless a meta image is explicitly configured: When a page is built, if there is nometa_imagesvalue for the page's guide name, then noog:imageorog:image:alttag is rendered.During the build process, the eleventy-img package modifies and anonymizes the name of the image file within the assets directory. The
Image()javascript call in index.js returns the processed image's URL. In order to access that URL within the page template file code, I've exposed it as a new Eleventy shortcode.Testing
Testing is manual and indirect, since image URLs are environment-specific and we don't have direct control over whether platforms use our pages'
og:imagemetadata.In the PR preview build
og:imagetag with content set to a relative path to an image fileog:image:alttag with content set to ""og:imageorog:image:altmeta tag is present.In a local build environment
NODE_ENV=production npm run devog:imagetag is present and has its content set to an absolute image URL, beginning withhttps://guides.18f.gov/security considerations
No security considerations; these changes use the existing Eleventy framework and OpenGraph standards.
In particular, the mechanism for determining whether the build the site for a production environment is already used to generate sitemap.xml.