FrancescoXX / 4c-site

Open-source website for the 4C
https://4c.rocks
MIT License
217 stars 154 forks source link

Open Graph and Twitter Cards #27

Closed InHuOfficial closed 3 years ago

InHuOfficial commented 3 years ago

Feature Request

When sharing the site we should have Open Graph and Twitter Cards so that they are shareable as rich media cards.

This was mentioned in the comms chat on Discord.

Solution:

We require the following Meta Tags adding (bear in mind that these need to be configurable on a page by page basis ideally):

Open Graph

That is the minimum for Open Graph to work.

We probably also want:

Twitter Cards

Implementation considerations

Example for a meta tag:

<meta name="twitter:title" content="4C - Cool Community for Content Creators, helping you grow your online following and improve your content creationa" />

More complete examples at: https://ogp.me/

danspratling commented 3 years ago

@InHuOfficial This is a non-issue as it's already been set up

Check out the file here - https://github.com/FrancescoXX/4c-site/blob/main/components/SEO.js

pages/index.js uses these already (though it only uses metaTitle). This is pulled into every page that uses the <Layout> component

How to use

const Page = () => {
  const seo = {
    metaTitle: "Page title goes here",
    metaDescription: "Page description goes here",
    metaImage: "https://4c.rocks/path-to-seo-image.jpg",
    url: "/blog" (path of current page),
    article: true (defaults to false),
    author: "Dan Spratling",
    lang: "en-US"  (language, no default)
  }

  return (
    <Layout seo={seo}>
      //your page content goes here
    </Layout>
  )
}

None of these fields are required, but when used they will create the correct fields for default, twitter and og meta tags

Types (these are not enforced)

interface seo {
  metaTitle: String
  metaDescription: String
  metaImage: String
  url: String
  article: Boolean
  author: String
  lang: String
}
InHuOfficial commented 3 years ago

Cool well you can close if you wish, obviously still needs setting up properly as at the moment not right, not sure whether you would rather close or just adapt this one so the missing info is added and ensure it is part of each page?

Was just reacting to the issue in chat so whatever works for you 👍

danspratling commented 3 years ago

@ayushhagarwal can you close this? Going to create new issues for the 3 remaining tasks related to this one