Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Copy other metadata systematically #94

Open
mrocklin opened this issue Jan 6, 2023 · 3 comments
Open

Copy other metadata systematically #94

mrocklin opened this issue Jan 6, 2023 · 3 comments
Labels
enhancement New feature or request

Comments

@mrocklin
Copy link

mrocklin commented Jan 6, 2023

So, in my site my pages have consistent metadata with fields like title. I'd love to have these automatically also populate the og:title field. Any suggestions on how this could be done?

@mrocklin
Copy link
Author

mrocklin commented Jan 6, 2023

My pages today look like the following (with MyST)

---
title: How I Conduct an Interview
og:title: How I Conduct an Interview
date: 2023-01-06
...

@Daltz333
Copy link
Member

Daltz333 commented Jan 8, 2023

How are you injecting titles or other metadata into pages conditionally? The regular default for OpenGraph (being the first header on the page) for titles solves most cases, as the first header is usually identical to the title of the page.

@Daltz333 Daltz333 added the enhancement New feature or request label Jan 8, 2023
@mrocklin
Copy link
Author

mrocklin commented Jan 9, 2023

I put the following in my template, mostly to help avoid duplication

{%- if meta is mapping and "title" in meta %}
<h1> {{ meta.get("title") }} </h1>
{%- endif %}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants