Auto

 

/***************************************************


























* Kid2Design.com 2026 Content Engine


























* Production-Ready Google Apps Script


























***************************************************/




















































/**


























* ==============


























* CONFIGURATION


























* ==============


























*/




















































// TODO: Replace with your real API key (or store in Script Properties)


























const GEMINI_API_KEY = 'YOUR_GEMINI_API_KEY_HERE';


























const GEMINI_MODEL_NAME = 'gemini-2.0-flash';




















































// How many keywords to process per run when generating full blog content


























const BLOGS_PER_RUN = 5;




















































// Script Properties keys


























const PROP_BLOG_POINTER = 'BLOG_POINTER';




















































/**


























* =====================


























* CORE UTILITIES


























* =====================


























*/




















































/**


























* Reset (or create) a sheet with given name and header row.


























*


























* @param {string} name


























* @param {string[]} headers


























* @return {GoogleAppsScript.Spreadsheet.Sheet}


























*/


























function resetSheet(name, headers) {


























const ss = SpreadsheetApp.getActiveSpreadsheet();


























let sheet = ss.getSheetByName(name);


























if (sheet) {


























ss.deleteSheet(sheet);


























}


























sheet = ss.insertSheet(name);


























sheet.appendRow(headers);


























return sheet;


























}




















































/**


























* Batch write rows to a sheet starting at row 2 (keeping header row).


























*


























* @param {GoogleAppsScript.Spreadsheet.Sheet} sheet


























* @param {any[][]} rows


























*/


























function writeRowsBelowHeader(sheet, rows) {


























if (!rows || !rows.length) return;


























const startRow = 2;


























const startCol = 1;


























const numRows = rows.length;


























const numCols = rows[0].length;




















































sheet.getRange(startRow, startCol, numRows, numCols).setValues(rows);


























}




















































/**


























* Safely call Gemini API with text prompt.


























*


























* @param {string} prompt


























* @return {string} response text or error string


























*/


























function callGeminiAPI(prompt) {


























const url = `https://generativelanguage.googleapis.com/v1beta/models/${GEMINI_MODEL_NAME}:generateContent?key=${GEMINI_API_KEY}`;




















































const payload = {


























contents: [


























{


























parts: [{ text: prompt }]


























}


























],


























generationConfig: {


























temperature: 0.7,


























maxOutputTokens: 2500,


























topP: 0.9


























}


























};




















































const options = {


























method: 'post',


























contentType: 'application/json',


























payload: JSON.stringify(payload),


























muteHttpExceptions: true


























};




















































try {


























const response = UrlFetchApp.fetch(url, options);


























const json = JSON.parse(response.getContentText());




















































const text =


























json &&


























json.candidates &&


























json.candidates[0] &&


























json.candidates[0].content &&


























json.candidates[0].content.parts &&


























json.candidates[0].content.parts[0] &&


























json.candidates[0].content.parts[0].text;




















































if (text) {


























return text;


























}




















































const errMsg = json && json.error && json.error.message


























? json.error.message


























: 'Unknown API error';


























throw new Error(errMsg);


























} catch (e) {


























Logger.log('Gemini API error: ' + e.message);


























return 'ERROR: ' + e.message;


























}


























}




















































/**


























* Get or initialize a Script Property as integer.


























*


























* @param {string} key


























* @param {number} defaultValue


























* @return {number}


























*/


























function getIntProperty(key, defaultValue) {


























const props = PropertiesService.getScriptProperties();


























const val = props.getProperty(key);


























if (!val) return defaultValue;


























const n = parseInt(val, 10);


























return isNaN(n) ? defaultValue : n;


























}




















































/**


























* Set a Script Property as integer.


























*


























* @param {string} key


























* @param {number} value


























*/


























function setIntProperty(key, value) {


























const props = PropertiesService.getScriptProperties();


























props.setProperty(key, String(value));


























}




















































/**


























* =====================


























* BASE DATA ARRAYS


























* =====================


























*/




















































const STATES = [


























Alabama','Alaska','Arizona','Arkansas','California','Colorado','Connecticut','Delaware',


























Florida','Georgia','Hawaii','Idaho','Illinois','Indiana','Iowa','Kansas','Kentucky',


























Louisiana','Maine','Maryland','Massachusetts','Michigan','Minnesota','Mississippi',


























Missouri','Montana','Nebraska','Nevada','New Hampshire','New Jersey','New Mexico',


























New York','North Carolina','North Dakota','Ohio','Oklahoma','Oregon','Pennsylvania',


























Rhode Island','South Carolina','South Dakota','Tennessee','Texas','Utah','Vermont',


























Virginia','Washington','West Virginia','Wisconsin','Wyoming'


























];




















































