Skip to content

Conversation

@solonovamax
Copy link
Contributor

@solonovamax solonovamax commented Dec 15, 2024

Summary

Improves/expands the meta tags for shared files.

  • Adds the following opengraph tags, depending on the file type
    • images:
      • og:image:type: the mimetype of the image file (TODO: should this be added for all shared files? all files will always have an og:image tag with either the preview or the nc logo)
    • audio:
      • og:audio: a direct link to the audio file
      • og:audio:type: the mimetype of the audio file
    • video:
      • og:video: a direct link to the video file
      • og:video:type: the mimetype of the video file
  • Updates the og:type tag from object (which is not a type that exists, as far as I can tell) to website
  • Adds meta tags for twitter
    • twitter:title: same as og:title
    • twitter:description: same as og:description
    • twitter:card: summary_large_image if the shared file is an image & it has a preview, otherwise summary
    • twitter:image: same as og:image

Before changes

Image

After changes

Note

I tested this on my personal self-hosted nextcloud, which is running nextcloud 29.0.10. I did this by just manually editing the apps/files_sharing/lib/DefaultPublicShareTemplateProvider.php file.

image

Checklist

@solracsf solracsf linked an issue Dec 15, 2024 that may be closed by this pull request
@solracsf

This comment was marked as resolved.

@solracsf solracsf added this to the Nextcloud 31 milestone Dec 15, 2024
@solracsf solracsf added the 3. to review Waiting for reviews label Dec 15, 2024
@solonovamax solonovamax force-pushed the master branch 2 times, most recently from dc9182d to 2a53ae7 Compare December 15, 2024 19:29
@solonovamax
Copy link
Contributor Author

Applied requested changes.

@solonovamax
Copy link
Contributor Author

solonovamax commented Dec 15, 2024

I've also added some additional changes to the opengraph meta tags. I will update the title/description in 15-20 with the additional changes.

Edit: updated

@solonovamax solonovamax changed the title Add Twitter Meta Tags Update & Expand Meta Tags Dec 15, 2024
@solonovamax
Copy link
Contributor Author

solonovamax commented Dec 15, 2024

oops, accidentally left in some funny formatting. I'll fix that in a bit.
Edit: fixed

other than that, the other failing checks seem to be either flaky tests, broken tests, or checks which won't run on forks.

Comment on lines +255 to +258
Util::addHeader('meta', ['property' => 'twitter:title', 'content' => $title]);
Util::addHeader('meta', ['property' => 'twitter:description', 'content' => $description]);
Util::addHeader('meta', ['property' => 'twitter:card', 'content' => $hasImagePreview ? 'summary_large_image' : 'summary']);
Util::addHeader('meta', ['property' => 'twitter:image', 'content' => $ogPreview]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we adding twitter specific tags? Can’t it read the standard tags?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we adding twitter specific tags? Can’t it read the standard tags?

It can, however imo it doesn't look as nice. yes, technically only the twitter:card tag is needed as it will fall back to the opengraph tags, however there is no harm in including them. (& there may be some services which only support the twitter tags, or if one of the twitter tags is present, it only uses twitter tags. unsure, as I have not tested this)

@solonovamax
Copy link
Contributor Author

Any updates on the review?

@github-actions
Copy link
Contributor

Hello there,
Thank you so much for taking the time and effort to create a pull request to our Nextcloud project.

We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process.

Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6

Thank you for contributing to Nextcloud and we hope to hear from you soon!

(If you believe you should not receive this message, you can add yourself to the blocklist.)

@blizzz blizzz mentioned this pull request Jan 8, 2025
This was referenced Jan 14, 2025
This was referenced Jan 21, 2025
@blizzz blizzz mentioned this pull request Jan 29, 2025
1 task
@blizzz blizzz removed this from the Nextcloud 31 milestone Jan 29, 2025
@blizzz blizzz added this to the Nextcloud 32 milestone Jan 29, 2025
@sorbaugh sorbaugh requested review from come-nc and solracsf February 14, 2025 15:01
@sorbaugh
Copy link
Contributor

Re-requesting reviews..

Adds the following twitter meta tags
- `twitter:card`: `summary_large_image` if the shared file is an image & it has a preview, otherwise `summary`
- `twitter:title`: same as `og:title`
- `twitter:description`: same as `og:description`
- `twitter:image`: same as `og:image`

Fixes nextcloud#49871

Signed-off-by: solonovamax <solonovamax@12oclockpoint.com>
…pengraph type to website

- Adds the following opengraph tags
  - images:
    - `og:image:type`: the mimetype of the image file
  - audio:
    - `og:audio`: a direct link to the audio file
    - `og:audio:type`: the mimetype of the audio file
  - video:
    - `og:video`: a direct link to the video file
    - `og:video:type`: the mimetype of the video file
- Changes th `og:type` meta tag from `object` (which is not valid) to `website`

Signed-off-by: solonovamax <solonovamax@12oclockpoint.com>
@sorbaugh sorbaugh merged commit 509a53c into nextcloud:master Feb 17, 2025
2 checks passed
@welcome
Copy link

welcome bot commented Feb 17, 2025

Thanks for your first pull request and welcome to the community! Feel free to keep them coming! If you are looking for issues to tackle then have a look at this selection: https://github.com/nextcloud/server/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22

@solonovamax
Copy link
Contributor Author

this was merged into 31.0.0, correct? bc on my nextcloud instance which is on version 31.0.7, I'm not seeing these changes

@susnux
Copy link
Contributor

susnux commented Aug 16, 2025

No its merged for Nextcloud 32 as you can see by the milestone
Screenshot_20250816_123245_Firefox

@solonovamax
Copy link
Contributor Author

No its merged for Nextcloud 32 as you can see by the milestone
Screenshot_20250816_123245_Firefox

ah, it doesn't show that to me on mobile, which is probably why. I could only see where it was mentioned, and it was only mentioned in PRs for nc 31

well, hopefully nc 32 will happen sometime soon, bc it'll make sharing nc links to other social media much nicer

@susnux
Copy link
Contributor

susnux commented Aug 17, 2025

well, hopefully nc 32 will happen sometime soon, bc it'll make sharing nc links to other social media much nicer

Yes: 2025-09-27
See also https://github.com/nextcloud/server/wiki/Maintenance-and-Release-Schedule#nextcloud-32

@nextcloud nextcloud locked as resolved and limited conversation to collaborators Aug 17, 2025
@skjnldsv skjnldsv modified the milestones: Nextcloud 32, Nextcloud 33 Sep 28, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Twitter Meta Tags

8 participants