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

Is it possible to use the og:description for the regular meta description as well? #65

Closed
msbt opened this issue Jun 27, 2022 · 15 comments · Fixed by #72
Closed

Is it possible to use the og:description for the regular meta description as well? #65

msbt opened this issue Jun 27, 2022 · 15 comments · Fixed by #72

Comments

@msbt
Copy link

msbt commented Jun 27, 2022

Hi there! Grabbing the first piece of content and add it as og:description works fine, thanks a lot for that. I'm just curious if there is a way to also use this content as regular meta name="description" if nothing is specified otherwise via

.. meta::
   :description:

Would be very nice to have, any pointers on how to achieve that?

@Daltz333
Copy link
Member

I believe it was an intentional design decision to not modify any content besides OpenGraph. We found other extensions tended to also mess with meta information and it caused painful conflicts. Additionally, it could pretty quickly expand the scope of this extension to include other meta customization outside of OpenGraph.

You can however, inject global meta values using the ogp_custom_meta_tags field in your conf.py. If you want to expand this to an on per-page basis, you can look at the source code for this extension and modify it pretty easily to fit your use case.

@msbt
Copy link
Author

msbt commented Jun 28, 2022

Ah good point, that makes sense, thanks @Daltz333!

@msbt msbt closed this as completed Jun 28, 2022
@ItayZiv
Copy link
Collaborator

ItayZiv commented Jul 2, 2022

I think it might be possible to consider a basic option to use the description we already generate as the default meta description, provided we don't deal with any special cases, overlaps or any other problems.

Reopening for now, I think it would be best if there was a setting in conf.py, disabled by default, and a per-page override to set the tag manually or remove the generated tag. (Using the meta directive would create 2 description tags, and taking care of that would require significant codes changes and/or additional dependencies)

@ItayZiv ItayZiv reopened this Jul 2, 2022
@msbt
Copy link
Author

msbt commented Jul 18, 2022

Thanks for reopening @ItayZiv! May I ask if this is something you're planning to do in the foreseeable future?

@hugovk
Copy link
Contributor

hugovk commented Oct 18, 2022

Please see PR #71 to do the first part of this: add a Boolean setting to conf.py, that when enabled, will add the same description to <meta name="description" content="..."> as used for <meta property="og:description" content="...">.

@msbt
Copy link
Author

msbt commented Oct 20, 2022

This is great, thank you @hugovk!

Quick question though: Would this a) override a manual meta description or b) create a duplicate or c) won't be applied at all?

@hugovk
Copy link
Contributor

hugovk commented Oct 20, 2022

@msbt Let's test it out! How do you set manual meta description?

@hugovk
Copy link
Contributor

hugovk commented Oct 20, 2022

@msbt Let's test it out! How do you set manual meta description?

Like this:

.. meta::
   :description: My manual description

With that set, and enable_meta_description = True, we get b) duplicates: both the manual and automated.

I think it would be better to do c) only have the manual.


Also testing #71 on a bigger set of docs I see we're also getting multiple meta descriptions for subpages too. I'll take a look.

@msbt
Copy link
Author

msbt commented Oct 20, 2022

I think it would be better to do c) only have the manual.

Totally agree with you on that, appreciate your efforts!

@hugovk
Copy link
Contributor

hugovk commented Oct 20, 2022

Please see #72 to fix this!

@TheTripleV
Copy link
Member

TheTripleV commented Oct 21, 2022

I'm open to adding support for meta descriptions to this extension, but want to make sure all of our bases are covered here. (#71 has been reverted while this decided).

Default Behavior

When the description is automatically parsed from the text, it would be written to both og:description and description.

Custom/Override Behavior

The custom version overwrites the auto-generated version.
There's various ways to specify metadata.
As above,

.. meta::
   :description: My manual description

should work. Additionally, in Sphinx, just

:description: My manual description

should work as well. Sphinx automatically puts top level field lists in the context meta.
As this extension already has some field list support, using

:og:description: My manual description

should continue to work as well.

I'm not sure on how to reconcile this on the following questions:

  • If :og:description: is overridden, should the generated description change as well?
  • If :description: is overridden, should the generated og:description change as well?
  • What if both are overridden?

I'm inclined to keep them both separate but that would mean duplicated overrides in rst pages.
Maybe specifying one overrides both, unless both are specified? Open to thoughts.

Note: The results of the aboves questions would apply in the future to overrides for :og:title: and :title: too.

@hugovk
Copy link
Contributor

hugovk commented Oct 21, 2022

I'm not sure on how to reconcile this on the following questions:

  • If :og:description: is overridden, should the generated description change as well?

No, use overridden og:description for og:description, and generate description.

  • If :description: is overridden, should the generated og:description change as well?

No, use overridden description for description, and generate og:description.

  • What if both are overridden?

We:

  • Use overridden og:description for og:description.
  • Use overridden description for description.
  • Don't generate either.

I'm inclined to keep them both separate but that would mean duplicated overrides in rst pages. Maybe specifying one overrides both, unless both are specified? Open to thoughts.

I'm also inclined to keep them separate.

The reason is that whilst their contents will often be the same, it's possible they can be different as they're slightly different, semantically speaking.

One is the title of the webpage, for browsers, the other is the title of the thing to be shared, for Facebook and so on.

  • <meta property="og:description" ...>: description of object to be shared, for Facebook etc.

  • <meta name="description" ...>: description for browsers, and shown in search engine results

Someone may wish to tweak one or both.

So I suggest:

  • We only generate an OG description when there's no overridden OG value.
  • We only generate a non-OG description when there's no overridden non-OG value.

How's that sound?

@TheTripleV
Copy link
Member

Sure, that sounds fine.

@TheTripleV
Copy link
Member

Fun aside (source),

<meta name="description" property="og:description" content="great description">

is allowed and works to set both to the same value. I don't think it's applicable / nice to shoehorn this into rst field lists though.

@hugovk
Copy link
Contributor

hugovk commented Oct 22, 2022

Fun aside 2:

Stack Overflow also combines some Twitter metadata with Open Graph metadata!

<meta property="og:type" content= "website" />
<meta property="og:url" content="https://stackoverflow.com/questions/6203984/combining-the-meta-description-and-open-graph-protocol-description-into-one-tag"/>
<meta property="og:site_name" content="Stack Overflow" />
<meta property="og:image" itemprop="image primaryImageOfPage" content="https://cdn.sstatic.net/Sites/stackoverflow/Img/apple-touch-icon@2.png?v=73d79a89bded" />
<meta name="twitter:card" content="summary"/>
<meta name="twitter:domain" content="stackoverflow.com"/>
<meta name="twitter:title" property="og:title" itemprop="name" content="Combining the meta description and Open Graph Protocol description into one tag" />
<meta name="twitter:description" property="og:description" itemprop="description" content="Is it possible to combine the meta description and Open Graph Protocol description&#x2026;&#xA;&#xA;&amp;lt;meta name=&quot;description&quot; content=&quot;My meta description copy.&quot; /&amp;gt;&#xA;&amp;lt;meta property=&quot;og:description&quot; content..." />

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

Successfully merging a pull request may close this issue.

5 participants