const INDUSTRIES = [


























Real Estate','Restaurants','Retail','Healthcare','Finance','Construction','Legal',


























Education','Beauty & Wellness','Fitness','Ecommerce','SaaS','Fintech','Logistics',


























Automotive','Hospitality','Nonprofit','Manufacturing','Energy','Agriculture',


























Media & Entertainment','Travel','Telecom','Pharma','Biotech','Aerospace','Insurance',


























Franchise','Cleaning Services','Landscaping','Plumbing','Electricians','HVAC',


























Security Services','Pet Services','Grocery','Gaming','Photography','Events','Consulting',


























Accounting','Recruiting','Transportation','Analytics','AI & ML','Robotics','Fashion',


























Apparel','Childcare','Senior Care'


























];




















































const SERVICES = [


























web design','web development','app development','mobile app development','SEO services',


























local SEO','ecommerce development','branding','marketing strategy','content marketing',


























PPC management','social media management','email marketing','marketing automation',


























analytics & tracking','UX/UI design'


























];




















































const MODIFIERS = [


























best','affordable','professional','top','custom','small business','startup',


























enterprise','near me','2025'


























];




















































// Templates for keyword variation


























const KEYWORD_TEMPLATES = [


























{modifier} {service} for {industry} in {state}',


























{state} {industry} {service}',


























{service} agency in {state}',


























hire {modifier} {service} in {state}'


























];




















































/**


























* ================================================


























* 1) GENERATE SEO FOUNDATIONS FOR KID2DESIGN


























* ================================================


























*/




















































/**


























* Main function: builds the SEO foundation (keywords, calendar, schema, meta, architecture).


























*/


























function generateKid2DesignSEO() {


























const ss = SpreadsheetApp.getActiveSpreadsheet();




















































// ---------------------------


























// 1) 10,000 KEYWORD MASTER


























// ---------------------------


























const kwSheet = resetSheet('10000_Keyword_Master', [


























keyword', 'state', 'industry', 'service', 'modifier'


























]);




















































const keywordRows = [];


























let keywordCount = 0;


























const maxKeywords = 10000;




















































outerLoop:


























for (const state of STATES) {


























for (const industry of INDUSTRIES) {


























for (const service of SERVICES) {


























for (const modifier of MODIFIERS) {


























for (const template of KEYWORD_TEMPLATES) {


























const kw = template


























.replace('{service}', service)


























.replace('{industry}', industry)


























.replace('{state}', state)


























.replace('{modifier}', modifier);




















































keywordRows.push([kw, state, industry, service, modifier]);


























keywordCount++;


























if (keywordCount >= maxKeywords) {


























break outerLoop;


























}


























}


























}


























}


























}


























}




















































writeRowsBelowHeader(kwSheet, keywordRows);




















































// ---------------------------


























// 2) STATE-BY-STATE KEYWORDS


























// ---------------------------


























const stateSheet = resetSheet('State_By_State_Keywords', [


























state', 'keywords', 'count'


























]);




















































const stateRows = [];


























const perStateCount = 200;




















































STATES.forEach(state => {


























const kws = [];


























for (let i = 0; i < perStateCount; i++) {


























const svc = SERVICES[i % SERVICES.length];


























const kw = `${svc} in ${state}`;


























kws.push(kw);


























}


























stateRows.push([state, kws.join('; '), kws.length]);


























});




















































writeRowsBelowHeader(stateSheet, stateRows);




















































// ---------------------------


























// 3) CONTENT CALENDAR (52 WEEKS)


























// ---------------------------


























const calendarSheet = resetSheet('Content_Calendar', [


























week', 'topic', 'target_keyword', 'content_type', 'cta'


























]);




















































const calendarRows = [];


























for (let w = 1; w <= 52; w++) {


























const svc = SERVICES[w % SERVICES.length];


























calendarRows.push([


























w,


























`SEO & Web Growth Strategy Week ${w}`,


























svc,


























Blog Post',


























Book Free Consultation'


























]);


























}


























writeRowsBelowHeader(calendarSheet, calendarRows);




















































// ---------------------------


























// 4) SCHEMA MARKUP (JSON-LD)


























// ---------------------------


























const schemaSheet = resetSheet('Schema_Markup', [


























page', 'url', 'json_ld'


























]);




















































const servicePages = [


























Web Design',


























App Development',


























SEO Services',


























Marketing Strategy'


























];




















































const schemaRows = servicePages.map(page => {


























const jsonLd = {


























@context': 'https://schema.org',


























@type': 'Service',


























name: `Kid2Design ${page}`,


























provider: {


























@type': 'Organization',


























name: 'Kid2Design'


























},


























areaServed: 'US'


























};




















































const url = `https://kid2design.com/${page.toLowerCase().replace(/ /g, '-')}`;


























return [page, url, JSON.stringify(jsonLd)];


























});




















































writeRowsBelowHeader(schemaSheet, schemaRows);




















































// ---------------------------


























// 5) META TITLES & DESCRIPTIONS


























// ---------------------------


























const metaSheet = resetSheet('Meta_Descriptions', [


























page', 'url', 'meta_title', 'meta_description', 'primary_keyword'


























]);




















































const metaRows = [];




















































// Home


























metaRows.push([


























Home',


























https://kid2design.com',


























Kid2Design | Web, App & SEO Agency',


























Kid2Design builds websites, apps, and SEO strategies that grow businesses.',


























web design, app development, SEO agency'


























]);




















































// Services pages


























servicePages.forEach(p => {


























const slug = p.toLowerCase().replace(/ /g, '-');


























metaRows.push([


























p,


























`https://kid2design.com/${slug}`,


























`Kid2Design | ${p}`,


























`${p} services by Kid2Design for startups and growing businesses.`,


























`${p.toLowerCase()} services`


























]);


























});




















































writeRowsBelowHeader(metaSheet, metaRows);




















































// ---------------------------


























// 6) SITE ARCHITECTURE BLUEPRINT


























// ---------------------------


























const archSheet = resetSheet('Site_Architecture', [


























page', 'parent', 'url', 'template', 'primary_keyword'


























]);




















































const archRows = [];




















































// Home


























archRows.push([


























Home', '', 'https://kid2design.com', 'landing', 'kid2design'


























]);




















































// Services Parent


























archRows.push([


























Services', 'Home', '/services', 'landing', 'digital services'


























]);




















































// Individual service pages


























servicePages.forEach(p => {


























const slug = p.toLowerCase().replace(/ /g, '-');


























archRows.push([


























p,


























Services',


























`/services/${slug}`,


























service',


























`${p.toLowerCase()} services`


























]);


























});




















































writeRowsBelowHeader(archSheet, archRows);




















































SpreadsheetApp.flush();


























SpreadsheetApp.getUi().alert('Kid2Design SEO Foundation Generated Successfully!');


























}




















































