Markdown pages use page title for OpenGraph link preview #10018

Open
opened 2025-11-02 08:55:52 -06:00 by GiteaMirror · 2 comments
Owner

Originally created by @aschrijver on GitHub (Dec 26, 2022).

Feature Description

When dropping a link to a Markdown file in a git repo, e.g. in a Matrix chat or Discourse forum, then the generated link preview should be based on the first <H1> title in this markdown document.

Some rules:

  • The H1 title may be preceded with frontmatter, and is then still detected.
  • If the markdown starts with other formatting (e.g. regular text) and then a H1, then it is not used in the link preview.

If the H1 can be considered as the title of the page, an og:title is added to the <meta> of the page.

Possible extensions

  • The regular text immediately following the title can be used as og:description, cut off at a designated number of chars and with ellipsis '...' added.

  • The frontmatter, if available on a markdown document, might be recognized and parse title and description into og:title and og:description.

Note

This feature request relates to downstream issue forgejo/#173.

Screenshots

Here is the link to markdown document titled FEP-1b12: Group federation in the fediverse/fep repository, after it was posted to a Matrix chatroom:

forgejo-markdown-link-previews

How it may look like after the feature is implemented:

forgejo-markdown-link-previews-concept

Originally created by @aschrijver on GitHub (Dec 26, 2022). ### Feature Description When dropping a link to a Markdown file in a git repo, e.g. in a Matrix chat or Discourse forum, then the generated link preview should be based on the first `<H1>` title in this markdown document. Some rules: - The H1 title may be preceded with frontmatter, and is then still detected. - If the markdown starts with other formatting (e.g. regular text) and then a H1, then it is not used in the link preview. If the H1 can be considered as the title of the page, an `og:title` is added to the `<meta>` of the page. ### Possible extensions - The regular text immediately following the title can be used as `og:description`, cut off at a designated number of chars and with ellipsis '...' added. - The frontmatter, if available on a markdown document, might be recognized and parse `title` and `description` into `og:title` and `og:description`. ### Note This feature request relates to downstream issue [forgejo/#173](https://codeberg.org/forgejo/forgejo/issues/173). ### Screenshots Here is the link to markdown document titled [FEP-1b12: Group federation](https://codeberg.org/fediverse/fep/src/branch/main/feps/fep-1b12.md) in the [fediverse/fep](https://codeberg.org/fediverse/fep) repository, after it was posted to a Matrix chatroom: ![forgejo-markdown-link-previews](https://user-images.githubusercontent.com/5111931/209551097-c69fb89f-6429-4489-b324-ff007e9b60f8.png) How it may look like after the feature is implemented: ![forgejo-markdown-link-previews-concept](https://user-images.githubusercontent.com/5111931/209551114-4a03ed46-3aff-4808-b554-0be9860aa7b7.png)
GiteaMirror added the type/proposaltype/feature labels 2025-11-02 08:55:52 -06:00
Author
Owner

@aschrijver commented on GitHub (Jan 19, 2023):

I should add that the OpenGraph issue is broader. Here's the organization account by the Pixelfed developer, and the description makes it look like this is Codeberg.

forgejo-opengraph-org-accounts

@aschrijver commented on GitHub (Jan 19, 2023): I should add that the OpenGraph issue is broader. Here's the organization account by the Pixelfed developer, and the description makes it look like this is Codeberg. ![forgejo-opengraph-org-accounts](https://user-images.githubusercontent.com/5111931/213363523-79e3b8db-918b-41b7-9ee5-939460fe4d3f.png)
Author
Owner

@jolheiser commented on GitHub (Jan 19, 2023):

I should add that the OpenGraph issue is broader. Here's the organization account by the Pixelfed developer, and the description makes it look like this is Codeberg.

forgejo-opengraph-org-accounts

fwiw this looks like a byproduct of where it was posted, and would be remedied if they added an org description.
On Discord, the OG embed for this org is blank, but in Matrix (where I'm assuming this was taken) it appears to try to use the site description as a fallback.
On both platforms it uses the org description if available.

@jolheiser commented on GitHub (Jan 19, 2023): > I should add that the OpenGraph issue is broader. Here's the organization account by the Pixelfed developer, and the description makes it look like this is Codeberg. > > ![forgejo-opengraph-org-accounts](https://user-images.githubusercontent.com/5111931/213363523-79e3b8db-918b-41b7-9ee5-939460fe4d3f.png) fwiw this looks like a byproduct of where it was posted, and would be remedied if they added an org description. On Discord, the OG embed for this org is blank, but in Matrix (where I'm assuming this was taken) it appears to try to use the site description as a fallback. On both platforms it uses the org description if available.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#10018