Skip to content

MetaRewriter is no longer correctly replacing title and description  #36

@aaccioly

Description

@aaccioly

Meta tags are currently receiving default values from Notion, e.g.:

<meta name="twitter:site" content="@NotionHQ">
<meta name="twitter:title" content="Notion – The all-in-one workspace for your notes, tasks, wikis, and databases.">
<meta name="twitter:description"
  content="A new tool that blends your everyday work apps into one. It's the all-in-one workspace for you and your team">
<!--- ...  -->
<meta property="og:title" content="Notion – The all-in-one workspace for your notes, tasks, wikis, and databases.">
<meta property="og:description"
  content="A new tool that blends your everyday work apps into one. It's the all-in-one workspace for you and your team">

Which leads to SEO issues:

image

The problem is likely happening at:

content = content.replace(' | Built with Notion', '')
content = content.replace(' | Notion', '')

Which gets used at:

if (element.tagName === 'title') {
element.setInnerContent(content)
}
if (property === 'og:title' || name === 'twitter:title') {
element.setAttribute('content', content)
}

And:

if (name === 'description' || property === 'og:description' || name === 'twitter:description') {
if (this.isRootPage) {
element.setAttribute('content', siteDescription)
} else {
element.setAttribute(
'content',
content.replace('Built with Notion, the all-in-one connected workspace with publishing capabilities.', ''),
)
}
}

A quick and dirty workaround is to use siteName and siteDescription instead of content for all pages. A more flexible solution would be to parameterise slugs with optional custom titles + descriptions, falling back to siteNameand description:

  siteName: 'My Notion Website',
  siteDescription: 'Build your own website with Notion. This is a demo site.',
  // Should replace twitter:site
  siteTwitter: '@MyHandle'

  slugToPage: {
    '': 'NOTION_PAGE_ID',
    about: 'NOTION_PAGE_ID',
    // Both pages above will fallback to siteName + description
    contact: {
      id: 'NOTION_PAGE_ID',
      title: 'Contact form',
      description: 'Bla bla bla',
    },
  },

Bonus, we should probably prepend https:// to the domain at:

if (property === 'og:url' || name === 'twitter:url') {
element.setAttribute('content', domain)
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions