- Description for listing page, in plain text, only a couple of lines. (max 140 characters)
+ Google currently displays 155-160 characters of the meta description in the search result. You can also check the previews for Facebook and Twitter using their debugger tools.
diff --git a/frappe/website/doctype/blog_post/blog_post.py b/frappe/website/doctype/blog_post/blog_post.py
index f71f1d3d5b..e9785855f4 100644
--- a/frappe/website/doctype/blog_post/blog_post.py
+++ b/frappe/website/doctype/blog_post/blog_post.py
@@ -66,22 +66,17 @@ class BlogPost(WebsiteGenerator):
context.content = get_html_content_based_on_type(self, 'content', self.content_type)
- if self.meta_description:
- context.description = self.meta_description
- else:
- context.description = self.blog_intro or strip_html_tags(context.content[:140])
-
+ #if meta description is not present, then blog intro or first 140 characters of the blog will be set as description
+ context.description["description"] = self.meta_description or self.blog_intro or strip_html_tags(context.content[:140])
+
context.metatags = {
"name": self.title,
"description": context.description,
}
+ #if meta image is not present, then first image inside the blog will be set as so
image = find_first_image(context.content)
- if self.meta_image:
- context.metatags["image"] = self.meta_image
- else:
- context.metatags["image"] = image
-
+ context.metatags["image"] = self.meta_image or image
self.load_comments(context)
From 9a40383ebf0bbdffb17a40d8fbd4bc26b95bdf4b Mon Sep 17 00:00:00 2001
From: Kenneth Sequeira
Date: Fri, 24 Apr 2020 18:28:31 +0530
Subject: [PATCH 11/62] cleanups
---
frappe/website/doctype/blog_post/blog_post.js | 3 ++-
frappe/website/doctype/blog_post/blog_post.py | 2 +-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/frappe/website/doctype/blog_post/blog_post.js b/frappe/website/doctype/blog_post/blog_post.js
index 955ffcd113..5c5308a115 100644
--- a/frappe/website/doctype/blog_post/blog_post.js
+++ b/frappe/website/doctype/blog_post/blog_post.js
@@ -27,7 +27,7 @@ function generate_google_search_preview(frm){
-
+
@@ -47,6 +47,7 @@ function generate_google_search_preview(frm){
+
Google currently displays 155-160 characters of the meta description in the search result. You can also check the previews for Facebook and Twitter using their debugger tools.
diff --git a/frappe/website/doctype/blog_post/blog_post.py b/frappe/website/doctype/blog_post/blog_post.py
index e9785855f4..100b55a362 100644
--- a/frappe/website/doctype/blog_post/blog_post.py
+++ b/frappe/website/doctype/blog_post/blog_post.py
@@ -74,7 +74,7 @@ class BlogPost(WebsiteGenerator):
"description": context.description,
}
- #if meta image is not present, then first image inside the blog will be set as so
+ #if meta image is not present, then first image inside the blog will be set as the meta image
image = find_first_image(context.content)
context.metatags["image"] = self.meta_image or image
From a50f8318314f1a4810d483a5b55f2a0293227e67 Mon Sep 17 00:00:00 2001
From: Kenneth Sequeira
Date: Fri, 24 Apr 2020 18:52:15 +0530
Subject: [PATCH 12/62] fix deadlock issue
---
frappe/website/doctype/blog_post/blog_post.js | 2 +-
frappe/website/doctype/blog_post/blog_post.py | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/frappe/website/doctype/blog_post/blog_post.js b/frappe/website/doctype/blog_post/blog_post.js
index 5c5308a115..a5aacc06bd 100644
--- a/frappe/website/doctype/blog_post/blog_post.js
+++ b/frappe/website/doctype/blog_post/blog_post.js
@@ -16,7 +16,7 @@ frappe.ui.form.on('Blog Post', {
}
});
function generate_google_search_preview(frm){
- frm.call('get_url').then((r)=>{
+ frm.call('get_site_url').then((r)=>{
let google_preview = frm.get_field("google_preview");
let seo_title = (frm.doc.title).slice(0, 60);
let seo_description = (frm.doc.meta_description || frm.doc.blog_intro || "").slice(0, 160);
diff --git a/frappe/website/doctype/blog_post/blog_post.py b/frappe/website/doctype/blog_post/blog_post.py
index 100b55a362..3e6ce3f1c8 100644
--- a/frappe/website/doctype/blog_post/blog_post.py
+++ b/frappe/website/doctype/blog_post/blog_post.py
@@ -97,7 +97,7 @@ class BlogPost(WebsiteGenerator):
else:
context.comment_text = _('{0} comments').format(len(context.comment_list))
- def get_url(self):
+ def get_site_url(self):
return frappe.utils.get_url()
def get_list_context(context=None):
From dcdc0d0e90311169527392a8a4c5602aea73314e Mon Sep 17 00:00:00 2001
From: Kenneth Sequeira
Date: Fri, 24 Apr 2020 19:46:40 +0530
Subject: [PATCH 13/62] improve description
---
frappe/website/doctype/blog_post/blog_post.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/frappe/website/doctype/blog_post/blog_post.js b/frappe/website/doctype/blog_post/blog_post.js
index a5aacc06bd..c40bf7cbe0 100644
--- a/frappe/website/doctype/blog_post/blog_post.js
+++ b/frappe/website/doctype/blog_post/blog_post.js
@@ -49,7 +49,7 @@ function generate_google_search_preview(frm){
- Google currently displays 155-160 characters of the meta description in the search result. You can also check the previews for Facebook and Twitter using their debugger tools.
+ This is a test preview based on the meta description generated for this blog. The description can be of any length but Google will truncate it to 155 - 160 characters. You can also check the previews for Facebook and Twitter using their debugger tools.
From 51dfe2971b3b9a47cc6cdbad2ea58f3d8e170dab Mon Sep 17 00:00:00 2001
From: Shivam Mishra
Date: Mon, 27 Apr 2020 15:36:00 +0530
Subject: [PATCH 14/62] feat: rename section and added description to preview
section
---
frappe/website/doctype/blog_post/blog_post.json | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/frappe/website/doctype/blog_post/blog_post.json b/frappe/website/doctype/blog_post/blog_post.json
index f4f66c95ea..18e00e7905 100644
--- a/frappe/website/doctype/blog_post/blog_post.json
+++ b/frappe/website/doctype/blog_post/blog_post.json
@@ -133,7 +133,7 @@
{
"fieldname": "seo_section",
"fieldtype": "Section Break",
- "label": "SEO Section"
+ "label": "SEO"
},
{
"fieldname": "meta_description",
@@ -150,11 +150,12 @@
"label": "Meta Image"
},
{
+ "description": "This is a test preview based on the meta description generated for this blog. The description can be of any length but Google will truncate it to 155 - 160 characters. You can also check the previews for Facebook and Twitter using their debugger tools. ",
"fieldname": "section_break_20",
- "fieldtype": "Section Break"
+ "fieldtype": "Section Break",
+ "label": "Google Search Preview"
},
{
- "description": "This is an example Google SERP Preview.",
"fieldname": "google_preview",
"fieldtype": "HTML",
"label": "Google Snippet Preview",
@@ -167,7 +168,7 @@
"is_published_field": "published",
"links": [],
"max_attachments": 5,
- "modified": "2020-04-22 20:07:37.324345",
+ "modified": "2020-04-27 15:12:02.179731",
"modified_by": "Administrator",
"module": "Website",
"name": "Blog Post",
From fd15d2608cfbdce7f867ce85f8191ca8246ca293 Mon Sep 17 00:00:00 2001
From: Shivam Mishra
Date: Mon, 27 Apr 2020 15:36:14 +0530
Subject: [PATCH 15/62] refactor: clean html for preview
---
frappe/website/doctype/blog_post/blog_post.js | 56 +++++++------------
1 file changed, 19 insertions(+), 37 deletions(-)
diff --git a/frappe/website/doctype/blog_post/blog_post.js b/frappe/website/doctype/blog_post/blog_post.js
index c40bf7cbe0..dea86b3b27 100644
--- a/frappe/website/doctype/blog_post/blog_post.js
+++ b/frappe/website/doctype/blog_post/blog_post.js
@@ -16,44 +16,26 @@ frappe.ui.form.on('Blog Post', {
}
});
function generate_google_search_preview(frm){
- frm.call('get_site_url').then((r)=>{
- let google_preview = frm.get_field("google_preview");
- let seo_title = (frm.doc.title).slice(0, 60);
- let seo_description = (frm.doc.meta_description || frm.doc.blog_intro || "").slice(0, 160);
+ let google_preview = frm.get_field("google_preview");
+ let seo_title = (frm.doc.title).slice(0, 60);
+ let seo_description = (frm.doc.meta_description || frm.doc.blog_intro || "").slice(0, 160);
+ let date = frm.doc.published_on ? new frappe.datetime.datetime(frm.doc.published_on).moment.format('ll') + ' - ' : '';
+ let route_array = frm.doc.route.split('/');
+ route_array.pop();
- google_preview.html(`
-
-
-
- This is a test preview based on the meta description generated for this blog. The description can be of any length but Google will truncate it to 155 - 160 characters. You can also check the previews for Facebook and Twitter using their debugger tools.
-