/**


























* =======================================================


























* 2) AI CONTENT ARCHITECTURE (OUTLINES + HOOKS)


























* =======================================================


























*/




















































/**


























* Generates SEO-optimized outlines and social hooks


























* for Kid2Design based on the 10,000 Keyword sheet.


























*/


























function generateAIContentArchitecture() {


























const ss = SpreadsheetApp.getActiveSpreadsheet();


























const kwSheet = ss.getSheetByName('10000_Keyword_Master');




















































if (!kwSheet) {


























SpreadsheetApp.getUi().alert('Please run generateKid2DesignSEO() first to build the 10K keyword sheet.');


























return;


























}




















































let aiSheet = ss.getSheetByName('AI_Content_Briefs');


























if (aiSheet) {


























ss.deleteSheet(aiSheet);


























}


























aiSheet = ss.insertSheet('AI_Content_Briefs');




















































const headers = [


























Target Keyword',


























Suggested Blog Title',


























H2 Section Outlines',


























SGE/AI Answer (Key Takeaway)',


























Social Media Hook (X/LinkedIn)'


























];


























aiSheet.appendRow(headers);




















































// Get a sample of keywords (e.g., top 50) – adjust as needed


























const rowCount = Math.min(50, kwSheet.getLastRow() - 1);


























if (rowCount <= 0) {


























SpreadsheetApp.getUi().alert('No data found in 10000_Keyword_Master.');


























return;


























}




















































const data = kwSheet.getRange(2, 1, rowCount, 4).getValues();




















































const outputRows = data.map(row => {


























const kw = row[0];


























const state = row[1];


























const industry = row[2];


























const service = row[3];




















































const title = `Why ${industry} in ${state} need ${service} to Lead in 2026`;




















































const outlines = [


























`1. The Current State of ${industry} in ${state}`,


























`2. How ${service} Solves Modern Business Pain Points`,


























`3. 2026 Trends: AI & Automation in ${service}`,


























`4. Case Study: ROI of Professional Design for ${industry}`,


























5. Choosing a Local Partner: Why Kid2Design?'


























].join('\n');




















































const aiAnswer =


























`${industry} businesses in ${state} can increase conversion by up to 40% ` +


























`through ${service} that focuses on mobile-first speed and AI-ready schema. ` +


























`Kid2Design specializes in these technical deployments.`;




















































const socialHook =


























`🚨 ${state} ${industry} Owners: Still using a 2023 website? ` +


























`You’re losing 2026 customers. Here is how ${service} is changing the game this year. ` +


























`#Kid2Design #${industry.replace(/\s+/g, '')}SEO #${state.replace(/\s+/g, '')}Business`;




















































return [kw, title, outlines, aiAnswer, socialHook];


























});




















































writeRowsBelowHeader(aiSheet, outputRows);





















































Comments