diff --git a/build.py b/build.py
index c6db37ca..e3c99307 100644
--- a/build.py
+++ b/build.py
@@ -206,6 +206,22 @@ TOPICS = [
]
MIN_TOPIC_JOKES = 5
+def _compute_topic_data():
+ pat_map = {t['slug']: re.compile(t['keywords']) for t in TOPICS}
+ t_jokes = {}
+ joke_topics = {j['id']: [] for j in JOKES}
+ for t in TOPICS:
+ pat = pat_map[t['slug']]
+ matching = [j for j in JOKES if pat.search((j['setup'] + ' ' + j['punch']).lower())]
+ t_jokes[t['slug']] = matching
+ live = [t for t in TOPICS if len(t_jokes[t['slug']]) >= MIN_TOPIC_JOKES]
+ for t in live:
+ for j in t_jokes[t['slug']]:
+ joke_topics[j['id']].append(t)
+ return t_jokes, live, joke_topics
+
+TOPIC_JOKES_MAP, LIVE_TOPICS, JOKE_TOPICS_MAP = _compute_topic_data()
+
def esc(s):
return html.escape(s, quote=True)
@@ -242,7 +258,7 @@ def layout(title, desc, body, path='/', extra_head=''):
'%s %s' % (c['slug'], c['emoji'], esc(c['name']))
for c in CATS)
foot_cats = ''.join('%s' % (c['slug'], esc(c['name'])) for c in CATS)
- live_topics_nav = [t for t in TOPICS if len(topic_jokes(t)) >= MIN_TOPIC_JOKES]
+ live_topics_nav = LIVE_TOPICS
foot_topics = ''.join('%s' % (t['slug'], esc(t['name'])) for t in live_topics_nav[:16])
return f"""
@@ -550,7 +566,7 @@ def page_index():
d_idx = datetime.date.today().toordinal()
jod = JOKES[d_idx % len(JOKES)]
latest = JOKES[-12:][::-1]
- live_topics = [t for t in TOPICS if len(topic_jokes(t)) >= MIN_TOPIC_JOKES]
+ live_topics = LIVE_TOPICS
topic_chips = ''.join('%s %s' % (
t['slug'], t['emoji'], esc(t['name'].replace('Dad Jokes About ', '').replace('Dad Jokes', 'Jokes')))
for t in live_topics)
@@ -640,9 +656,8 @@ def page_category(slug):
# Internal link loop: related topic clusters that overlap with this category
cat_topics = [
- t for t in TOPICS
- if len(topic_jokes(t)) >= MIN_TOPIC_JOKES and
- any(j['cat'] == slug for j in topic_jokes(t))
+ t for t in LIVE_TOPICS
+ if any(j['cat'] == slug for j in topic_jokes(t))
][:6]
topics_html = ''.join('%s %s' % (t['slug'], t['emoji'], esc(t['name'])) for t in cat_topics)
topic_section = f'
Explore Related Joke Topics
{topics_html}
' if topics_html else ''
@@ -688,8 +703,8 @@ def page_category(slug):
def topic_jokes(topic):
- pat = re.compile(topic['keywords'])
- return [j for j in JOKES if pat.search((j['setup'] + ' ' + j['punch']).lower())]
+ slug = topic['slug'] if isinstance(topic, dict) else topic
+ return TOPIC_JOKES_MAP.get(slug, [])
def page_topic(slug):
@@ -698,7 +713,7 @@ def page_topic(slug):
if len(js) < MIN_TOPIC_JOKES:
return None
cards = ''.join(joke_card(j) for j in js)
- live_topics = [o for o in TOPICS if len(topic_jokes(o)) >= MIN_TOPIC_JOKES]
+ live_topics = LIVE_TOPICS
t_idx = next(i for i, o in enumerate(live_topics) if o['slug'] == slug)
prev_t = live_topics[(t_idx - 1) % len(live_topics)]
next_t = live_topics[(t_idx + 1) % len(live_topics)]
@@ -733,7 +748,7 @@ def page_topic(slug):
@@ -827,11 +842,10 @@ def page_generator():
def page_joke(j):
cat = CAT_BY_SLUG[j['cat']]
# Determine matching topic clusters for internal linking (fallback to general topics so no dead-ends):
- matching_topics = [t for t in TOPICS if len(topic_jokes(t)) >= MIN_TOPIC_JOKES and re.search(t['keywords'], (j['setup'] + ' ' + j['punch']).lower())][:3]
+ matching_topics = JOKE_TOPICS_MAP.get(j['id'], [])[:3]
if not matching_topics:
# Guaranteed loop: pick 3 consistent live topics based on joke ID
- live_topics = [t for t in TOPICS if len(topic_jokes(t)) >= MIN_TOPIC_JOKES]
- matching_topics = [live_topics[(j['id'] + offset * 7) % len(live_topics)] for offset in range(3)]
+ matching_topics = [LIVE_TOPICS[(j['id'] + offset * 7) % len(LIVE_TOPICS)] for offset in range(3)]
topic_chips = ''.join('%s %s' % (t['slug'], t['emoji'], esc(t['name'])) for t in matching_topics)
topic_section = f'
Explore Related Topics:
{topic_chips}
' if topic_chips else ''
@@ -1141,7 +1155,7 @@ def build():
pages = ['/', '/blog/', '/dad-joke-generator/', '/joke-of-the-day/', '/search/', '/about/', '/contact/',
'/privacy-policy/', '/terms/', '/best-dad-gifts/'] + ['/blog/%s/' % a['slug'] for a in BLOG_ARTICLES] \
+ ['/category/%s/' % c['slug'] for c in CATS] \
- + ['/topic/%s/' % t['slug'] for t in TOPICS if len(topic_jokes(t)) >= MIN_TOPIC_JOKES] + ['/joke/%s/' % j['id'] for j in JOKES]
+ + ['/topic/%s/' % t['slug'] for t in LIVE_TOPICS] + ['/joke/%s/' % j['id'] for j in JOKES]
robots_content = """# robots.txt for bestdadjokes.lol
User-agent: *
Allow: /
@@ -1173,7 +1187,7 @@ Sitemap: %s/sitemap.xml
> The best dad jokes on the internet — short, clean, groan-worthy, and 100% family-friendly.
-Best Dad Jokes provides over {len(JOKES)} hand-curated, school-safe dad jokes, puns, and holiday one-liners organized across {len(CATS)} categories and {len([t for t in TOPICS if len(topic_jokes(t)) >= MIN_TOPIC_JOKES])} targeted topic clusters. All jokes are formatted for high clarity, instant reading, and family entertainment.
+Best Dad Jokes provides over {len(JOKES)} hand-curated, school-safe dad jokes, puns, and holiday one-liners organized across {len(CATS)} categories and {len(LIVE_TOPICS)} targeted topic clusters. All jokes are formatted for high clarity, instant reading, and family entertainment.
## Core Hubs & Curated Lists
diff --git a/site/api/v1/random.json b/site/api/v1/random.json
index cdaab674..52a3cb60 100644
--- a/site/api/v1/random.json
+++ b/site/api/v1/random.json
@@ -1 +1 @@
-{"setup": "What do snowmen call their offspring?", "punchline": "Chill-dren.", "type": "qa", "category": "weather", "source": "https://bestdadjokes.lol/category/weather/#joke-152"}
\ No newline at end of file
+{"setup": "What's red and bad for your teeth?", "punchline": "A brick.", "type": "line", "category": "one-liners", "source": "https://bestdadjokes.lol/category/one-liners/#joke-266"}
\ No newline at end of file
diff --git a/site/rss.xml b/site/rss.xml
index fb767f2b..c4effa7a 100644
--- a/site/rss.xml
+++ b/site/rss.xml
@@ -1 +1 @@
-Best Dad Jokes — Dad Joke of the Dayhttps://bestdadjokes.lol/joke-of-the-day/The best dad jokes on the internet — short, clean, and groan-worthy.en-usDad Joke of the Day — Oct 23https://bestdadjokes.lol/joke-of-the-day/?d=2026-10-23bjd-daily-2026-10-23Fri, 23 Oct 2026 08:27:40 -0000Why couldn't the astronaut book a hotel room on the moon? — Because it was full.Dad Joke of the Day — Oct 22https://bestdadjokes.lol/joke-of-the-day/?d=2026-10-22bjd-daily-2026-10-22Thu, 22 Oct 2026 08:27:40 -0000What do you call a space magician? — A flying saucerer.Dad Joke of the Day — Oct 21https://bestdadjokes.lol/joke-of-the-day/?d=2026-10-21bjd-daily-2026-10-21Wed, 21 Oct 2026 08:27:40 -0000Why did the cow become an astronaut? — To see the moooon.Dad Joke of the Day — Oct 20https://bestdadjokes.lol/joke-of-the-day/?d=2026-10-20bjd-daily-2026-10-20Tue, 20 Oct 2026 08:27:40 -0000What's an astronaut's favorite part of a computer? — The space bar.Dad Joke of the Day — Oct 19https://bestdadjokes.lol/joke-of-the-day/?d=2026-10-19bjd-daily-2026-10-19Mon, 19 Oct 2026 08:27:40 -0000Why aren't astronauts hungry after they blast off? — Because they've had a big launch.Dad Joke of the Day — Oct 18https://bestdadjokes.lol/joke-of-the-day/?d=2026-10-18bjd-daily-2026-10-18Sun, 18 Oct 2026 08:27:40 -0000What do astronauts use to keep their pants up? — An asteroid belt.Dad Joke of the Day — Oct 17https://bestdadjokes.lol/joke-of-the-day/?d=2026-10-17bjd-daily-2026-10-17Sat, 17 Oct 2026 08:27:40 -0000What did Saturn say to Jupiter? — Give me a ring sometime.Dad Joke of the Day — Oct 16https://bestdadjokes.lol/joke-of-the-day/?d=2026-10-16bjd-daily-2026-10-16Fri, 16 Oct 2026 08:27:40 -0000What kind of music do planets listen to? — Neptunes.Dad Joke of the Day — Oct 15https://bestdadjokes.lol/joke-of-the-day/?d=2026-10-15bjd-daily-2026-10-15Thu, 15 Oct 2026 08:27:40 -0000Why did the astronaut break up with his girlfriend? — He needed space.Dad Joke of the Day — Oct 14https://bestdadjokes.lol/joke-of-the-day/?d=2026-10-14bjd-daily-2026-10-14Wed, 14 Oct 2026 08:27:40 -0000What do you call an alien with three eyes? — An aliiien.Dad Joke of the Day — Oct 13https://bestdadjokes.lol/joke-of-the-day/?d=2026-10-13bjd-daily-2026-10-13Tue, 13 Oct 2026 08:27:40 -0000Why is the moon always broke? — It's down to its last quarter.Dad Joke of the Day — Oct 12https://bestdadjokes.lol/joke-of-the-day/?d=2026-10-12bjd-daily-2026-10-12Mon, 12 Oct 2026 08:27:40 -0000How do you organize a party in space? — You planet.Dad Joke of the Day — Oct 11https://bestdadjokes.lol/joke-of-the-day/?d=2026-10-11bjd-daily-2026-10-11Sun, 11 Oct 2026 08:27:40 -0000How does the moon cut its hair? — Eclipse it.Dad Joke of the Day — Oct 10https://bestdadjokes.lol/joke-of-the-day/?d=2026-10-10bjd-daily-2026-10-10Sat, 10 Oct 2026 08:27:40 -0000The forecast said it would rain cats and dogs. — I went outside and stepped in a poodle.Dad Joke of the Day — Oct 09https://bestdadjokes.lol/joke-of-the-day/?d=2026-10-09bjd-daily-2026-10-09Fri, 09 Oct 2026 08:27:40 -0000What do you get when you leave a dog out in the cold? — A chili dog.Dad Joke of the Day — Oct 08https://bestdadjokes.lol/joke-of-the-day/?d=2026-10-08bjd-daily-2026-10-08Thu, 08 Oct 2026 08:27:40 -0000Why don't mountains ever get cold in winter? — They wear snowcaps.Dad Joke of the Day — Oct 07https://bestdadjokes.lol/joke-of-the-day/?d=2026-10-07bjd-daily-2026-10-07Wed, 07 Oct 2026 08:27:40 -0000What's a rainbow's favorite accessory? — A bow-tie.Dad Joke of the Day — Oct 06https://bestdadjokes.lol/joke-of-the-day/?d=2026-10-06bjd-daily-2026-10-06Tue, 06 Oct 2026 08:27:40 -0000What do snowmen call their offspring? — Chill-dren.Dad Joke of the Day — Oct 05https://bestdadjokes.lol/joke-of-the-day/?d=2026-10-05bjd-daily-2026-10-05Mon, 05 Oct 2026 08:27:40 -0000What's a tornado's favorite game? — Twister.Dad Joke of the Day — Oct 04https://bestdadjokes.lol/joke-of-the-day/?d=2026-10-04bjd-daily-2026-10-04Sun, 04 Oct 2026 08:27:40 -0000Why did the weather want privacy? — It was changing.Dad Joke of the Day — Oct 03https://bestdadjokes.lol/joke-of-the-day/?d=2026-10-03bjd-daily-2026-10-03Sat, 03 Oct 2026 08:27:40 -0000What falls in winter but never gets hurt? — Snow.
\ No newline at end of file
+Best Dad Jokes — Dad Joke of the Dayhttps://bestdadjokes.lol/joke-of-the-day/The best dad jokes on the internet — short, clean, and groan-worthy.en-usDad Joke of the Day — Oct 23https://bestdadjokes.lol/joke-of-the-day/?d=2026-10-23bjd-daily-2026-10-23Fri, 23 Oct 2026 08:49:15 -0000Why couldn't the astronaut book a hotel room on the moon? — Because it was full.Dad Joke of the Day — Oct 22https://bestdadjokes.lol/joke-of-the-day/?d=2026-10-22bjd-daily-2026-10-22Thu, 22 Oct 2026 08:49:15 -0000What do you call a space magician? — A flying saucerer.Dad Joke of the Day — Oct 21https://bestdadjokes.lol/joke-of-the-day/?d=2026-10-21bjd-daily-2026-10-21Wed, 21 Oct 2026 08:49:15 -0000Why did the cow become an astronaut? — To see the moooon.Dad Joke of the Day — Oct 20https://bestdadjokes.lol/joke-of-the-day/?d=2026-10-20bjd-daily-2026-10-20Tue, 20 Oct 2026 08:49:15 -0000What's an astronaut's favorite part of a computer? — The space bar.Dad Joke of the Day — Oct 19https://bestdadjokes.lol/joke-of-the-day/?d=2026-10-19bjd-daily-2026-10-19Mon, 19 Oct 2026 08:49:15 -0000Why aren't astronauts hungry after they blast off? — Because they've had a big launch.Dad Joke of the Day — Oct 18https://bestdadjokes.lol/joke-of-the-day/?d=2026-10-18bjd-daily-2026-10-18Sun, 18 Oct 2026 08:49:15 -0000What do astronauts use to keep their pants up? — An asteroid belt.Dad Joke of the Day — Oct 17https://bestdadjokes.lol/joke-of-the-day/?d=2026-10-17bjd-daily-2026-10-17Sat, 17 Oct 2026 08:49:15 -0000What did Saturn say to Jupiter? — Give me a ring sometime.Dad Joke of the Day — Oct 16https://bestdadjokes.lol/joke-of-the-day/?d=2026-10-16bjd-daily-2026-10-16Fri, 16 Oct 2026 08:49:15 -0000What kind of music do planets listen to? — Neptunes.Dad Joke of the Day — Oct 15https://bestdadjokes.lol/joke-of-the-day/?d=2026-10-15bjd-daily-2026-10-15Thu, 15 Oct 2026 08:49:15 -0000Why did the astronaut break up with his girlfriend? — He needed space.Dad Joke of the Day — Oct 14https://bestdadjokes.lol/joke-of-the-day/?d=2026-10-14bjd-daily-2026-10-14Wed, 14 Oct 2026 08:49:15 -0000What do you call an alien with three eyes? — An aliiien.Dad Joke of the Day — Oct 13https://bestdadjokes.lol/joke-of-the-day/?d=2026-10-13bjd-daily-2026-10-13Tue, 13 Oct 2026 08:49:15 -0000Why is the moon always broke? — It's down to its last quarter.Dad Joke of the Day — Oct 12https://bestdadjokes.lol/joke-of-the-day/?d=2026-10-12bjd-daily-2026-10-12Mon, 12 Oct 2026 08:49:15 -0000How do you organize a party in space? — You planet.Dad Joke of the Day — Oct 11https://bestdadjokes.lol/joke-of-the-day/?d=2026-10-11bjd-daily-2026-10-11Sun, 11 Oct 2026 08:49:15 -0000How does the moon cut its hair? — Eclipse it.Dad Joke of the Day — Oct 10https://bestdadjokes.lol/joke-of-the-day/?d=2026-10-10bjd-daily-2026-10-10Sat, 10 Oct 2026 08:49:15 -0000The forecast said it would rain cats and dogs. — I went outside and stepped in a poodle.Dad Joke of the Day — Oct 09https://bestdadjokes.lol/joke-of-the-day/?d=2026-10-09bjd-daily-2026-10-09Fri, 09 Oct 2026 08:49:15 -0000What do you get when you leave a dog out in the cold? — A chili dog.Dad Joke of the Day — Oct 08https://bestdadjokes.lol/joke-of-the-day/?d=2026-10-08bjd-daily-2026-10-08Thu, 08 Oct 2026 08:49:15 -0000Why don't mountains ever get cold in winter? — They wear snowcaps.Dad Joke of the Day — Oct 07https://bestdadjokes.lol/joke-of-the-day/?d=2026-10-07bjd-daily-2026-10-07Wed, 07 Oct 2026 08:49:15 -0000What's a rainbow's favorite accessory? — A bow-tie.Dad Joke of the Day — Oct 06https://bestdadjokes.lol/joke-of-the-day/?d=2026-10-06bjd-daily-2026-10-06Tue, 06 Oct 2026 08:49:15 -0000What do snowmen call their offspring? — Chill-dren.Dad Joke of the Day — Oct 05https://bestdadjokes.lol/joke-of-the-day/?d=2026-10-05bjd-daily-2026-10-05Mon, 05 Oct 2026 08:49:15 -0000What's a tornado's favorite game? — Twister.Dad Joke of the Day — Oct 04https://bestdadjokes.lol/joke-of-the-day/?d=2026-10-04bjd-daily-2026-10-04Sun, 04 Oct 2026 08:49:15 -0000Why did the weather want privacy? — It was changing.Dad Joke of the Day — Oct 03https://bestdadjokes.lol/joke-of-the-day/?d=2026-10-03bjd-daily-2026-10-03Sat, 03 Oct 2026 08:49:15 -0000What falls in winter but never gets hurt? — Snow.
\ No newline at end of file
diff --git a/site/topic/animals/index.html b/site/topic/animals/index.html
index e5d687ff..d0e78633 100644
--- a/site/topic/animals/index.html
+++ b/site/topic/animals/index.html
@@ -87,7 +87,7 @@