We'd like to truncate the description with a very specific character count. The name=length value=short or long parameters are to restrictive and the chosen text is poor as it is based on the search results order hierarchy (see below).
Length
How can we select a very specific character counter to return in the description? Also it would need to always truncate at a complete word.
Text
As it stands the selected text for the search result is not always the from the blog content.
For instance, if the search result is returned because it was a Meta description (see #2 below), the returned text is the meta description and then the blog content.
We need to returned desciption to alway be the blog content. Essentially this will be the first sentence or so of the blog post body.
This relates to the search results order hierarchy...
Unfortunately I can't speak to the search functiuonality. Maybe someone from hubspot can weigh in.
But for you truncation I'd double chek the hubspot docs, I know a few features do include truncations. If its not avaliable it might be worth looking into a jQuery script or plugin. Here are a few.
Below I've created a jQuery function that'll truncate the text for you. Its been annotated for ease of use. As a best practice I would remove the comments when publishing, but its not necessary.
$(document).ready(function(){ var target = $('.para'), //Define the element you with to target here truncLength = 15;//Set the length you would like here
target.each(function() {//Loop through all target elements console.log(this);//Console log to ensure youre targeting correctly var string = this.innerHTML;//Get the current targets text if (string.length <= truncLength) {//If the length of the text string is less than or equal to the truncLenght, skip the truncation step //Do nothing } else { string = string.substring(0, truncLength) + "…";//Truncate the targets text starting at position 0 console.log(string);// Console log the new value this.innerHTML = string;//Update the DOM with the new text string } }); });