This script will replace text with a keyword, geograpghy or related seo item on a page. It can be used for quick duplication of pages for a client. There are two versions, one for landing pages and one for seo optimized pages.

For SEO Pages

<script>
// Function to Capitalize the First Letter of Every Word
function titleCase(str) {
var splitStr = str.toLowerCase().split(' ');
for (var i = 0; i < splitStr.length; i++) {
// You do not need to check if i is larger than splitStr length, as your for does that for you
// Assign it back to the array
splitStr[i] = splitStr[i].charAt(0).toUpperCase() + splitStr[i].substring(1);
}
// Directly return the joined string
return splitStr.join(' ');
}
// Map the url to variables and assign each to a variable
var pathArray = window.location.pathname.split('/');
var TheStateL = pathArray[2];
var TheCityL = pathArray[3];
// Replace slashes with spaces
var TheCityS = TheCityL.replace(/-/g, ' ');
var TheStateS = TheStateL.replace(/-/g, ' ');
// Run the Capitalization Function and set keyword variables for City, State and City, State
var TheCityU = titleCase(TheCityS);
var TheStateU = titleCase(TheStateS);
var TheCityState = TheCityU + ", " + TheStateU;
// Set the title tag and description tag with dynamic keywords variables
var TheTitle = "Sell Your Unwanted " + TheCityState + " House - Get Fast Cash";
var TheDescription = "Local " + TheCityState + "home buyer. Sell unwanted property as is for fast cash. We purchase houses in any condition with no repairs necessary.";
// Replace text inside of classes with dynamic keyword data
$('.JHBCityState').html(TheCityState);
$('.JHBCity').html(TheCityU);
$('.JHBState').html(TheStateU);
$('.joeHomebuyerLocation').html(TheCityState);
// Change the title and description tags
document.title = TheTitle;
document.querySelector('meta[name="description"]').setAttribute("content", TheDescription);
</script>

For Landing Pages