Karenlara Posted November 6, 2021 Share Posted November 6, 2021 Site URL: https://www.almendritasabia.com/blog/la-adiccion-es-una-enfermedad Hello, I added a reading time to my blog posts, thanks to this article I saw online: https://www.maryphilip.com/the-blog/how-to-add-a-reading-time-to-your-squarespace-blog I don't want to have to add a code block to each single post. So I followed the following instructions: 1. To add to all blogs, go to the Blog’s Page Settings, click Post Blog Item Code Injection and add the following: Copy Code <div class="reading-time"></div> 2. Go to Settings > Advanced > Code Injection and paste the following into the Header: Copy Code <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script> <script> $(function () { var txt = $("article")[0].textContent, wordCount = txt.replace( /[^\w ]/g, "" ).split( /\s+/ ).length; var readingTimeInMinutes = Math.floor(wordCount / 228) + 1; var readingTimeAsString = readingTimeInMinutes + " min"; $('article .reading-time').html(readingTimeAsString); }); </script> 3. Change the design to your liking. Go to Design, click Custom CSS, and paste the following: Copy Code .reading-time { text-align: center; font-size: 18px; font-family: 'Playfair Display' } To add text before the time count, adapt the content with this CSS to your liking: Copy Code .reading-time:before { content: 'Reading Time:'; margin-right: 3px; } (I changed a little of the CSS) So it appears at the bottom. And I was wondering if it's possible to move it under the blog title? TThank you! 🙂 Link to comment
Solution Beyondspace Posted November 7, 2021 Solution Share Posted November 7, 2021 9 hours ago, Karenlara said: Site URL: https://www.almendritasabia.com/blog/la-adiccion-es-una-enfermedad Hello, I added a reading time to my blog posts, thanks to this article I saw online: https://www.maryphilip.com/the-blog/how-to-add-a-reading-time-to-your-squarespace-blog I don't want to have to add a code block to each single post. So I followed the following instructions: 1. To add to all blogs, go to the Blog’s Page Settings, click Post Blog Item Code Injection and add the following: Copy Code <div class="reading-time"></div> 2. Go to Settings > Advanced > Code Injection and paste the following into the Header: Copy Code <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script> <script> $(function () { var txt = $("article")[0].textContent, wordCount = txt.replace( /[^\w ]/g, "" ).split( /\s+/ ).length; var readingTimeInMinutes = Math.floor(wordCount / 228) + 1; var readingTimeAsString = readingTimeInMinutes + " min"; $('article .reading-time').html(readingTimeAsString); }); </script> 3. Change the design to your liking. Go to Design, click Custom CSS, and paste the following: Copy Code .reading-time { text-align: center; font-size: 18px; font-family: 'Playfair Display' } To add text before the time count, adapt the content with this CSS to your liking: Copy Code .reading-time:before { content: 'Reading Time:'; margin-right: 3px; } (I changed a little of the CSS) So it appears at the bottom. And I was wondering if it's possible to move it under the blog title? TThank you! 🙂 You can add to Home > Settings > Advanced > Code Injection <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script> <script> $(function () { var txt = $("article")[0].textContent, wordCount = txt.replace( /[^\w ]/g, "" ).split( /\s+/ ).length; var readingTimeInMinutes = Math.floor(wordCount / 228) + 1; var readingTimeAsString = readingTimeInMinutes + " min"; $('article .reading-time').appendTo('article .blog-item-title'); $('article .reading-time').html(readingTimeAsString); }); </script> Let me know how it works on your site Support me by pressing 👍 if this useful for you tuanphan 1 BeyondSpace - Squarespace Website Developer 🖼️ Lightbox Studio (Enable Pinch/Zoom on lightbox, video lightbox and much more) 🗓️ Delivery Date Picker (Squarespace Date picker form field) 💫 Gallery block 7.1 workaround 🥳 No-code customisations for Squarespace 🚀 Learn how to rank new pages on Google in 48 hours! If you find my answer useful, let's leave a like or upvote so others with the same issue can find their solution. Thank you! Link to comment
Beyondspace Posted November 7, 2021 Share Posted November 7, 2021 My testing result BeyondSpace - Squarespace Website Developer 🖼️ Lightbox Studio (Enable Pinch/Zoom on lightbox, video lightbox and much more) 🗓️ Delivery Date Picker (Squarespace Date picker form field) 💫 Gallery block 7.1 workaround 🥳 No-code customisations for Squarespace 🚀 Learn how to rank new pages on Google in 48 hours! If you find my answer useful, let's leave a like or upvote so others with the same issue can find their solution. Thank you! Link to comment
Karenlara Posted November 7, 2021 Author Share Posted November 7, 2021 Thank you soo much! Worked great ☺️ Link to comment
LauraLemon Posted December 27, 2021 Share Posted December 27, 2021 This answer just worked for me too, thank you! Beyondspace 1 Link to comment
recoveringlazyholic Posted March 4, 2022 Share Posted March 4, 2022 @bangank36 I also used the same code provided by Mary Philip. I'm using Brine and the read time appears at the top of each blog post (above the category and title - not desired but I can live with it) but ALSO above each post in the main gallery blog home page. Do you know how to hide the read time from the gallery view? Link to comment
Beyondspace Posted March 5, 2022 Share Posted March 5, 2022 6 hours ago, recoveringlazyholic said: @bangank36 I also used the same code provided by Mary Philip. I'm using Brine and the read time appears at the top of each blog post (above the category and title - not desired but I can live with it) but ALSO above each post in the main gallery blog home page. Do you know how to hide the read time from the gallery view? Can you share the link to this page so I can take a look? BeyondSpace - Squarespace Website Developer 🖼️ Lightbox Studio (Enable Pinch/Zoom on lightbox, video lightbox and much more) 🗓️ Delivery Date Picker (Squarespace Date picker form field) 💫 Gallery block 7.1 workaround 🥳 No-code customisations for Squarespace 🚀 Learn how to rank new pages on Google in 48 hours! If you find my answer useful, let's leave a like or upvote so others with the same issue can find their solution. Thank you! Link to comment
recoveringlazyholic Posted March 6, 2022 Share Posted March 6, 2022 @bangank36 sure! you'll see there is "1 minute" above each image, which I assume is the estimated time based on the excerpt. https://www.recoveringlazyholic.com/blog Link to comment
tuanphan Posted March 10, 2022 Share Posted March 10, 2022 On 3/7/2022 at 5:23 AM, recoveringlazyholic said: @bangank36 sure! you'll see there is "1 minute" above each image, which I assume is the estimated time based on the excerpt. https://www.recoveringlazyholic.com/blog Add to Design > Custom CSS /* hide reading time from list view */ body.view-list .reading-time { display: none; } Beyondspace 1 Email me if you have need any help (free, of course.). Answer within 24 hours. Or send to forum message Contact Customer Care - Learn CSS - Buy me a coffee (thank you!) Link to comment
recoveringlazyholic Posted March 10, 2022 Share Posted March 10, 2022 @tuanphan Brilliant -- thank you! That worked perfectly. You guys are Squarespace heroes. Link to comment
rachella Posted April 26, 2022 Share Posted April 26, 2022 Hi everyone - I've just followed these same steps but something isn't working right. I can see the 'reading time' in the footer of the front page (see attached image) - can someone tell me why this would be happening? The site is: www.eventplanningtemplates.co thanks! Rachella Link to comment
tuanphan Posted April 27, 2022 Share Posted April 27, 2022 On 4/26/2022 at 7:08 AM, rachella said: Hi everyone - I've just followed these same steps but something isn't working right. I can see the 'reading time' in the footer of the front page (see attached image) - can someone tell me why this would be happening? The site is: www.eventplanningtemplates.co thanks! Rachella You added this code to Code Injection <div class="reading-time"></div> I think you should add it to Blog Page Page Header Email me if you have need any help (free, of course.). Answer within 24 hours. Or send to forum message Contact Customer Care - Learn CSS - Buy me a coffee (thank you!) Link to comment
rachella Posted May 3, 2022 Share Posted May 3, 2022 On 4/27/2022 at 5:57 PM, tuanphan said: You added this code to Code Injection <div class="reading-time"></div> I think you should add it to Blog Page Page Header Thanks for responding. It still isn't working. If I take the code out of the Code Injection (Footer) and place it in the BlogPage Header Code Injection - it shows at the top of the page - see image - and it doesn't show on the blog. If I put the code in Post Blog Item Code Injection then it disappears completely. I am using Brine template and the instructions were to put this in the general Code Injection. <!-- Start of Blog Post Reading Time ----------------> <div class="reading-time"></div> <script> $( ".reading-time" ).insertBefore ( "h1.BlogItem-title" ); </script> <!-- End of Blog Post Reading Time ----------------> Link to comment
AnotherRandomDisplayName1 Posted April 4, 2023 Share Posted April 4, 2023 Hello, I followed the instructions here: https://forum.squarespace.com/topic/207845-move-reading-time-under-blog-title/ to successfully add "reading time" to my blog post. Yay! However, I would also like to add "reading time" to the general blog page. The page that houses all the blogs written. Anyone have any advice on how to this? Thank you so much in advance. Link to comment
DevonHarris Posted April 28, 2023 Share Posted April 28, 2023 Hi guys, is there a way to add this to the metadata when the blog is viewed in a summary block? Like this: McFlystrodamus 1 Link to comment
SpeedReader26 Posted May 10, 2023 Share Posted May 10, 2023 Does anyone know how to do this on 7.1? I can't get it to work. I would also like to add it to my titles on my blog home page, if anyone knows how to do that. Thanks! Link to comment
McFlystrodamus Posted March 28 Share Posted March 28 (edited) @SpeedReader26 I have 7.1 and it worked flawlessly. Two Codes Add this to the main blog settings > click the gear icon> select advanced > Post Blog Item Code Injection <div class="reading-time"></div> Don't forget to save. Second code: Website tools > Code Injection > Header: <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script> <script> $(function () { var txt = $("article")[0].textContent, wordCount = txt.replace( /[^\w ]/g, "" ).split( /\s+/ ).length; var readingTimeInMinutes = Math.floor(wordCount / 228) + 1; var readingTimeAsString = readingTimeInMinutes + " min"; $('article .reading-time').appendTo('article .blog-item-title'); $('article .reading-time').html(readingTimeAsString); }); </script> That should do the trick. Edited March 28 by McFlystrodamus Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment