Open aaccioly opened 4 months ago
Since the 2024-06-25 update (https://www.notion.so/releases/2024-06-25), when a page is configured to be "Discoverable on the web", Notion now sets:
og:site_name
ending in "on Notion"twitter:site
to @NotionHQ
So, most of the problems mentioned above are now fixed on Notion's side. Nevertheless, customising meta tags is a premium feature, so I think we can still make good use of this PR. I'll update it to fallback to the old behaviour of extracting content from Notion when pageMetadata
is not specified.
Thanks for the pull request!
Merged it with a small refactoring.
Now version 1.0.31 is the latest one containing your PR.
Hi @velsa,
Many thanks for merging and refactoring the PR, as well as for the amazing software.
I've updated my site to use the latest version and can confirm that custom metadata is still reported correctly when visiting the site with Googlebot and Bingbot user agents (i.e., Mozilla/5.0 (Linux; Android 6.0.1; Nexus 5X Build/MMB29P) AppleWebKit/537.36 (KHTML, like Gecko) [Chrome/W.X.Y.Z](https://developers.google.com/search/docs/crawling-indexing/overview-google-crawlers#user_agent_version) Mobile Safari/537.36 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)
and Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; bingbot/2.0; +http://www.bing.com/bingbot.htm) Chrome/
).
Apparently, https://velsa.net/ is reporting a 404 when using one of the agents. Have you toggled the "Discoverable on the web" option off by any chance?
Finally, a non-important detail, but given Notion's update mentioned in https://github.com/velsa/notehost/issues/36#issuecomment-2195560337, I don't think that lines 98 and 100 bellow are necessary anymore: https://github.com/velsa/notehost/blob/811088548ab07daf71e78e507fcfc02c03fa0d9b/src/rewriters/meta-rewriter.ts#L96-L101
Line 99 is still required for the title, and if you ever decide to change the code to not replace og:site_name
unconditionally, you may also want to replace ' on Notion'
.
Meta tags are currently receiving default values from Notion, e.g.:
Which leads to SEO issues:
The problem is likely happening at: https://github.com/velsa/notehost/blob/d227b8c2fbef34644cc337af9f327a40f41da289/src/rewriters/meta-rewriter.ts#L23-L24
Which gets used at:
https://github.com/velsa/notehost/blob/d227b8c2fbef34644cc337af9f327a40f41da289/src/rewriters/meta-rewriter.ts#L29-L35 And:
https://github.com/velsa/notehost/blob/d227b8c2fbef34644cc337af9f327a40f41da289/src/rewriters/meta-rewriter.ts#L41-L50
A quick and dirty workaround is to use
siteName
andsiteDescription
instead of content for all pages. A more flexible solution would be to parameterise slugs with optional custom titles + descriptions, falling back tositeName
anddescription
:Bonus, we should probably prepend
https://
to the domain at:https://github.com/velsa/notehost/blob/d227b8c2fbef34644cc337af9f327a40f41da289/src/rewriters/meta-rewriter.ts#L52-L54