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 Open Graph meta tags for archive pages. #13137

Conversation

emilyatmobtown
Copy link
Contributor

@emilyatmobtown emilyatmobtown commented Jul 26, 2019

Previously, Open Graph tags were added only for pages that were singular, home, or author archives. These changes add Open Graph meta tags to all archive pages.

Fixes #1987

Changes proposed in this Pull Request:

  • The og:type is set to 'website', which is the default recommended by Facebook and the Open Graph protocol.
  • The title of the archive page is added as the og:title.
  • The site name is added as the og:site_name.
  • For category, tag, taxonomy, and post type archives, the og:url is set to the appropriate archive link and the og:description is set to the relevant description. For date archives, the URL defaults to the site URL and the description defaults to the site description.
  • The og:image and og:locale tags are handled as they are for the home page.
  • Tags for author archives are not addressed in this change since they're already included.

Is this a new feature or does it add/remove features to an existing part of Jetpack?

  • If you're an Automattician, include a shortlink to the p2 discussion with Jetpack Product here.

This updates the existing Open Graph meta tag functionality to apply appropriate tags to archive pages.

Testing instructions:

To test Category pages:

  • Log in to the WordPress dashboard.
  • Go to Posts > Categories.
  • Go to a category in the list and hover over the category name to see the menu links appear below.
  • Click "View" to view the category archive page.
  • Right-click the page and select "Inspect" or "Inspect Element" to open the Web Inspector.
  • See the HTML in the Elements panel.
  • Within the HTML, click on "" to expand that section.
  • See the Open Graph tags in the added by Jetpack as shown below.
  • See that tags are present for og:type, og:title, og:url, og:site_name, og:locale, and og:image.
  • If an archive description is present, see that the og:description is present and set to that description.

Screen Shot 2019-07-26 at 2 27 10 PM

To test Tag pages:

  • Repeat the same steps above but for Tags by going to to Posts > Tags, viewing the tag archive page, and continuing from there.

To test custom post type archives:

  • Install and activate the Custom Post Type UI plugin.
  • Go to CPT UI > Add/Edit Post Types.
  • Fill in the following fields:
    • Post Type Slug: things
    • Plural Label: Things
    • Singular Label: Thing
  • Scroll down to "Has Archive" and select "True".
  • Click "Add Post Type".
  • Go to Things > Add New.
  • Enter a title and click "Publish".
  • Go to /things to view the Thing archive page.
  • Continue with the steps above to inspect the page and see the Open Graph tags in the HTML.

To test custom taxonomy archive pages:

  • Complete the steps above to install the Custom Post Type UI plugin and create a CPT called Things.
  • Go to CPT UI > Add/Edit Taxonomies.
  • Fill in the following fields:
    • Taxonomy Slug: types
    • Plural Label: Types
    • Singular Label: Type
  • Check the box to "Attach to Post Type" for "Things".
  • Click "Add Taxonomy".
  • Go to Things > Add New.
  • Enter a title.
  • Under Types, enter "Blue" in the "Add new Type" field and press Enter.
  • Click Publish.
  • Go to Things > Types.
  • In the list of Types, hover over the name "Blue" to see the menu links appear below.
  • Click "View" to view the custom taxonomy archive page.
  • Continue with the steps above to inspect the page and see the Open Graph tags in the HTML.

To test date archive pages:

  • Go to /2019.
  • Continue with the steps above to inspect the page and see the Open Graph tags in the HTML.
  • Additionally, if a site description is present, see that the og:description is present and set to that description.

Proposed changelog entry for your changes:

  • Add Open Graph meta tags to archive pages.

@jetpackbot
Copy link

jetpackbot commented Jul 26, 2019

Thank you for the great PR description!

When this PR is ready for review, please apply the [Status] Needs Review label. If you are an a11n, please have someone from your team review the code if possible. The Jetpack team will also review this PR and merge it to be included in the next Jetpack release.

Scheduled Jetpack release: August 6, 2019.
Scheduled code freeze: July 30, 2019

Generated by 🚫 dangerJS against f4e11e4

@jeherve jeherve added [Status] Needs Review To request a review from Crew. Label will be renamed soon. [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it [Feature] Sharing Post sharing, sharing buttons [Pri] Normal labels Jul 29, 2019
@jeherve jeherve added this to the 7.7 milestone Jul 29, 2019
Copy link
Member

@jeherve jeherve left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution. I left a few first comments.

I would also recommend running yarn build in your local testing environment. It will bring you some additional tools to help you with developing, such as PHPCS.

You can get started with this here:
https://github.com/Automattic/jetpack/blob/master/docs/development-environment.md#before-moving-forward

functions.opengraph.php Outdated Show resolved Hide resolved
functions.opengraph.php Outdated Show resolved Hide resolved
functions.opengraph.php Outdated Show resolved Hide resolved
functions.opengraph.php Outdated Show resolved Hide resolved
functions.opengraph.php Outdated Show resolved Hide resolved
@jeherve jeherve added [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! and removed [Status] Needs Review To request a review from Crew. Label will be renamed soon. labels Jul 31, 2019
@emilyatmobtown
Copy link
Contributor Author

Thanks for all your feedback, @jeherve!

@jeherve jeherve added [Status] Needs Review To request a review from Crew. Label will be renamed soon. [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! and removed [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! [Status] Needs Review To request a review from Crew. Label will be renamed soon. labels Aug 1, 2019
@jeherve jeherve added [Status] Needs Review To request a review from Crew. Label will be renamed soon. and removed [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! labels Aug 6, 2019
Copy link
Member

@jeherve jeherve left a comment

Choose a reason for hiding this comment

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

This works well in my tests. 👍

@jeherve jeherve added [Status] Ready to Merge Go ahead, you can push that green button! and removed [Status] Needs Review To request a review from Crew. Label will be renamed soon. labels Aug 6, 2019
@matticbot
Copy link
Contributor

Caution: This PR has changes that must be merged to WordPress.com
Hello emilyatmobtown! These changes need to be synced to WordPress.com - If you 're an a11n, please commandeer, review, and approve D31233-code before merging this PR. Thank you!

@mdawaffe mdawaffe merged commit 41f6b7d into Automattic:master Aug 15, 2019
@matticbot matticbot removed the [Status] Ready to Merge Go ahead, you can push that green button! label Aug 15, 2019
jeherve added a commit that referenced this pull request Aug 23, 2019
jeherve added a commit that referenced this pull request Aug 27, 2019
* 7.7 changelog: initial set of changes

* Changelog: add #13154

* Changelog: add #13134

* Changelog: add #12699 and many others

* Changelog: add #13127

* Changelog: add #13167

* Changelog: add #13225

* Changelog: add #13179

* Changelog: add #13173

* Changelog: add #13232

* Changelog: add #13137

* Changelog: add #13172

* Changelog: add #13182

* Changelog: add #13200

* Changelog: add #13244

* Changelog: add #13267

* Changelog: add #13204

* changelog: add #13205

* Changelog: add #13183

* Changelog: add #13278

* Changelog: add #13162

* Changelog: add #13268

* Changelog: add #13286

* Changelog: add #13273

* Changelog: add #12474

* Changelog: add #13085

* Changelog: add #13266

* Changelog: add #13306

* Changelog: add #13311

* Changelog: add #13302

* Changelog: add #13196

* Changelog: add #12733

* Changelog: add #13261

* Changelog: add #13322

* Changelog: add #13333

* Changelog: add #13335
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Sharing Post sharing, sharing buttons [Pri] Normal Touches WP.com Files [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Open Graph: add tags on archive pages
5 participants