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

Opengraph support #86

Merged
merged 6 commits into from
Apr 1, 2019
Merged

Opengraph support #86

merged 6 commits into from
Apr 1, 2019

Conversation

johanjanssens
Copy link
Member

@johanjanssens johanjanssens commented Apr 1, 2019

Opengraph support

This PR implements automatic support for opengraph and additionally twitter cards. For an overview of both standards please see:

1. Default properties

  • og:type; defaults to website
  • og:image; defaults to page image
  • og:title; defaults to page title
  • og:description; defaults to page description
  • og:url, defaults to the page url

For opengraph metadata to be added to the page both the og:type and og:image properties need to be defined.

2. Custom properties

Properties can be added or custom values for defaults defined by specifying them in the page frontmatter. Example:

metadata:
   'og:type': article  
   'og:author': john doe

3. Global properties

Default properties can be configured, or additional properties can be added using a new 'metadata' config option. Example:

return array(
   'metadata' => [
        'og:site_name' => 'Joomlatools',
        'og:image'     => '/images/default_card.jpg',
        'twitter:site' => '@joomlatools',
        'twitter:card' => 'summary_large_image',
     ]
);

4. Disabling opengraph

Opengraph support can be disabled by setting the 'og:type' metadata property to false.

return array(
   'metadata' => [
        'og:type'  => false
     ]
);

Notes

  • The image should be a site absolute image path, or a url. If it's a path it's transformed into a url when the metadata is being rendered.

  • For twitter we making use of the opengraph properties supported by twitter. For info see: https://developer.twitter.com/en/docs/tweets/optimize-with-cards/overview/markup Specific twitter properties need to be defined either in the page frontmatter of in the global configuration.

Additional improvements

This PR also adds a page ìmage`property.

- Add required opengraph properties to the page metadata
- Allow to disable opengraph support by setting og:type to false
- Return default opengraph properties for title, descriptipn and image
using page properties
Allow to configure the default page metadata. For example to add
twitter card and opengraph defaults to each page.
- Opengraph requires the meta element to use a property tag instead of a
name tag
- Escape the metadata content
@johanjanssens johanjanssens added this to the v0.9.0 milestone Apr 1, 2019
@johanjanssens johanjanssens self-assigned this Apr 1, 2019
Copy link
Member

@ercanozkaya ercanozkaya left a comment

Choose a reason for hiding this comment

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

@johanjanssens left an inline comment

code/site/components/com_pages/view/html.php Show resolved Hide resolved
@ercanozkaya ercanozkaya merged commit 08abcfb into master Apr 1, 2019
@johanjanssens johanjanssens deleted the feature/85-opengraph branch April 1, 2019 11:55
@johanjanssens johanjanssens mentioned this pull request Apr 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants