Closed msbt closed 1 year ago
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.
Ah good point, that makes sense, thanks @Daltz333!
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)
Thanks for reopening @ItayZiv! May I ask if this is something you're planning to do in the foreseeable future?
Please see PR https://github.com/wpilibsuite/sphinxext-opengraph/pull/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="...">
.
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?
@msbt Let's test it out! How do you set manual meta description?
@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.
I think it would be better to do c) only have the manual.
Totally agree with you on that, appreciate your efforts!
Please see https://github.com/wpilibsuite/sphinxext-opengraph/pull/72 to fix this!
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).
When the description is automatically parsed from the text, it would be written to both og:description
and description
.
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:
:og:description:
is overridden, should the generated description
change as well?:description:
is overridden, should the generated og:description
change as well?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.
I'm not sure on how to reconcile this on the following questions:
- If
:og:description:
is overridden, should the generateddescription
change as well?
No, use overridden og:description
for og:description
, and generate description
.
- If
:description:
is overridden, should the generatedog:description
change as well?
No, use overridden description
for description
, and generate og:description
.
- What if both are overridden?
We:
og:description
for og:description
.description
for description
.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:
How's that sound?
Sure, that sounds fine.
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.
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…

&lt;meta name="description" content="My meta description copy." /&gt;
&lt;meta property="og:description" content..." />
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 regularmeta name="description"
if nothing is specified otherwise viaWould be very nice to have, any pointers on how to achieve that?