简体   繁体   中英

How to override the og:url meta tag with reactjs

I am new to ReactJs and working on a site that uses react-document-meta to generate meta data. I would like to override the og:url tag and was wondering if there is a way to do this. Being new to ReactJs, I couldn't figure out a way looking at the library. I appreciate any help.

Thanks, -DJ

Based on the docs and source code

const meta = {
  title: 'Some Meta Title',
  description: 'I am a description, and I can create multiple tags',
  canonical: 'http://example.com/path/to/page',  // this will be doubled as og:url
  meta: {
    charset: 'utf-8',
    name: {
      keywords: 'react,meta,document,html,tags'
    },
    property : {
      'og:url' : 'http://example.com/overriden_url' // but here you can override the autogenerated og:url
    }
  }
};

Keep in mind it only makes sense when rendering on the server-side, as setting meta properties on the client-side (in the browser) has no effect on what the Facebook parser sees when scrapping the page.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM