import re with open("build.py", "r") as f: content = f.read() # Topics injection new_topics = """ {"slug": "software-engineers", "name": "Dad Jokes About Software Engineers", "emoji": "💻", "intro": "Did you hear about the programmer who got locked out of their house? They lost their keys! These software engineer dad jokes are fully debugged and ready to compile into instant groans.", "keywords": r"\\b(software|engineer|code|coding|programmer|dev|developer|bug|python|java|html|internet|wifi|tech)\\b"}, {"slug": "clean-dad-jokes-for-5-year-olds", "name": "Clean Dad Jokes for 5 Year Olds", "emoji": "👧", "intro": "Why did the toddler cross the playground? To get to the other slide! These clean dad jokes for 5-year-olds are kindergarten-approved and perfectly tailored for the juice-box crowd.", "keywords": r"\\b(kid|child|children|kindergarten|toddler|play|preschool|toy|five|5)\\b"}, """ content = content.replace(' {"slug": "eyes", "name": "Dad Jokes About Eyes"', new_topics + ' {"slug": "eyes", "name": "Dad Jokes About Eyes"') # Optimize page_topic CTR meta old_topic_meta = """ title = '%d+ Best %s (Clean Puns & Groaners for Kids & Family)' % (len(js), t['name']) desc = t['intro'] suffix = ' Browse %d clean, funny jokes.' % len(js)""" new_topic_meta = """ title = '%d+ Hilarious %s - Perfect for Groans & Laughs' % (len(js), t['name']) desc = 'Looking for %s? %s Guaranteed to make anyone roll their eyes. Read %d completely clean jokes now.' % (t['name'].lower(), t['intro'], len(js)) suffix = ''""" content = content.replace(old_topic_meta, new_topic_meta) # Update sitemap to ensure everything is perfect. Currently it has: # changefreq: weekly if '/', else 'monthly' # we can make topics and categories 'weekly' old_sitemap_gen = """ for p in pages: sm.append('%s%s%s%s%s' % (SITE_URL, p, today, 'weekly' if p == '/' else 'monthly', '1.0' if p == '/' else '0.8'))""" new_sitemap_gen = """ for p in pages: freq = 'weekly' if p == '/' or '/topic/' in p or '/category/' in p else 'monthly' pri = '1.0' if p == '/' else '0.9' if '/topic/' in p or '/category/' in p else '0.7' sm.append('%s%s%s%s%s' % (SITE_URL, p, today, freq, pri))""" content = content.replace(old_sitemap_gen, new_sitemap_gen) # Make the internal linking trap! We should link related categories and topics below the joke content randomly. # Currently page_joke has: #

More {esc(cat['name'])}

# old_page_joke = """

More {esc(cat['name'])}

\"\"\"""" new_page_joke = """

You Might Also Suffer From...

\"\"\"""" content = content.replace(old_page_joke, new_page_joke) with open("build.py", "w") as f: f.write(content)