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

description content for optimised social sharing #184

Closed
techievivek opened this issue Feb 21, 2020 · 17 comments · Fixed by #212
Closed

description content for optimised social sharing #184

techievivek opened this issue Feb 21, 2020 · 17 comments · Fixed by #212
Assignees
Labels
help wanted Open to participation from the community

Comments

@techievivek
Copy link
Contributor

techievivek commented Feb 21, 2020

Problem Description

Add the description content to be shown while sharing the link on Facebook and Twitter.
image-preview

From the above image, you can see the description part is missing. Only the title and image are shown.

Solution Description

I have already added the image preview feature the only thing that is lacking is the description part that will be shown when any link will be shared.

Helping Hands

You can get the content part of a page/post and then first strip HTML tags to convert into plain text and then get the first 20 words or so to be used in the description part.
Some plugins that you can play with strip-html-tags and markdown-excerpt

Note

Please don't add new fields, use the one that are already implemented, read more about it here

@techievivek
Copy link
Contributor Author

@kgodey Mam, Please add labels to this issue so that somebody can take it.

@kgodey kgodey added the help wanted Open to participation from the community label Feb 24, 2020
@kgodey
Copy link
Member

kgodey commented Feb 24, 2020

thanks for creating this @techievivek

@nik-gautam
Copy link

Can I work on this issue?

@techievivek
Copy link
Contributor Author

@nik-gautam go ahead.

@nik-gautam
Copy link

@techievivek where can I find the latest code with the previous image fixes that you made?

Thanks.

@techievivek
Copy link
Contributor Author

@nik-gautam Check here #183

@techievivek
Copy link
Contributor Author

@kgodey Can't we use JavaScript here too to add meta description once the DOM content is loaded rather then going for plugins to strip HTML and get excerpt.
It will be easy to implement.
I have gone through some articles on setting meta data using JS, if we can do before the page loads fully there won't be an issue.
We will wait for @nik-gautam if he has any other plans for same.

@kgodey
Copy link
Member

kgodey commented Feb 26, 2020

@techievivek could you link the articles you read here?

@nik-gautam
Copy link

nik-gautam commented Feb 27, 2020

@techievivek I think will be easier to use javascript.
Till now, I have been trying to fix the issue with strip-html-tags plugin.

A problem that I faced was where to get the info from, because as far I saw there is no common p-tag or any other tag that every page has (which contains the info we want to display), so a common script cannot be ran for all.

Also, my mid-sem exams are going on right now, it will take me a few days to really start coding.

Sorry for the delay.

@techievivek
Copy link
Contributor Author

@kgodey Here is one they are doing using Jquery https://stackoverflow.com/questions/9231845/javascript-to-change-metadata-metatags-dynamically
(I have not tested this myself for now). There are some speculations that FB doesn't run JS code. And I have gone through some articles looking for its effect on SEO, but luckily google crawlers can run JavaScript.
Here is from their official developer website:- https://developers.google.com/search/docs/guides/javascript-seo-basics
And here is a report generated by searchengineland team https://searchengineland.com/tested-googlebot-crawls-javascript-heres-learned-220157

@techievivek
Copy link
Contributor Author

techievivek commented Feb 27, 2020

@nik-gautam All the post/page have content stored in content folder, we can use frontend html-stripping and get first 20 words to be part of meta description tag.
When we do html-stripping it will take care and will return us just the text content.
This is not recommended method as there are speculations that FB wont run JS code, so we will have to test it locally first.

@techievivek
Copy link
Contributor Author

techievivek commented Feb 27, 2020

@nik-gautam @kgodey It might not be possible with JS https://stackoverflow.com/questions/25420887/does-facebook-crawler-currently-interpret-javascript-before-parsing-the-dom
I will try then locally and will confirm by today. Also if this doesn't we will see for alternate with lektor itself.

@nik-gautam
Copy link

@techievivek js won't work with Facebook crawler...

I did some research, it turns out that fb gets the data by crawling and looking for og meta tags, before loading the DOM. So, any changes via JavaScript on DOM won't work.

Data has to added before generating the static HTML files in lektor.

@techievivek
Copy link
Contributor Author

@nik-gautam Yes, I tested it, it's not working. Try doing it with lektor plugins itself.

@nik-gautam
Copy link

@techievivek @kgodey I have somewhat fixed the issue.

https://github.com/nik-gautam/creativecommons.github.io-source/tree/description_for_social_media_sharing

Can you check it before I make a PR?

@nik-gautam
Copy link

@kgodey @techievivek
Please take a look at this PR.

@techievivek
Copy link
Contributor Author

@nik-gautam It's good. If possible please add a screenshot so that it will easy to see the end result. @kgodey will be available after Tuesday till then you can look for other issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Open to participation from the community
Projects
None yet
3 participants