bestdadjokes/build.py

1310 lines
79 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env python3
"""Static site generator for bestdadjokes.lol. Python 3.6 stdlib only."""
import json, os, re, shutil, html, datetime
ROOT = os.path.dirname(os.path.abspath(__file__))
CONTENT = os.path.join(ROOT, 'content', 'jokes.json')
SITE_DIR = os.path.join(ROOT, 'site')
STATIC = os.path.join(ROOT, 'static')
SITE_URL = 'https://bestdadjokes.lol'
SITE_NAME = 'Best Dad Jokes'
TAGLINE = 'The best dad jokes on the internet — short, clean, and groan-worthy.'
YEAR = datetime.date.today().year
with open(CONTENT) as f:
DATA = json.load(f)
CATS = DATA['categories']
JOKES = DATA['jokes']
CAT_BY_SLUG = {c['slug']: c for c in CATS}
for i, j in enumerate(JOKES):
j['id'] = i
# Long-tail topic pages: jokes matched by keyword across all categories.
TOPICS = [
{"slug": "coffee", "name": "Dad Jokes About Coffee", "emoji": "☕",
"intro": "Fuel for dads and their worst puns alike. These coffee dad jokes are best served strong, black, and with a healthy amount of eye-rolling.",
"keywords": r"\b(coffee|espresso|latte|caffeine|beans?|mugs?)\b"},
{"slug": "cats", "name": "Dad Jokes About Cats", "emoji": "🐱",
"intro": "For the cat dads out there. These cat dad jokes will make your feline walk out of the room in disgust — which, for a cat, is a standing ovation.",
"keywords": r"\b(cats?|kittens?|purr|feline|meow)\b"},
{"slug": "dogs", "name": "Dad Jokes About Dogs", "emoji": "🐕",
"intro": "A dog is the only audience that wags at dad jokes. Fetch! These dog dad jokes are good boys, every one of them.",
"keywords": r"\b(dogs?|puppy|puppies|pup|hound)\b"},
{"slug": "cows", "name": "Dad Jokes About Cows", "emoji": "🐄",
"intro": "Outstanding in their field and in our pun archive. These cow dad jokes are udderly relentless.",
"keywords": r"\b(cows?|cattle|moo|udder|beef|herd)\b"},
{"slug": "dad-jokes-about-fishing", "name": "Dad Jokes About Fishing", "emoji": "🎣",
"intro": "Reel in the groans with these clean fishing dad jokes. Hook, line, and sinker comedy for anglers and lake trips.",
"keywords": r"\b(fish|fishing|angler|anglers|trout|salmon|bass|goldfish|sofishticated|stream|bait|tackle|reel|reeling|fisherman|fishermen|carp|catch|lake|rod)\b"},
{"slug": "pizza", "name": "Dad Jokes About Pizza", "emoji": "🍕",
"intro": "A slice of comedy gold. These pizza dad jokes are cheesy by design — that's not a bug, it's the whole point.",
"keywords": r"\b(pizza|pizzas|cheese|cheesy|crust|pepperoni|slice|slices|mozzarella)\b"},
{"slug": "money", "name": "Dad Jokes About Money", "emoji": "💰",
"intro": "Money can't buy happiness, but it can buy these money dad jokes, which are basically the same thing but cheaper.",
"keywords": r"\b(money|cash|coins?|dollars?|penn(y|ies)|bank|rich|spen[dt]|salary)\b"},
{"slug": "sleep", "name": "Dad Jokes About Sleep", "emoji": "😴",
"intro": "Read these sleep dad jokes in bed. Groaning yourself to sleep counts as a lullaby.",
"keywords": r"\b(sleep|nap|bed|pillow|blanket|tired|asleep|dream)\b"},
{"slug": "love", "name": "Dad Jokes About Love", "emoji": "❤️",
"intro": "Romance, dad-style. These love dad jokes have walked someone down the aisle against their will and lived to pun about it.",
"keywords": r"\b(love|romantic|valentine|marri(ed|age)|attract|wife|husband|buoy)\b"},
{"slug": "birthday", "name": "Birthday Dad Jokes", "emoji": "🎂",
"intro": "Because every birthday needs at least one groan with the cake. These birthday dad jokes are tradition now, sorry.",
"keywords": r"\b(birthday|cake|candles?|party|presents?)\b"},
{"slug": "winter", "name": "Winter Dad Jokes", "emoji": "⛄",
"intro": "These winter dad jokes are snow joke. Perfect for breaking the ice at any cold-weather gathering.",
"keywords": r"\b(winter|snow|snowman|ic(y|icle)|frost|chill)\b"},
{"slug": "school", "name": "Dad Jokes About School", "emoji": "\U0001F392",
"intro": "Class clown certified jokes for teachers, students, and anyone who survived homework. These school dad jokes will get you a passing grade in groans.",
"keywords": r"\b(school|teacher|class|student|homework|math|book|read|study)\b"},
{"slug": "cars", "name": "Dad Jokes About Cars", "emoji": "🚗",
"intro": "Drive everyone up the wall during your next road trip. These car dad jokes are strictly automatic when it comes to terrible punchlines.",
"keywords": r"\b(car|drive|road|truck|tire|wheel|traffic)\b"},
{"slug": "teacher", "name": "Dad Jokes About Teachers", "emoji": "🍎",
"intro": "Grade A puns that will get you sent to the principal's office. These teacher dad jokes are strictly for extra credit.",
"keywords": r"\b(teacher|teachers|teach|principal)\b"},
{"slug": "computer", "name": "Dad Jokes About Computers", "emoji": "💻",
"intro": "Hard drive full of jokes? Boot up these tech puns. These computer dad jokes are guaranteed to crash your family dinner.",
"keywords": r"\b(computer|computers|laptop|pc|keyboard|mouse)\b"},
{"slug": "snowman", "name": "Dad Jokes About Snowmen", "emoji": "⛄️",
"intro": "Frosty reception guaranteed. These snowman dad jokes are stone cold classics that will melt your heart (and your patience).",
"keywords": r"\b(snowman|snowmen|frosty)\b"},
{"slug": "ocean", "name": "Dad Jokes About the Ocean", "emoji": "🌊",
"intro": "Water you waiting for? Dive into these shore-fire maritime puns. These ocean dad jokes will make waves at any beach party.",
"keywords": r"\b(ocean|sea|beach|water|tides?|waves?|boat|ship|sail|sand|sharks?|fish)\b"},
{"slug": "moon", "name": "Dad Jokes About the Moon", "emoji": "🌖",
"intro": "These jokes are out of this world! Get ready for some stellar dad jokes about the moon.",
"keywords": r"\b(moon|space|stars?|planet)\b"},
{"slug": "vacation", "name": "Dad Jokes About Vacation", "emoji": "🏖️",
"intro": "Time to pack your bags and your best puns! These dad jokes about vacation will have you laughing all the way to your destination.",
"keywords": r"\b(vacation|trip|travel|holiday|packing)\b"},
{"slug": "food", "name": "Dad Jokes About Food", "emoji": "🍔",
"intro": "Hungry for a laugh? These dad jokes about food will hit the spot.",
"keywords": r"\b(food|eat|dinner|lunch|breakfast|hungry|pizza|coffee|cheese|lettuce)\b"},
{"slug": "animals", "name": "Dad Jokes About Animals", "emoji": "🐘",
"intro": "Lions, tigers, and puns - oh my! Enjoy these wild dad jokes about animals.",
"keywords": r"\b(animal|animals|dog|cat|fish|bird|bear|horse|cows?|deer)\b"},
{"slug": "music", "name": "Dad Jokes About Music", "emoji": "🎵",
"intro": "Strike a chord with these dad jokes about music. They are sure to be a hit.",
"keywords": r"\b(music|song|sing|band|guitar|piano|drum|notes?)\b"},
{"slug": "clothing", "name": "Dad Jokes About Clothing", "emoji": "👔",
"intro": "You will look stylish telling these dad jokes about clothing.",
"keywords": r"\b(clothes|shirt|pants|shoes|hat|wear|socks?|tie|suit)\b"},
{"slug": "space", "name": "Dad Jokes About Space", "emoji": "🚀",
"intro": "These space dad jokes are out of this world.",
"keywords": r"\b(space|astronauts?|planets?|moon|sun|stars|aliens?)\b"},
{"slug": "halloween-dad-jokes", "name": "Halloween Dad Jokes", "emoji": "🎃",
"intro": "The best clean Halloween dad jokes, spooky puns, and skeleton one-liners. Groan-worthy laughs for trick-or-treaters, kids, and family parties.",
"keywords": r"\b(halloween|ghost|skeleton|pumpkin|spooky|vampire|zombie|witch|monster|bat|dracula|frankenstein|ghoul)\b"},
{"slug": "thanksgiving-dad-jokes", "name": "Thanksgiving Dad Jokes", "emoji": "🦃",
"intro": "Feast on the funniest Thanksgiving dad jokes! Clean turkey puns, dinner table groaners, and autumn laughs guaranteed to make the family roll their eyes.",
"keywords": r"\b(thanksgiving|turkey|turkeys|pilgrim|pilgrims|cranberr\w*|stuffing|gravy|feast|yam|yams)\b"},
{"slug": "christmas-dad-jokes", "name": "Christmas Dad Jokes", "emoji": "🎄",
"intro": "Spread holiday cheer with the best Christmas dad jokes, Santa puns, and clean holiday one-liners. Perfect for Christmas cards and family gatherings.",
"keywords": r"\b(christmas|santa|elf|reindeer|snow|winter|tree|present|holiday|sleigh|snowman)\b"},
{"slug": "dad-jokes-for-kids", "name": "Dad Jokes for Kids", "emoji": "🧒",
"intro": "Over 50 hilarious, 100% clean dad jokes for kids, students, and teachers. School-safe puns and corny one-liners that the whole family will love.",
"keywords": r"\b(kid|child|children|school|teacher|student|boy|girl|math|science|homework|play|game)\b"},
{"slug": "work-dad-jokes", "name": "Work Dad Jokes", "emoji": "🏢",
"intro": "Break the ice at your next meeting with clean office dad jokes. Workplace-safe humor, corporate puns, and harmless water cooler groaners.",
"keywords": r"\b(work|office|job|boss|meeting|employee|coworker|business|company|career)\b"},
{"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|engineers|code|coding|programmer|programmers|dev|developer|developers|debug|debugging|python|java|javascript|html|cache|server|servers|database|sql|hardware|udp|hobbyte|git)\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(clean|kid|kids|child|kindergarten|toddler|preschool|toy|toys|five|5|playground|sandbox|nursery)\b"},
{"slug": "dad-jokes-for-fathers-day", "name": "Dad Jokes for Father's Day", "emoji": "👔",
"intro": "Honor the undisputed king of groans with hilarious Father's Day dad jokes and parenting puns that celebrate all things dad.",
"keywords": r"\b(father|fathers|dad|dads|parent|parents|daddy|pop|papa|father's day)\b"},
{"slug": "dad-jokes-about-books", "name": "Dad Jokes About Books", "emoji": "📚",
"intro": "Check out these novel dad jokes about books, libraries, and reading. Bound to get a solid chuckle from bookworms and librarians.",
"keywords": r"\b(book|books|novel|novels|author|authors|library|libraries|librarian|librarians|reading|read|chapter|chapters|thesaurus|dictionary|overbooked|anti-gravity)\b"},
{"slug": "dad-jokes-about-gardening", "name": "Dad Jokes About Gardening", "emoji": "🌱",
"intro": "Plant a smile with garden dad jokes, tree puns, and flora humor that will grow on you in no time.",
"keywords": r"\b(garden|gardens|gardening|gardener|plant|plants|tree|trees|flower|flowers|lawn|weed|soil|bud|seeds?|bark|branch|leaf|leaves)\b"},
{"slug": "dad-jokes-about-baseball", "name": "Dad Jokes About Baseball", "emoji": "⚾",
"intro": "Step up to the plate with these hilarious baseball dad jokes. They will knock your socks off or strike you out laughing.",
"keywords": r"\b(baseball|batter|batters|pitcher|pitchers|home run|stole second|dugout|catcher|baseball player|baseball players)\b"},
{"slug": "dad-jokes-about-golf", "name": "Dad Jokes About Golf", "emoji": "⛳",
"intro": "Tee off with clean golf dad jokes that are guaranteed to stay out of the rough and score a hole-in-one groan.",
"keywords": r"\b(golf|golfer|golfers|golfing|hole in one|birdie|fairway|par|putt|putting|green)\b"},
{"slug": "dad-jokes-for-road-trips", "name": "Dad Jokes for Road Trips", "emoji": "🚗",
"intro": "Are we there yet? Fuel up family travel with hilarious road trip dad jokes, car puns, and highway humor.",
"keywords": r"\b(road|trip|car|cars|drive|driving|traffic|miles|highway|travel|vacation|wheels?|tires?|gps|map|van|truck)\b"},
{"slug": "math-dad-jokes", "name": "Dad Jokes About Math", "emoji": "📐",
"intro": "Why was the geometry book so adorable? It had acute angles! These clean math dad jokes and number puns are 100% calculated to multiply groans and divide boredom.",
"keywords": r"\b(math|triangle|geometry|angle|acute|algebra|fraction|calculator|times square)\b"},
{"slug": "doctor-dad-jokes", "name": "Dad Jokes About Doctors", "emoji": "🩺",
"intro": "Why did the banana go to the doctor? It wasn't peeling well! These hilarious doctor, dentist, and medical dad jokes are just what the physician ordered for instant laughs.",
"keywords": r"\b(doctor|physicians?|dentists?|hospitals?|nurses?|stethoscope|surgeons?|filling|checkup|clinic|medicine|prescription|broken arm|patients?)\b"},
{"slug": "cross-the-road-jokes", "name": "Why Did the Chicken Cross the Road Jokes", "emoji": "🐔",
"intro": "Why did the turtle cross the road? To get to the shell station! Explore the best groan-worthy twists on the classic 'Why did the chicken cross the road?' punchline.",
"keywords": r"\b(cross(?:ed|ing)?\s+(?:the\s+)?road|other\s+side|other\s+slide|shell\s+station|barking\s+lot|udder\s+side)\b"},
{"slug": "eyes", "name": "Dad Jokes About Eyes", "emoji": "👀",
"intro": "Eye see what you did there! These dad jokes about eyes are a sight for sore... well, you know.",
"keywords": r"\b(eyes?|see|sight|glasses|vision)\b"},
{"slug": "dad-jokes-about-history", "name": "Dad Jokes About History", "emoji": "🏛️",
"intro": "Why did Rudolph get a bad report card? Because he went down in history! Travel back in time with ancient Roman puns, medieval laughs, and historic dad jokes that will never go out of style.",
"keywords": r"\b(history|historical|ancient|rome|roman|romans|caesar|pharaoh|pyramid|pyramids|medieval|knight|knights|castle|king|queen|revolution|napoleon|gladiator)\b"},
{"slug": "dad-jokes-about-airplanes", "name": "Dad Jokes About Airplanes", "emoji": "✈️",
"intro": "Why did the airplane get sent to its room? For bad altitude! Fasten your seatbelts for first-class aviation dad jokes, pilot puns, and high-flying humor that never crash.",
"keywords": r"\b(plane|planes|airplane|airplanes|pilot|pilots|airport|cabin|propeller|jet|runway|altitude|boarding)\b"},
{"slug": "dad-jokes-about-cooking", "name": "Dad Jokes About Cooking & Baking", "emoji": "🍳",
"intro": "Looking for appetizing humor? Whip up some laughter with these clean cooking dad jokes, kitchen puns, and bakery groaners.",
"keywords": r"\b(cook|cooking|chef|chefs|bake|baker|bakers|bakery|kitchen|recipe|dough|yeast|sauce|pan|pasta|spaghetti|skillet)\b"},
{"slug": "dad-jokes-about-trees", "name": "Dad Jokes About Trees & Nature", "emoji": "🌲",
"intro": "Branch out into arbor humor! These clean tree dad jokes, forest puns, and leafy one-liners will root you to the spot.",
"keywords": r"\b(trees?|branch|branches|leaf|leaves|bark|trunk|root|roots|acorn|forest|oak|pine|wood)\b"},
{"slug": "dad-jokes-about-birds", "name": "Dad Jokes About Birds", "emoji": "🐦",
"intro": "Flock together for bird dad jokes and feathered puns that will take flight at your next family gathering.",
"keywords": r"\b(birds?|seagulls?|duck|ducks|owl|owls|penguin|penguins|crow|crows|feathers?|wings?|flying|quack|nest|pigeon)\b"},
{"slug": "dad-jokes-about-construction", "name": "Dad Jokes About Construction & Tools", "emoji": "🔨",
"intro": "Nailed it! Build up the laughs with hilarious construction dad jokes, carpenter puns, and heavy-duty tool humor.",
"keywords": r"\b(construction|hammer|nail|nails|tool|tools|saw|screw|screwdriver|drill|wrench|brick|bricks|builder|plumber|plumbing|ladder)\b"},
{"slug": "dad-jokes-for-breakfast", "name": "Dad Jokes About Breakfast", "emoji": "🥞",
"intro": "Start your morning with an egg-cellent laugh. Sunny-side-up breakfast dad jokes, coffee puns, and pancake groaners.",
"keywords": r"\b(breakfast|coffee|cereal|egg|eggs|toast|pancake|pancakes|waffle|waffles|bacon|morning|tea)\b"},
{"slug": "dad-jokes-about-clocks", "name": "Dad Jokes About Clocks & Time", "emoji": "⏰",
"intro": "It's about time! Watch out for these clean clock dad jokes, watchmaker puns, and timeless family-friendly groaners.",
"keywords": r"\b(clocks?|watch|watches|watchmaker|hourglass|alarm|time|tock|ticking|seconds?|minutes?|hours?|calendar|pendulum)\b"},
{"slug": "dad-jokes-about-science", "name": "Dad Jokes About Science & Chemistry", "emoji": "🔬",
"intro": "Tested and approved by the funniest minds in the lab. Clean science dad jokes, physics puns, and periodic groaners.",
"keywords": r"\b(science|scientist|scientists|atom|atoms|physics|chemistry|chemist|biology|microscope|beaker|laboratory|gravity)\b"},
{"slug": "dad-jokes-about-water-and-swimming", "name": "Dad Jokes About Water and Swimming", "emoji": "🏊",
"intro": "Dive right into deep groans and shallow laughs. These clean dad jokes about water, swimming pools, and lakes make a huge splash.",
"keywords": r"\b(water|swim|swimming|pool|pools|swimmer|swimmers|diver|divers|diving|splash|splashing|deep end|shallow end|lake|lakes|river|rivers)\b"},
{"slug": "dad-jokes-about-farm-animals", "name": "Dad Jokes About Farm Animals", "emoji": "🚜",
"intro": "Straight from the barnyard to your dinner table. These farm animal dad jokes about pigs, chickens, horses, and tractors are udderly ridiculous.",
"keywords": r"\b(farm|farmer|barn|barnyard|cow|cows|cattle|bovine|pasture|pig|pigs|piglet|chicken|chickens|rooster|roosters|hen|hens|horse|horses|sheep|goat|goats|tractor|hay|stable)\b"},
{"slug": "dad-jokes-about-shoes-and-feet", "name": "Dad Jokes About Shoes and Feet", "emoji": "👟",
"intro": "Sole-crushing puns and toe-tapping groans. These dad jokes about shoes, socks, and feet are tied together for maximum comfort.",
"keywords": r"\b(shoe|shoes|sneaker|sneakers|boot|boots|sock|socks|foot|feet|toe|toes|shoelace|shoelaces|heel|heels|sandals?)\b"},
{"slug": "dad-jokes-about-fruit", "name": "Dad Jokes About Fruit", "emoji": "🍎",
"intro": "Ripe for the picking and sweet to the punchline. These fruity dad jokes about apples, bananas, melons, and berries are simply pear-fect.",
"keywords": r"\b(fruit|fruits|apple|apples|banana|bananas|orange|oranges|lemon|lemons|melon|melons|berry|berries|grape|grapes|pear|pears|peach|peaches|watermelon)\b"},
{"slug": "dad-jokes-about-monsters-and-ghosts", "name": "Dad Jokes About Monsters and Ghosts", "emoji": "👻",
"intro": "Spooky chuckles and supernatural eye-rolls. These monster and ghost dad jokes about vampires, skeletons, and ghouls will raise your spirits.",
"keywords": r"\b(monster|monsters|ghost|ghosts|ghoul|ghouls|vampire|vampires|skeleton|skeletons|zombie|zombies|frankenstein|mummy|mummies|haunt|haunted|dracula|witch|witches)\b"},
{"slug": "dad-jokes-about-restaurants-and-dining", "name": "Dad Jokes About Restaurants and Dining", "emoji": "🍽️",
"intro": "Reserved for lovers of fine humor and cheap puns. These restaurant and dining dad jokes serve up generous portions of groan-worthy laughs.",
"keywords": r"\b(restaurant|restaurants|waiter|waiters|waitress|waitresses|order|ordering|menu|menus|dine|dining|diner|diners|table|tip|tipping|bill|chef|chefs)\b"},
{"slug": "dad-jokes-about-money-and-banks", "name": "Dad Jokes About Money and Banks", "emoji": "💵",
"intro": "Invest in quality laughs with high-interest returns. These dad jokes about money, cash, banks, and currency are rich with humor.",
"keywords": r"\b(money|bank|banks|banker|bankers|cash|dollar|dollars|cent|cents|penny|pennies|quarter|quarters|atm|wealth|rich|broke|loan|interest|wallet)\b"},
{"slug": "clean-dad-jokes-for-school", "name": "Clean Dad Jokes for School", "emoji": "🎒",
"intro": "Class is in session and the groans are mandatory. These clean dad jokes for school, homework, tests, and recess get straight A's in humor.",
"keywords": r"\b(school|schools|class|classes|classroom|teacher|teachers|homework|student|students|grade|grades|test|tests|exam|exams|recess|pencil|pencils|backpack)\b"},
{"slug": "dad-jokes-about-desserts-and-sweets", "name": "Dad Jokes About Desserts and Sweets", "emoji": "🍦",
"intro": "Sweet treats with an extra scoop of silliness. These dessert dad jokes about cookies, cake, ice cream, and candy are a recipe for smiles.",
"keywords": r"\b(dessert|desserts|cookie|cookies|cake|cakes|pie|pies|ice cream|candy|candies|chocolate|chocolates|sugar|sweet|sweets|bakery|brownie|brownies|donut|donuts|doughnut|doughnuts)\b"},
{"slug": "dad-jokes-about-bugs-and-insects", "name": "Dad Jokes About Bugs and Insects", "emoji": "🐝",
"intro": "Hilarious crawlers and winged wordplay. These bug and insect dad jokes about bees, ants, spiders, and beetles won't bug anyone.",
"keywords": r"\b(bug|bugs|insect|insects|ant|ants|bee|bees|spider|spiders|beetle|beetles|butterfly|butterflies|caterpillar|caterpillars|mosquito|mosquitoes|housefly|firefly|fireflies|centipede|cricket|crickets)\b"},
{"slug": "dad-jokes-about-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|engineers|code|coding|programmer|programmers|dev|developer|developers|debug|debugging|python|java|javascript|html|cache|server|servers|database|sql|hardware|udp|hobbyte|git)\b"},
{"slug": "clean-dad-jokes-for-work-meetings", "name": "Clean Dad Jokes for Work Meetings", "emoji": "💼",
"intro": "Lighten the mood on your next Zoom call or team standup. These clean dad jokes for work meetings are office-friendly, HR-approved, and guaranteed to break the ice.",
"keywords": r"\b(work|office|meeting|meetings|zoom|boss|manager|coworker|coworkers|job|career|salary|desk|cubicle|presentation|agenda|slack|teams|email|hr|corporate|standup)\b"},
{"slug": "dad-jokes-about-cats-and-dogs", "name": "Dad Jokes About Cats and Dogs", "emoji": "🐾",
"intro": "Paws what you are doing! These hilarious dad jokes about cats and dogs are fur-real crowd pleasers that will have pet lovers howling with laughter.",
"keywords": r"\b(cat|cats|kitten|kittens|feline|meow|purr|dog|dogs|puppy|puppies|canine|bark|barking|woof|tail|tails|paws?|collar|leash|vet|veterinarian)\b"},
{"slug": "dad-jokes-about-space-and-astronomy", "name": "Dad Jokes About Space and Astronomy", "emoji": "🚀",
"intro": "Out of this world humor that defies gravity. These space and astronomy dad jokes about planets, astronauts, stars, and rockets are truly stellar.",
"keywords": r"\b(space|astronomy|planet|planets|star|stars|moon|moons|sun|solar|orbit|galaxy|galaxies|astronaut|astronauts|rocket|rockets|nasa|alien|aliens|telescope|universe|gravity|meteor|asteroid)\b"},
{"slug": "dad-jokes-for-elementary-students", "name": "Dad Jokes for Elementary Students", "emoji": "🎒",
"intro": "Kid-tested and teacher-approved! These funny dad jokes for elementary students will rule the lunch table, recess, and school bus with wholesome laughs.",
"keywords": r"\b(school|student|students|elementary|classroom|teacher|teachers|homework|recess|pencil|desk|backpack|grade|grades|kindergarten|hallway|lunchbox)\b"},
{"slug": "dad-jokes-about-weather-and-rain", "name": "Dad Jokes About Weather and Rain", "emoji": "🌦️",
"intro": "Forecast calls for 100% chance of eye-rolls. These weather dad jokes about rain, clouds, storms, and sunshine will brighten up any cloudy day.",
"keywords": r"\b(weather|rain|raining|rainbow|cloud|clouds|cloudy|storm|storms|thunder|lightning|wind|windy|sun|sunny|sunshine|forecast|tornado|hurricane|umbrella|puddle|temperature)\b"},
{"slug": "dad-jokes-about-sports-and-athletes", "name": "Dad Jokes About Sports and Athletes", "emoji": "⚽",
"intro": "Score big smiles with the best sports dad jokes! From baseball and basketball to golf and soccer, these clean athletic puns are a home run.",
"keywords": r"\b(sport|sports|athlete|athletes|baseball|basketball|football|soccer|golf|tennis|coach|stadium|game|pitcher|batter|hoop|referee|tournament|trophy|ball)\b"},
{"slug": "dad-jokes-about-coffee-and-tea", "name": "Dad Jokes About Coffee and Tea", "emoji": "☕",
"intro": "Brewing up fresh groans one cup at a time. These clean dad jokes about coffee, espresso, caffeine, and tea are steeped in hilarious puns.",
"keywords": r"\b(coffee|espresso|caffeine|brew|brewing|latte|cappuccino|mocha|roast|cup|mug|tea|teabag|herbal|chai|pot|kettle|cafe|barista)\b"},
{"slug": "dad-jokes-about-pizza-and-tacos", "name": "Dad Jokes About Pizza and Tacos", "emoji": "🍕",
"intro": "Cheesy puns and spicy one-liners! These dad jokes about pizza and tacos deliver a supreme slice of laughter for the whole family.",
"keywords": r"\b(pizza|pizzas|slice|slices|pepperoni|cheese|crust|topping|toppings|taco|tacos|burrito|salsa|guacamole|tortilla|mexican|delivery|cheesy)\b"}
]
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)
def joke_count(slug):
return sum(1 for j in JOKES if j['cat'] == slug)
def json_ld_script(obj):
"""Serialize structured data cleanly without HTML escaping quotes."""
return '<script type="application/ld+json">%s</script>' % json.dumps(obj, ensure_ascii=False).replace('</', r'<\/')
def joke_card(j, reveal=False):
"""A single joke card. Punchline is in the DOM (SEO-safe); JS blurs until clicked."""
cls = 'joke-card'
if j.get('type') == 'knock':
body = '<p class="joke-setup multi">%s</p>' % esc(j['setup']).replace('\n', '<br>')
else:
body = '<p class="joke-setup">%s</p>' % esc(j['setup'])
punch = '<div class="joke-punch" data-punch>%s</div>' % esc(j['punch'])
share = ('<button class="btn-tiny" data-share="%d">🖼️ Share as image</button>'
'<button class="btn-tiny" data-copy="%d">📋 Copy</button>' % (j['id'], j['id']))
return ('<figure class="%s" id="joke-%d">%s%s'
'<figcaption class="joke-actions">%s</figcaption></figure>'
% (cls, j['id'], body, punch, share))
def layout(title, desc, body, path='/', extra_head=''):
if len(desc) > 155:
desc = desc[:154] + '…'
nav_cats = ''.join(
'<a href="/category/%s/">%s %s</a>' % (c['slug'], c['emoji'], esc(c['name']))
for c in CATS)
foot_cats = ''.join('<a href="/category/%s/">%s</a>' % (c['slug'], esc(c['name'])) for c in CATS)
live_topics_nav = LIVE_TOPICS
foot_topics = ''.join('<a href="/topic/%s/">%s</a>' % (t['slug'], esc(t['name'])) for t in live_topics_nav[:16])
return f"""<!DOCTYPE html>
<html lang="en">
<head>
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-719FXSCTTS"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){{dataLayer.push(arguments);}}
gtag('js', new Date());
gtag('config', 'G-719FXSCTTS');
</script>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{esc(title)}</title>
<meta name="description" content="{esc(desc)}">
<link rel="canonical" href="{SITE_URL}{esc(path)}">
<link rel="icon" href="/static/favicon.svg" type="image/svg+xml">
<link rel="alternate" type="application/rss+xml" title="Dad Joke of the Day" href="/rss.xml">
<meta property="og:site_name" content="{SITE_NAME}">
<meta property="og:title" content="{esc(title)}">
<meta property="og:description" content="{esc(desc)}">
<meta property="og:type" content="website">
<meta property="og:url" content="{SITE_URL}{esc(path)}">
<meta property="og:image" content="{SITE_URL}/static/og-image.png">
<meta property="og:image:width" content="1200">
<meta property="og:image:height" content="630">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:title" content="{esc(title)}">
<meta name="twitter:description" content="{esc(desc)}">
<meta name="twitter:image" content="{SITE_URL}/static/og-image.png">
<link rel="stylesheet" href="/static/style.css?v=3">
<style>:root{{--brand:#e4572e;--brand2:#f5a623;--ink:#2b2118;--cream:#fff8ec;--card:#ffffff}}</style>
{extra_head}
</head>
<body>
<header class="site-header">
<div class="wrap header-row">
<a class="logo" href="/">😂 <strong>Best<span>Dad</span>Jokes</strong><em>.lol</em></a>
<input type="checkbox" id="navtoggle" class="navtoggle">
<label for="navtoggle" class="navburger" aria-label="Menu">☰</label>
<nav class="site-nav">
<a href="/" {'class="on"' if path == '/' else ''}>Home</a>
<a href="/blog/" {'class="on"' if path.startswith('/blog') else ''}>Blog</a>
<a href="/dad-joke-generator/" {'class="on"' if path.startswith('/dad-joke-generator') else ''}>Joke Generator</a>
<a href="/joke-of-the-day/" {'class="on"' if path.startswith('/joke-of-the-day') else ''}>Joke of the Day</a>
<a href="/search/" {'class="on"' if path.startswith('/search') else ''}>Search</a>
<a href="/about/" {'class="on"' if path.startswith('/about') else ''}>About</a>
<div class="cat-dropdown">
<input type="checkbox" id="cattoggle" class="cattoggle">
<label for="cattoggle" class="cat-trigger">Categories ▾</label>
<div class="cat-panel">
{nav_cats}
</div>
</div>
</nav>
</div>
</header>
<main>
{body}
</main>
<footer class="site-footer">
<div class="wrap foot-grid">
<div>
<p class="foot-logo">😂 Best<span>Dad</span>Jokes<em>.lol</em></p>
<p>Hi, I'm a dad. These are my jokes. Someone has to laugh at them, and it might as well be the internet.</p>
</div>
<div>
<p class="foot-h">Categories</p>
<div class="foot-links">{foot_cats}</div>
</div>
<div>
<p class="foot-h">Popular Topics</p>
<div class="foot-links">{foot_topics}</div>
</div>
<div>
<p class="foot-h">More</p>
<div class="foot-links">
<a href="/best-dad-gifts/">Dad Gifts & Merch</a>
<a href="/dad-joke-generator/">Dad Joke Generator</a>
<a href="/joke-of-the-day/">Joke of the Day</a>
<a href="/blog/">Blog & Curated Lists</a>
<a href="/search/">Search Jokes</a>
<a href="/rss.xml">RSS Feed</a>
<a href="/api/v1/random.json">Free JSON API</a>
<a href="/about/">About</a>
<a href="/contact/">Contact</a>
<a href="/privacy-policy/">Privacy Policy</a>
<a href="/terms/">Terms</a>
</div>
</div>
</div>
<div class="wrap foot-base">
<p>© {YEAR} {SITE_NAME} · Family-friendly jokes, dad-certified since the Big Dad Energy era.</p>
</div>
</footer>
<script src="/static/jokes-data.js?v=2" defer></script>
<script src="/static/main.js?v=2" defer></script>
</body>
</html>"""
# --- BLOG & CURATED LIST ARTICLES ---
BLOG_ARTICLES = [
{
"slug": "thanksgiving-dad-jokes-that-will-make-the-table-groan",
"title": "12 Thanksgiving Dad Jokes That Will Make the Whole Table Groan",
"desc": "The ultimate list of 100% clean Thanksgiving dad jokes, turkey puns, and dinner table groaners guaranteed to make your family roll their eyes.",
"date": "2026-10-01",
"author": "Best Dad Jokes Team",
"emoji": "🦃",
"intro": "Thanksgiving dinner is all about family, gratitude, second helpings of mashed potatoes, and of course—inflicting the corniest holiday puns possible upon unsuspecting relatives. Whether you need a witty one-liner to break the ice during awkward small talk or a quick pun before carving the bird, here are 12 hand-picked Thanksgiving dad jokes that will make the entire table groan in delight.",
"topic_link": "/topic/thanksgiving-dad-jokes/",
"topic_name": "Thanksgiving Dad Jokes topic cluster",
"jokes": [
{"setup": "Why didn't the turkey finish its dessert?", "punch": "Because it was already stuffed."},
{"setup": "Why did the cranberries turn red?", "punch": "Because they saw the turkey dressing."},
{"setup": "What kind of music did the Pilgrims like?", "punch": "Plymouth Rock."},
{"setup": "What do turkeys wear to formal occasions?", "punch": "Gravy-ties."},
{"setup": "What's a turkey's favorite dessert?", "punch": "Peach gobbler."},
{"setup": "Why did the police arrest the turkey?", "punch": "They suspected foul play."},
{"setup": "What did the mother turkey say to her disobedient children?", "punch": "If your father could see you now, he'd turn over in his gravy!"},
{"setup": "What happens when you step on a grape at Thanksgiving?", "punch": "It lets out a little wine."},
{"setup": "What do you call a stuffed animal?", "punch": "You after Thanksgiving dinner."},
{"setup": "What side of the turkey has the most feathers?", "punch": "The outside."},
{"setup": "What sound does a space turkey make?", "punch": "Hubble, hubble, hubble."},
{"setup": "Why do pilgrims' pants always fall down?", "punch": "Because they wear their belt buckles on their hats!"}
]
},
{
"slug": "clean-halloween-dad-jokes-for-kids-and-trick-or-treaters",
"title": "15 Clean Halloween Dad Jokes for Kids & Trick-or-Treaters",
"desc": "Spooky, silly, and 100% kid-safe! These clean Halloween dad jokes and skeleton puns are perfect for classroom parties and trick-or-treat laughs.",
"date": "2026-10-01",
"author": "Best Dad Jokes Team",
"emoji": "🎃",
"intro": "Halloween should be full of treats, not tricky innuendos. If you're a parent packing a spooky lunchbox note, an elementary teacher looking for a classroom icebreaker, or just a dad greeting trick-or-treaters at the front door, here are 15 clean, hilarious Halloween dad jokes that offer maximum laughs with zero fright.",
"topic_link": "/topic/halloween-dad-jokes/",
"topic_name": "Halloween Dad Jokes collection",
"jokes": [
{"setup": "Why don't skeletons ever fight each other?", "punch": "They don't have the guts."},
{"setup": "What do you call a witch's garage?", "punch": "A broom closet."},
{"setup": "Why did the vampire subscribe to the newspaper?", "punch": "He heard it had great circulation."},
{"setup": "What's a ghost's favorite dessert?", "punch": "I scream."},
{"setup": "Why don't mummies take vacations?", "punch": "They're afraid to unwind."},
{"setup": "What do you call a monster who poisons corn flakes?", "punch": "A cereal killer."},
{"setup": "Why are ghosts such bad liars?", "punch": "You can see right through them."},
{"setup": "What do you get when you cross a snowman with a vampire?", "punch": "Frostbite."},
{"setup": "Why did the skeleton go to the party alone?", "punch": "He had no body to go with him."},
{"setup": "What kind of music do mummies listen to?", "punch": "Wrap music."},
{"setup": "What did the skeleton order at the restaurant?", "punch": "Spare ribs."},
{"setup": "Why do witches ride brooms?", "punch": "Vacuum cleaners are too expensive."},
{"setup": "What do you call a haunted chicken?", "punch": "A poultry-geist."},
{"setup": "Why did the ghost go to the bar?", "punch": "For the boos."},
{"setup": "How do you make a skeleton laugh?", "punch": "Tickle its funny bone."}
]
},
{
"slug": "best-dad-jokes-for-kids-school-safe-puns",
"title": "15 Best Dad Jokes for Kids (School-Safe Puns & Groaners)",
"desc": "Looking for clean, school-safe dad jokes for kids? Here are 15 hilarious, family-friendly puns tested and approved by groaners everywhere.",
"date": "2026-10-01",
"author": "Best Dad Jokes Team",
"emoji": "🎒",
"intro": "Kids love dad jokes because they are short, silly, and rely on clever wordplay they can instantly repeat on the playground. These 15 school-safe, family-friendly dad jokes are tested and approved for morning announcements, lunchbox notes, and bedtime storytelling.",
"topic_link": "/topic/dad-jokes-for-kids/",
"topic_name": "Dad Jokes for Kids library",
"jokes": [
{"setup": "Why did the kid swallow coins?", "punch": "The teacher said he needed more sense."},
{"setup": "Why was the math book sad?", "punch": "It had too many problems."},
{"setup": "Why can't a leopard hide?", "punch": "Because he's always spotted."},
{"setup": "What do you call a dinosaur that sleeps all day?", "punch": "A dino-snore."},
{"setup": "What did the left eye say to the right eye?", "punch": "Between you and me, something smells."},
{"setup": "Why did the music teacher go to jail?", "punch": "Because she got caught with a sharp note."},
{"setup": "What did one plate say to another plate?", "punch": "Tonight, dinner's on me."},
{"setup": "Why did the picture go to jail?", "punch": "Because it was framed."},
{"setup": "What has hands but cannot clap?", "punch": "A clock."},
{"setup": "Why did the banana go to the doctor?", "punch": "Because it wasn't peeling well."},
{"setup": "What do you call a sleeping bull?", "punch": "A bulldozer."},
{"setup": "Why are fish so smart?", "punch": "Because they live in schools."},
{"setup": "What do you call an alligator in a vest?", "punch": "An investigator."},
{"setup": "Why did the bicycle fall over?", "punch": "It was two-tired."},
{"setup": "What do you call cheese that isn't yours?", "punch": "Nacho cheese."}
]
}
]
def page_blog_index():
cards = ''.join(f"""
<article class="blog-card">
<span class="blog-card-emoji">{a['emoji']}</span>
<div class="blog-card-content">
<span class="blog-meta">{a['date']} · By {a['author']}</span>
<h2><a href="/blog/{a['slug']}/">{esc(a['title'])}</a></h2>
<p>{esc(a['desc'])}</p>
<p><a class="blog-read-more" href="/blog/{a['slug']}/">Read all {len(a['jokes'])} jokes →</a></p>
</div>
</article>""" for a in BLOG_ARTICLES)
body = f"""
<div class="wrap narrow">
<nav class="crumbs"><a href="/">Home</a> › <span>Blog</span></nav>
<h1>📝 Dad Joke Lists & Curated Articles</h1>
<p class="page-sub">Hand-picked collections, seasonal lists, and groan-worthy countdowns for every occasion.</p>
<div class="blog-list">
{cards}
</div>
</div>"""
title = 'Dad Joke Blog & Curated Lists — BestDadJokes.lol'
desc = 'Hand-picked dad joke lists and curated humor guides for Thanksgiving, Halloween, kids, and family dinners.'
ld = {
"@context": "https://schema.org",
"@type": "CollectionPage",
"name": title,
"url": SITE_URL + '/blog/',
"description": desc
}
return layout(title, desc, body, '/blog/', json_ld_script(ld))
def page_blog_article(a):
joke_items = []
for idx, j in enumerate(a['jokes']):
joke_items.append(f"""
<div class="blog-joke-item" id="joke-{idx+1}">
<span class="blog-joke-num">#{idx+1}</span>
<div class="blog-joke-body">
<p class="blog-joke-setup">{esc(j['setup'])}</p>
<p class="blog-joke-punch">👉 {esc(j['punch'])}</p>
</div>
</div>""")
jokes_html = ''.join(joke_items)
other_articles = [o for o in BLOG_ARTICLES if o['slug'] != a['slug']]
more_html = ''.join(f'<li><a href="/blog/{o["slug"]}/">{o["emoji"]} {esc(o["title"])}</a></li>' for o in other_articles)
body = f"""
<div class="wrap narrow">
<nav class="crumbs"><a href="/">Home</a> › <a href="/blog/">Blog</a> › <span>{esc(a['title'])}</span></nav>
<article class="blog-article">
<header class="blog-article-header">
<div class="blog-header-badge">{a['emoji']} Curated List</div>
<h1>{esc(a['title'])}</h1>
<p class="blog-meta">Published on {a['date']} · By {a['author']} · {len(a['jokes'])} jokes</p>
</header>
<div class="blog-intro">
<p>{esc(a['intro'])}</p>
</div>
<div class="blog-jokes-container">
{jokes_html}
</div>
<div class="blog-cta">
<h3>Want more like this?</h3>
<p>Explore our complete <a href="{a['topic_link']}">{esc(a['topic_name'])}</a> or roll the dice on our <a href="/dad-joke-generator/">Random Dad Joke Generator</a>!</p>
</div>
<div class="blog-more">
<h3>More Curated Lists</h3>
<ul>{more_html}</ul>
</div>
</article>
</div>"""
faq_ld = {
"@context": "https://schema.org",
"@type": "FAQPage",
"mainEntity": [
{
"@type": "Question",
"name": j['setup'],
"acceptedAnswer": {
"@type": "Answer",
"text": j['punch']
}
} for j in a['jokes']
]
}
article_ld = {
"@context": "https://schema.org",
"@type": "Article",
"headline": a['title'],
"description": a['desc'],
"datePublished": a['date'],
"author": {"@type": "Organization", "name": a['author']},
"publisher": {"@type": "Organization", "name": SITE_NAME, "url": SITE_URL},
"url": SITE_URL + '/blog/%s/' % a['slug']
}
crumbs_ld = {
"@context": "https://schema.org",
"@type": "BreadcrumbList",
"itemListElement": [
{"@type": "ListItem", "position": 1, "name": "Home", "item": SITE_URL + '/'},
{"@type": "ListItem", "position": 2, "name": "Blog", "item": SITE_URL + '/blog/'},
{"@type": "ListItem", "position": 3, "name": a['title'], "item": SITE_URL + '/blog/%s/' % a['slug']}
]
}
extra = json_ld_script(article_ld) + '\n' + json_ld_script(crumbs_ld) + '\n' + json_ld_script(faq_ld)
return layout(a['title'], a['desc'], body, '/blog/%s/' % a['slug'], extra)
def page_index():
rnd = JOKES[(datetime.date.today().toordinal() * 7) % len(JOKES)]
d_idx = datetime.date.today().toordinal()
jod = JOKES[d_idx % len(JOKES)]
latest = JOKES[-12:][::-1]
live_topics = LIVE_TOPICS
topic_chips = ''.join('<a class="chip" href="/topic/%s/">%s %s</a>' % (
t['slug'], t['emoji'], esc(t['name'].replace('Dad Jokes About ', '').replace('Dad Jokes', 'Jokes')))
for t in live_topics)
cat_cards = ''.join(f"""
<a class="cat-card" href="/category/{c['slug']}/">
<span class="cat-emoji">{c['emoji']}</span>
<span class="cat-name">{esc(c['name'])}</span>
<span class="cat-count">{joke_count(c['slug'])} jokes</span>
</a>""" for c in CATS)
latest_cards = ''.join(joke_card(j) for j in latest)
body = f"""
<section class="hero wrap">
<h1>The Best Dad Jokes on the Internet</h1>
<p class="hero-sub">Short. Clean. Painfully punny. {len(JOKES)}+ jokes your kids don't want to hear but absolutely need to.</p>
<div class="hero-card">
<p class="joke-setup" data-hero-setup>{esc(rnd['setup'])}</p>
<div class="joke-punch" data-hero-punch>{esc(rnd['punch'])}</div>
<div class="hero-btns">
<button class="btn" data-hero-next>🎲 Another one</button>
<button class="btn btn-ghost" data-copy-hero>📋 Copy</button>
<button class="btn btn-ghost" data-share-hero>🖼️ Share as image</button>
</div>
</div>
</section>
<!-- AD_SLOT_TOP -->
<section class="wrap">
<div class="jod-banner">
<p class="jod-label">😄 Dad Joke of the Day</p>
<p class="joke-setup">{esc(jod['setup'])}</p>
<div class="joke-punch" data-punch>{esc(jod['punch'])}</div>
<p class="jod-more"><a href="/joke-of-the-day/">See the archive →</a></p>
</div>
</section>
<section class="wrap" id="all-cats">
<h2>Browse Dad Jokes by Category</h2>
<div class="cat-grid">{cat_cards}</div>
</section>
<section class="wrap" id="topics">
<h2>Popular Dad Joke Topics</h2>
<div class="chips">
{topic_chips}
</div>
</section>
<!-- AD_SLOT_MID -->
<section class="wrap">
<h2>Fresh Out of the Dad Oven</h2>
<div class="joke-grid">{latest_cards}</div>
<p class="center-link"><a class="btn" href="/dad-joke-generator/">Open the Dad Joke Generator →</a></p>
</section>
<section class="wrap seo-blurb">
<h2>What is a dad joke?</h2>
<p>A dad joke is a short, clean, pun-based joke delivered with maximum confidence and zero shame. It's the kind of joke that makes your kids groan, your wife roll her eyes, and your dog leave the room. Science has yet to explain why hearing one makes you feel briefly smarter and visibly worse at the same time.</p>
<p>This site is a growing collection of the best dad jokes on the internet: one-liners, knock-knock jokes, and puns about animals, food, work, school, sports, tech, space and more. Every joke is family-friendly — the only thing at risk of injury is everyone's patience. Start with the <a href="/dad-joke-generator/">dad joke generator</a>, browse the <a href="#all-cats">categories</a>, or come back every day for a new <a href="/joke-of-the-day/">dad joke of the day</a>.</p>
</section>"""
title = 'Best Dad Jokes — %d+ Funny, Clean Dad Jokes (One-Liners, Puns & Knock-Knocks)' % len(JOKES)
desc = ('%d clean, funny dad jokes: puns, one-liners, and knock-knocks by category. '
'Features a daily dad joke and free generator for maximum groans.'
% len(JOKES))
ld = {
"@context": "https://schema.org",
"@type": "WebSite",
"name": SITE_NAME,
"url": SITE_URL + '/',
"description": TAGLINE,
"potentialAction": {
"@type": "SearchAction",
"target": SITE_URL + "/search/?q={search_term_string}",
"query-input": "required name=search_term_string"
}
}
return layout(title, desc, body, '/', json_ld_script(ld))
def page_category(slug):
c = CAT_BY_SLUG[slug]
js = [j for j in JOKES if j['cat'] == slug]
cards = ''.join(joke_card(j) for j in js)
others = [o for o in CATS if o['slug'] != slug][:6]
others_html = ''.join('<a class="chip" href="/category/%s/">%s %s</a>' % (o['slug'], o['emoji'], esc(o['name'])) for o in others)
# Internal link loop: related topic clusters that overlap with this category
cat_topics = [
t for t in LIVE_TOPICS
if any(j['cat'] == slug for j in topic_jokes(t))
][:6]
topics_html = ''.join('<a class="chip" href="/topic/%s/">%s %s</a>' % (t['slug'], t['emoji'], esc(t['name'])) for t in cat_topics)
topic_section = f'<h2>Explore Related Joke Topics</h2><div class="chips" style="margin-bottom: 24px;">{topics_html}</div>' if topics_html else ''
body = f"""
<div class="wrap">
<nav class="crumbs"><a href="/">Home</a> › <span>{esc(c['name'])}</span></nav>
<h1>{c['emoji']} {esc(c['name'])}</h1>
<p class="page-sub">{esc(c['blurb'])} That's {len(js)} jokes of pure dad energy.</p>
<div class="joke-grid">{cards}</div>
<!-- AD_SLOT_CAT -->
{topic_section}
<h2>Keep the groans going</h2>
<div class="chips">{others_html}</div>
<p class="center-link"><a class="btn" href="/dad-joke-generator/">🎲 Random Dad Joke Generator</a></p>
</div>"""
title = '%d+ Best %s (Clean & Groan-Worthy) | Best Dad Jokes' % (len(js), c['name'])
if len(title) > 65:
title = '%d+ %s (Clean & Funny) | Best Dad Jokes' % (len(js), c['name'])
desc = 'The ultimate collection of %d+ %s! Clean, family-friendly puns, one-liners, and guaranteed groaners. Browse and share the best laughs.' % (len(js), c['name'].lower())
if len(desc) > 155:
desc = desc[:152] + '...'
ld = {"@context": "https://schema.org", "@type": "BreadcrumbList", "itemListElement": [
{"@type": "ListItem", "position": 1, "name": "Home", "item": SITE_URL + '/'},
{"@type": "ListItem", "position": 2, "name": c['name'], "item": SITE_URL + '/category/%s/' % slug}]}
faq_ld = {
"@context": "https://schema.org",
"@type": "FAQPage",
"mainEntity": [
{
"@type": "Question",
"name": j['setup'],
"acceptedAnswer": {
"@type": "Answer",
"text": j['punch']
}
} for j in js[:20]
]
}
return layout(title, desc, body, '/category/%s/' % slug, json_ld_script(ld) + '\n' + json_ld_script(faq_ld))
def topic_jokes(topic):
slug = topic['slug'] if isinstance(topic, dict) else topic
return TOPIC_JOKES_MAP.get(slug, [])
def page_topic(slug):
t = next(t for t in TOPICS if t['slug'] == slug)
js = topic_jokes(t)
if len(js) < MIN_TOPIC_JOKES:
return None
cards = ''.join(joke_card(j) for j in js)
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)]
other_topics = [live_topics[(t_idx + 1 + offset) % len(live_topics)] for offset in range(12)]
chips = ''.join('<a class="chip" href="/topic/%s/">%s %s</a>' % (o['slug'], o['emoji'], esc(o['name'].replace('Dad Jokes About ', '').replace('Dad Jokes', 'Jokes'))) for o in other_topics)
body = f"""
<div class="wrap">
<nav class="crumbs"><a href="/">Home</a> › <a href="/#topics">Topics</a> › <span>{esc(t['name'])}</span></nav>
<h1>{t['emoji']} {esc(t['name'])}</h1>
<p class="page-sub">{esc(t['intro'])} That's {len(js)} of them, carefully curated for maximum groan.</p>
<div class="joke-grid">{cards}</div>
<!-- Endless Joke Loop Navigation -->
<div class="loop-nav" style="margin: 3.5rem 0 2rem; padding: 2rem; background: var(--bg-alt); border-radius: 14px; border: 1px solid var(--border); box-shadow: 0 4px 12px rgba(0,0,0,0.04);">
<div style="text-align: center; margin-bottom: 1.5rem;">
<h3 style="margin: 0 0 0.5rem; font-size: 1.4rem;">Trapped in the Pun Loop? Don't Stop Now!</h3>
<p style="margin: 0; color: var(--muted); font-size: 0.95rem;">Keep rolling through more knee-slappers, groans, and instant family classics:</p>
</div>
<div style="display: flex; gap: 1rem; justify-content: space-between; align-items: stretch; flex-wrap: wrap;">
<a class="btn btn-ghost" href="/topic/{prev_t['slug']}/" style="flex: 1 1 240px; text-align: left; padding: 0.85rem 1.25rem;">
<span style="font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; display: block; color: var(--muted); margin-bottom: 0.25rem;">← Previous Category</span>
<strong style="font-size: 1rem;">{prev_t['emoji']} {esc(prev_t['name'])}</strong>
</a>
<a class="btn" href="/dad-joke-generator/" style="flex: 1 1 200px; display: flex; align-items: center; justify-content: center; font-weight: 600; padding: 0.85rem 1.25rem;">
🎲 Random Generator
</a>
<a class="btn btn-ghost" href="/topic/{next_t['slug']}/" style="flex: 1 1 240px; text-align: right; padding: 0.85rem 1.25rem;">
<span style="font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; display: block; color: var(--muted); margin-bottom: 0.25rem;">Next Category →</span>
<strong style="font-size: 1rem;">{next_t['emoji']} {esc(next_t['name'])}</strong>
</a>
</div>
<div style="display: flex; gap: 0.75rem; justify-content: center; flex-wrap: wrap; margin-top: 1.25rem; font-size: 0.9rem;">
<a href="/joke-of-the-day/" style="color: var(--accent); font-weight: 500;">☀️ Joke of the Day</a>
<span style="color: var(--border);">•</span>
<a href="/best-dad-gifts/" style="color: var(--accent); font-weight: 500;">🎁 Curated Dad Gifts</a>
<span style="color: var(--border);">•</span>
<a href="/blog/" style="color: var(--accent); font-weight: 500;">📚 Best Joke Lists</a>
</div>
</div>
<h2>Explore More Dad Joke Topics</h2>
<div class="chips">{chips}</div>
</div>"""
# High-CTR SEO Title and Meta Description
name_raw = t['name']
cluster = name_raw if ('Dad Jokes' in name_raw or 'Jokes' in name_raw) else f'Dad Jokes About {name_raw}'
short_cluster = cluster.replace('Why Did the Chicken ', '') if len(cluster) > 28 else cluster
title = f"{len(js)}+ {short_cluster} (Clean & Funny) | Best Dad Jokes"
if len(title) > 65:
title = f"{len(js)}+ {short_cluster} | Best Dad Jokes"
desc = None
for cand in js:
s = cand['setup'].strip()
if not s.endswith('?') or s.startswith(('Kid:', 'Patient:', 'Doctor:')) or 'anti-gravity' in s:
continue
s_clean = s.replace('"', "'").rstrip('?')
trial = f'Laugh out loud with {len(js)}+ {cluster.lower()}: "{s_clean}?" Read now for instant family-friendly groans!'
# Calculate escaped length since build.py uses esc(desc)
trial_escaped = html.escape(trial, quote=True)
if 115 <= len(trial_escaped) <= 158:
desc = trial
break
trial_alt = f'Groan along with {len(js)}+ {cluster.lower()}: "{s_clean}?" Clean, funny jokes for instant smiles!'
trial_alt_escaped = html.escape(trial_alt, quote=True)
if 115 <= len(trial_alt_escaped) <= 158:
desc = trial_alt
break
if not desc:
desc = f"Get ready to chuckle with {len(js)}+ hilarious {cluster.lower()}. 100% family-friendly, groan-worthy dad humor for kids and adults!"
if len(html.escape(desc, quote=True)) > 158:
desc = desc[:145] + '...'
faq_ld = {
"@context": "https://schema.org",
"@type": "FAQPage",
"mainEntity": [
{
"@type": "Question",
"name": j['setup'].replace('\n', ' '),
"acceptedAnswer": {
"@type": "Answer",
"text": j['punch']
}
} for j in js
]
}
crumbs_ld = {
"@context": "https://schema.org",
"@type": "BreadcrumbList",
"itemListElement": [
{"@type": "ListItem", "position": 1, "name": "Home", "item": SITE_URL + '/'},
{"@type": "ListItem", "position": 2, "name": "Topics", "item": SITE_URL + '/#topics'},
{"@type": "ListItem", "position": 3, "name": t['name'], "item": SITE_URL + '/topic/%s/' % slug}
]
}
return layout(title, desc, body, '/topic/%s/' % slug,
json_ld_script(faq_ld) + '\n' + json_ld_script(crumbs_ld))
def page_generator():
body = """
<div class="wrap narrow">
<h1>🎲 Dad Joke Generator</h1>
<p class="page-sub">One click. One random dad joke. Zero apologies. Works at parties, in the car line, and mid-argument.</p>
<div class="hero-card gen-card">
<p class="joke-setup" data-gen-setup>Click the button to summon a dad joke.</p>
<div class="joke-punch" data-gen-punch></div>
<div class="hero-btns">
<button class="btn" data-gen-next>🎲 Generate dad joke</button>
<button class="btn btn-ghost" data-gen-copy>📋 Copy</button>
<button class="btn btn-ghost" data-gen-share>🖼️ Share as image</button>
</div>
</div>
<h2>How to weaponize a dad joke</h2>
<ol class="plain-list">
<li><strong>Deliver with confidence.</strong> Eye contact is everything. The dad joke fears hesitation.</li>
<li><strong>Pause before the punchline.</strong> Let the suspense marinate. Then pounce.</li>
<li><strong>Ignore the groans.</strong> The groan is applause in dad dialect.</li>
<li><strong>Repeat the best ones.</strong> Repetition builds tradition. Tradition builds groans.</li>
</ol>
<p>Looking for something specific? <a href="/search/">Search all dad jokes</a> or browse by <a href="/#all-cats">category</a>.</p>
</div>"""
title = 'Dad Joke Generator — Random Dad Jokes, One Click'
desc = 'Press one button and get a random dad joke instantly. Hundreds of clean, funny dad jokes ready to embarrass your kids.'
return layout(title, desc, body, '/dad-joke-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 = JOKE_TOPICS_MAP.get(j['id'], [])[:3]
if not matching_topics:
# Guaranteed loop: pick 3 consistent live topics based on joke ID
matching_topics = [LIVE_TOPICS[(j['id'] + offset * 7) % len(LIVE_TOPICS)] for offset in range(3)]
topic_chips = ''.join('<a class="chip" href="/topic/%s/">%s %s</a>' % (t['slug'], t['emoji'], esc(t['name'])) for t in matching_topics)
topic_section = f'<div style="margin: 24px 0 16px;"><p style="font-weight: 600; margin-bottom: 8px;">Explore Related Topics:</p><div class="chips">{topic_chips}</div></div>' if topic_chips else ''
# Internal joke-reading loop: next/prev links and related same-category jokes:
prev_id = (j['id'] - 1) % len(JOKES)
next_id = (j['id'] + 1) % len(JOKES)
same_cat = [other for other in JOKES if other['cat'] == j['cat'] and other['id'] != j['id']]
rel1 = same_cat[j['id'] % len(same_cat)] if same_cat else None
rel2 = same_cat[(j['id'] + 7) % len(same_cat)] if len(same_cat) > 1 else None
related = [r for r in [rel1, rel2] if r]
related_cards = ''.join(joke_card(r) for r in related)
body = f"""
<div class="wrap narrow">
<nav class="crumbs"><a href="/">Home</a> › <a href="/category/{j['cat']}/">{esc(cat['name'])}</a> › <span>Joke #{j['id']}</span></nav>
<h1>Dad Joke #{j['id']}</h1>
<div class="jod-banner jod-page">
<p class="joke-setup">{esc(j['setup'])}</p>
<div class="joke-punch" data-punch>{esc(j['punch'])}</div>
<div class="hero-btns">
<button class="btn btn-ghost" onclick="navigator.clipboard.writeText('{esc(j['setup'])} ' + '{esc(j['punch'])}')">📋 Copy</button>
<button class="btn btn-ghost" data-jod-share>🖼️ Share as image</button>
</div>
</div>
<div class="hero-btns" style="margin-top: 18px; justify-content: space-between;">
<a class="btn btn-ghost" href="/joke/{prev_id}/">← Previous Joke</a>
<a class="btn" href="/joke/{next_id}/">Next Joke →</a>
</div>
{topic_section}
<h2>You Might Also Suffer From...</h2>
<div class="joke-grid" style="grid-template-columns: 1fr; margin-bottom: 24px;">{related_cards}</div>
<p class="center-link"><a class="btn" href="/category/{j['cat']}/">More {esc(cat['name'])} →</a></p>
<p class="center-link"><a class="btn btn-ghost" href="/dad-joke-generator/">Keep groaning (Random Joke) →</a></p>
<p class="center-link"><a class="btn btn-ghost" href="/joke-of-the-day/">Joke of the Day →</a></p>
</div>"""
title = '%s - Funny Dad Joke' % esc(j['setup'])
if len(title) > 60:
title = title[:57] + '...'
title = title + ' | BestDadJokes.lol'
desc = '%s %s' % (j['setup'], j['punch'])
if len(desc) > 155:
desc = desc[:152] + '...'
ld = {
"@context": "https://schema.org",
"@type": "QAPage",
"mainEntity": {
"@type": "Question",
"name": j['setup'],
"acceptedAnswer": {
"@type": "Answer",
"text": j['punch']
}
}
}
crumbs_ld = {
"@context": "https://schema.org",
"@type": "BreadcrumbList",
"itemListElement": [
{"@type": "ListItem", "position": 1, "name": "Home", "item": SITE_URL + '/'},
{"@type": "ListItem", "position": 2, "name": cat['name'], "item": SITE_URL + '/category/%s/' % j['cat']},
{"@type": "ListItem", "position": 3, "name": "Joke #%s" % j['id'], "item": SITE_URL + '/joke/%s/' % j['id']}
]
}
return layout(title, desc, body, '/joke/%s/' % j['id'], json_ld_script(ld) + '\n' + json_ld_script(crumbs_ld))
def page_jotd():
d = datetime.date.today()
j = JOKES[d.toordinal() % len(JOKES)]
body = f"""
<div class="wrap narrow">
<h1>😄 Dad Joke of the Day</h1>
<p class="page-sub">A brand-new dad joke every single day. Doctors recommend exactly one per day. We won't tell if you don't.</p>
<div class="jod-banner jod-page">
<p class="jod-date" data-jod-date>{d.strftime('%B %d, %Y')}</p>
<p class="joke-setup" data-jod-setup>{esc(j['setup'])}</p>
<div class="joke-punch" data-punch data-jod-punch>{esc(j['punch'])}</div>
<div class="hero-btns">
<button class="btn btn-ghost" data-jod-copy>📋 Copy</button>
<button class="btn btn-ghost" data-jod-share>🖼️ Share as image</button>
</div>
</div>
<h2>The dad joke archive</h2>
<p>Every recent dad joke of the day, one per day, no repeats (for a few months, anyway):</p>
<div class="archive" data-jod-archive></div>
<p class="center-link"><a class="btn" href="/dad-joke-generator/">Can't wait a whole day? Generator →</a></p>
</div>"""
title = 'Dad Joke of the Day — A New Funny Dad Joke Daily'
desc = "Today's dad joke of the day, plus the full archive. One clean, funny dad joke for every day of the year."
ld = {
"@context": "https://schema.org",
"@type": "ItemPage",
"name": "Dad Joke of the Day",
"url": SITE_URL + '/joke-of-the-day/',
"mainEntity": {
"@type": "CreativeWork",
"name": j['setup'],
"text": j['punch']
}
}
return layout(title, desc, body, '/joke-of-the-day/',
'<link rel="canonical" href="%s/joke-of-the-day/">' % SITE_URL +
json_ld_script(ld))
def page_search():
body = """
<div class="wrap narrow">
<h1>🔎 Search Dad Jokes</h1>
<p class="page-sub">Looking for a dad joke about coffee, cats, or cardio? Type it in. We probably have a pun for that.</p>
<form class="search-form" onsubmit="return false;">
<input type="search" id="search-box" placeholder="Try 'pizza', 'cow', 'work'..." autocomplete="off">
</form>
<p class="search-count" data-search-count></p>
<div class="joke-grid" data-search-results></div>
<p data-search-empty style="display:none">No jokes matched. Which, honestly, is a great setup for a new dad joke — send it to us via the <a href="/contact/">contact page</a>.</p>
</div>"""
title = 'Search Dad Jokes — Find a Dad Joke About Anything'
desc = 'Search hundreds of clean dad jokes by keyword. Find puns and one-liners about any topic instantly.'
return layout(title, desc, body, '/search/')
def page_about():
body = """
<div class="wrap narrow">
<h1>👋 About Best Dad Jokes</h1>
<p>Welcome to <strong>BestDadJokes.lol</strong> — a growing collection of the internet's best dad jokes: short, clean, pun-heavy, and delivered with the quiet confidence only a dad can muster.</p>
<p>The mission is simple: build the most useful dad joke resource on the internet. That means:</p>
<ul class="plain-list">
<li><strong>Curated, not scraped.</strong> Every joke is hand-picked for maximum groan. If it doesn't make someone audibly sigh, it doesn't make the cut.</li>
<li><strong>Family-friendly, always.</strong> Clean humor that's safe to tell at the dinner table, the office, or the school pickup line.</li>
<li><strong>Fast and simple.</strong> No pop-ups, no logins, no nonsense. Just jokes.</li>
</ul>
<h2>Why dad jokes?</h2>
<p>Because a dad joke is never just a joke. It's a love language. It's saying "I would rather embarrass myself than miss a chance to make you laugh." Also, they're free, and this is a budget operation.</p>
<h2>Get in touch</h2>
<p>Got a joke that deserves to be here? Found a bug? Want to license 300 dad jokes for your family group chat? Head to the <a href="/contact/">contact page</a>.</p>
</div>"""
title = 'About — Best Dad Jokes .lol'
desc = 'BestDadJokes.lol is a curated collection of clean, funny dad jokes. Hand-picked jokes, family-friendly humor, zero nonsense.'
return layout(title, desc, body, '/about/')
def page_contact():
body = """
<div class="wrap narrow">
<h1>📮 Contact</h1>
<p>Want to send us the greatest dad joke of all time? Report a joke that's more "dad" than "joke"? Tell us the site made you laugh so hard you spilled your coffee? We read everything.</p>
<p>Email us at <a href="mailto:hello@bestdadjokes.lol">hello@bestdadjokes.lol</a> — responses may be delayed by naps.</p>
<h2>Joke submissions</h2>
<p>Include the setup and the punchline in your email. If we use it, you get full bragging rights and absolutely no money, which is exactly how dad economics works.</p>
</div>"""
title = 'Contact — Best Dad Jokes .lol'
desc = 'Get in touch with BestDadJokes.lol — submit a dad joke, say hi, or report a bug.'
return layout(title, desc, body, '/contact/')
def page_privacy():
body = """
<div class="wrap narrow">
<h1>Privacy Policy</h1>
<p class="page-sub">Last updated: %s</p>
<p>BestDadJokes.lol respects your privacy, which is ironic because dads famously respect nothing more than a good interruption. Here's the deal in plain English:</p>
<h2>What we collect</h2>
<p>We keep standard web server logs (IP address, browser type, pages visited) for security and aggregate traffic statistics. We do not ask for your name, email, or your kids' report cards. There are no accounts on this site.</p>
<h2>Cookies and advertising</h2>
<p>We may display advertising on this site to keep it free. Advertising partners, which may include Google, use cookies and similar technologies to serve ads based on your prior visits to this and other websites.</p>
<p>Google's use of advertising cookies enables it and its partners to serve ads based on your visits to this site and/or other sites on the Internet. You may opt out of personalized advertising by visiting <a href="https://www.google.com/settings/ads" rel="nofollow noopener">Google Ads Settings</a>, or opt out of third-party vendor cookies at <a href="https://www.aboutads.info" rel="nofollow noopener">aboutads.info</a>.</p>
<p>If we run a consent banner for visitors from the EEA/UK, your choices will be honored and stored locally.</p>
<h2>Analytics</h2>
<p>We use aggregate, privacy-respecting analytics to count page views and understand which categories people enjoy. This data cannot reasonably be used to identify you.</p>
<h2>Data sharing</h2>
<p>We do not sell personal data. We have no personal data to sell. We barely have data.</p>
<h2>Children</h2>
<p>Content on this site is family-friendly by design. The site is not directed at children under 13, and we do not knowingly collect personal information from children.</p>
<h2>Contact</h2>
<p>Questions about this policy? Email <a href="mailto:hello@bestdadjokes.lol">hello@bestdadjokes.lol</a>.</p>
</div>""" % datetime.date.today().strftime('%B %d, %Y')
title = 'Privacy Policy — Best Dad Jokes .lol'
desc = 'Privacy policy for BestDadJokes.lol — what we collect (very little), cookies, advertising, and your choices.'
return layout(title, desc, body, '/privacy-policy/')
def page_terms():
body = """
<div class="wrap narrow">
<h1>Terms of Use</h1>
<p class="page-sub">Last updated: %s</p>
<p>By using BestDadJokes.lol you agree to the following terms. Reading them aloud in a dad voice is optional but encouraged.</p>
<h2>Use of content</h2>
<p>The jokes on this site are provided for personal, non-commercial enjoyment. Share them freely at dinner tables, offices, and group chats. If you want to republish jokes in bulk or use this site commercially, contact us first — we're reasonable people.</p>
<h2>No warranties</h2>
<p>This site is provided "as is." We make no guarantees that jokes will be funny, that groans will be produced, or that your teenagers will acknowledge your existence. All comedic risk is yours.</p>
<h2>Limitation of liability</h2>
<p>To the fullest extent permitted by law, BestDadJokes.lol is not liable for any damages arising from use of the site, including but not limited to eye-rolling, sighing, involuntary chuckling, and children hiding your phone.</p>
<h2>External links</h2>
<p>We are not responsible for the content of external websites, including their jokes, which are almost certainly worse than ours.</p>
<h2>Changes</h2>
<p>We may update these terms occasionally. Continued use of the site means you accept the updated terms, and possibly a fresh dad joke.</p>
</div>""" % datetime.date.today().strftime('%B %d, %Y')
title = 'Terms of Use — Best Dad Jokes .lol'
desc = 'Terms of use for BestDadJokes.lol.'
return layout(title, desc, body, '/terms/')
def page_gifts():
body = """<section class="hero hero-sm">
<div class="wrap">
<span class="badge">🎁 Gift Guide & Merch</span>
<h1 class="hero-h1">The Best Gifts for Dads Who Love Dad Jokes</h1>
<p class="hero-sub">Hand-picked gear, books, and novelty gifts for dads who never miss an opportunity to deliver a punchline.</p>
</div>
</section>
<section class="section">
<div class="wrap grid-3">
<div class="card">
<span style="font-size: 2.5rem;">📖</span>
<h3 style="margin: 0.5rem 0;">Exceptionally Bad Dad Jokes</h3>
<p style="color: var(--text-muted); font-size: 0.9rem; margin-bottom: 1rem;">Spiffing illustrated book of painfully terrible dad jokes, puns, and one-liners.</p>
<a href="https://www.amazon.com/dp/1643400940?tag=bestdadjokes-20" target="_blank" rel="noopener sponsored" class="btn btn-outline" style="display:inline-block; text-align:center;">View on Amazon →</a>
</div>
<div class="card">
<span style="font-size: 2.5rem;">☕</span>
<h3 style="margin: 0.5rem 0;">'I Tell Dad Jokes Periodically' Mug</h3>
<p style="color: var(--text-muted); font-size: 0.9rem; margin-bottom: 1rem;">Ceramic science-pun coffee mug guaranteed to elicit eye-rolls before breakfast.</p>
<a href="https://www.amazon.com/dp/B088BH43BG?tag=bestdadjokes-20" target="_blank" rel="noopener sponsored" class="btn btn-outline" style="display:inline-block; text-align:center;">View on Amazon →</a>
</div>
<div class="card">
<span style="font-size: 2.5rem;">👕</span>
<h3 style="margin: 0.5rem 0;">'Hi Hungry, I'm Dad' Classic Tee</h3>
<p style="color: var(--text-muted); font-size: 0.9rem; margin-bottom: 1rem;">100% cotton tee featuring the undisputed king of all dad retorts.</p>
<a href="https://www.amazon.com/dp/B07N11Y4VN?tag=bestdadjokes-20" target="_blank" rel="noopener sponsored" class="btn btn-outline" style="display:inline-block; text-align:center;">View on Amazon →</a>
</div>
</div>
<div class="wrap" style="margin-top: 3rem; text-align: center;">
<p style="font-size: 0.85rem; color: var(--text-muted);">Disclosure: When you purchase through links on our site, we may earn an affiliate commission at no extra cost to you.</p>
</div>
</section>"""
return layout('Best Gifts for Dads Who Love Dad Jokes · Best Dad Jokes',
'Hand-picked gear, books, and novelty gifts for dads who love groan-worthy humor.',
body, '/best-dad-gifts/')
def page_404():
body = """
<div class="wrap narrow center">
<h1>404</h1>
<p class="page-sub">This page is like a dad joke that got cut from the site — it just didn't land.</p>
<div class="hero-card">
<p class="joke-setup">Why did the web page go to therapy?</p>
<div class="joke-punch" data-punch>It had too many broken links.</div>
</div>
<p><a class="btn" href="/">Take me home →</a></p>
</div>"""
return layout('404 — Page Not Found', 'Page not found. The joke is on us.', body, '/404.html')
def write(path, content):
full = os.path.join(SITE_DIR, path)
os.makedirs(os.path.dirname(full), exist_ok=True)
with open(full, 'w') as f:
f.write(content)
def build():
if os.path.exists(SITE_DIR):
shutil.rmtree(SITE_DIR)
os.makedirs(SITE_DIR)
# static assets
st = os.path.join(SITE_DIR, 'static')
os.makedirs(st, exist_ok=True)
for fn in os.listdir(STATIC):
shutil.copy(os.path.join(STATIC, fn), st)
# jokes data for client-side JS
payload = {
'categories': [{'slug': c['slug'], 'name': c['name'], 'emoji': c['emoji']} for c in CATS],
'jokes': [{'id': j['id'], 'cat': j['cat'], 'type': j.get('type', 'qa'),
's': j['setup'], 'p': j['punch']} for j in JOKES]}
write('static/jokes-data.js',
'window.BDJ=%s;' % json.dumps(payload, ensure_ascii=False, separators=(',', ':')))
write('index.html', page_index())
for c in CATS:
write('category/%s/index.html' % c['slug'], page_category(c['slug']))
for t in TOPICS:
page = page_topic(t['slug'])
if page:
write('topic/%s/index.html' % t['slug'], page)
write('dad-joke-generator/index.html', page_generator())
write('joke-of-the-day/index.html', page_jotd())
write('blog/index.html', page_blog_index())
for a in BLOG_ARTICLES:
write('blog/%s/index.html' % a['slug'], page_blog_article(a))
for j in JOKES:
write('joke/%s/index.html' % j['id'], page_joke(j))
write('search/index.html', page_search())
write('about/index.html', page_about())
write('contact/index.html', page_contact())
write('privacy-policy/index.html', page_privacy())
write('terms/index.html', page_terms())
write('best-dad-gifts/index.html', page_gifts())
write('404.html', page_404())
# robots + sitemap
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 LIVE_TOPICS] + ['/joke/%s/' % j['id'] for j in JOKES]
robots_content = """# robots.txt for bestdadjokes.lol
User-agent: *
Allow: /
# Explicit AI Search & Discovery Crawlers
User-agent: GPTBot
Allow: /
User-agent: OAI-SearchBot
Allow: /
User-agent: PerplexityBot
Allow: /
User-agent: ClaudeBot
Allow: /
User-agent: Google-Extended
Allow: /
User-agent: Applebot-Extended
Allow: /
Sitemap: %s/sitemap.xml
""" % SITE_URL
write('robots.txt', robots_content)
llms_content = f"""# Best Dad Jokes (bestdadjokes.lol)
> 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(LIVE_TOPICS)} targeted topic clusters. All jokes are formatted for high clarity, instant reading, and family entertainment.
## Core Hubs & Curated Lists
- [Home](https://bestdadjokes.lol/): Daily featured jokes, random joke generator, and popular categories.
- [Blog & Curated Lists](https://bestdadjokes.lol/blog/): High-intent curated lists with quick-copy formatting.
- [12 Thanksgiving Dad Jokes That Will Make the Whole Table Groan](https://bestdadjokes.lol/blog/thanksgiving-dad-jokes-that-will-make-the-table-groan/)
- [15 Clean Halloween Dad Jokes for Kids & Trick-or-Treaters](https://bestdadjokes.lol/blog/clean-halloween-dad-jokes-for-kids-and-trick-or-treaters/)
- [15 Best Dad Jokes for Kids (School-Safe Puns & Groaners)](https://bestdadjokes.lol/blog/best-dad-jokes-for-kids-school-safe-puns/)
- [Joke of the Day](https://bestdadjokes.lol/joke-of-the-day/): Daily refreshed family joke.
- [Dad Joke Generator](https://bestdadjokes.lol/dad-joke-generator/): Instant randomized joke player.
- [Search Dad Jokes](https://bestdadjokes.lol/search/): Instant search across all 430+ jokes.
- [Dad Gifts & Merch](https://bestdadjokes.lol/best-dad-gifts/): Curated gift guide and funny gear for dads who love dad jokes.
## Seasonal & Holiday Clusters
- [Thanksgiving Dad Jokes](https://bestdadjokes.lol/topic/thanksgiving-dad-jokes/): Clean turkey puns, feast humor, and pilgrim jokes.
- [Halloween Dad Jokes](https://bestdadjokes.lol/topic/halloween-dad-jokes/): Ghost, skeleton, and spooky family-safe puns.
- [Christmas Dad Jokes](https://bestdadjokes.lol/topic/christmas-dad-jokes/): Santa, elf, and winter holiday humor.
- [Dad Jokes for Kids](https://bestdadjokes.lol/topic/dad-jokes-for-kids/): Elementary-safe puns and animal humor.
- [Work Dad Jokes](https://bestdadjokes.lol/topic/work-dad-jokes/): Clean office jokes and water-cooler puns.
## Open APIs for AI & Bots
- [Random Dad Joke API (JSON)](https://bestdadjokes.lol/api/v1/random.json): Returns a single clean dad joke in JSON format (`{{id, setup, punchline, category}}`).
- [Today's Joke of the Day API (JSON)](https://bestdadjokes.lol/api/v1/today.json): Returns the canonical joke of the day.
"""
write('llms.txt', llms_content)
today = datetime.date.today().isoformat()
sm = ['<?xml version="1.0" encoding="UTF-8"?>',
'<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">']
for p in pages:
# Hierarchical SEO crawl prioritization:
if p == '/':
freq, pri = 'daily', '1.0'
elif p in ('/dad-joke-generator/', '/joke-of-the-day/'):
freq, pri = 'daily', '0.9'
elif '/topic/' in p or p == '/blog/':
freq, pri = 'daily', '0.8'
elif '/category/' in p or '/blog/' in p:
freq, pri = 'weekly', '0.7'
elif '/joke/' in p:
freq, pri = 'weekly', '0.6'
else:
freq, pri = 'monthly', '0.5'
sm.append('<url><loc>%s%s</loc><lastmod>%s</lastmod><changefreq>%s</changefreq><priority>%s</priority></url>'
% (SITE_URL, p, today, freq, pri))
sm.append('</urlset>')
write('sitemap.xml', '\n'.join(sm) + '\n')
# RSS: dad joke of the day feed, last 21 days
from email.utils import formatdate
now_ts = datetime.datetime.utcnow().timestamp()
items = []
for back in range(21):
d = datetime.date.today() - datetime.timedelta(days=back)
j = JOKES[d.toordinal() % len(JOKES)]
ts = now_ts - back * 86400
items.append(
'<item><title>%s</title><link>%s/joke-of-the-day/?d=%s</link>'
'<guid isPermaLink="false">bjd-daily-%s</guid>'
'<pubDate>%s</pubDate><description>%s — %s</description></item>'
% (esc('Dad Joke of the Day — %s' % d.strftime('%b %d')), SITE_URL, d.isoformat(),
d.isoformat(), formatdate(ts), esc(j['setup']), esc(j['punch'])))
rss = ('<?xml version="1.0" encoding="UTF-8"?>'
'<rss version="2.0"><channel><title>%s — Dad Joke of the Day</title>'
'<link>%s/joke-of-the-day/</link><description>%s</description>'
'<language>en-us</language>%s</channel></rss>'
% (esc(SITE_NAME), SITE_URL, esc(TAGLINE), ''.join(items)))
write('rss.xml', rss)
# free JSON API
rnd = JOKES[(datetime.datetime.utcnow().microsecond // 1000) * len(JOKES) // 1000]
tod = JOKES[datetime.date.today().toordinal() % len(JOKES)]
def api_j(j):
return json.dumps({'setup': j['setup'], 'punchline': j['punch'], 'type': j.get('type', 'qa'),
'category': j['cat'],
'source': SITE_URL + '/category/%s/#joke-%d' % (j['cat'], j['id'])},
ensure_ascii=False)
write('api/v1/random.json', api_j(rnd))
write('api/v1/today.json', api_j(tod))
total = sum(os.path.getsize(os.path.join(dp, f)) for dp, dn, fn in os.walk(SITE_DIR) for f in fn)
nfiles = sum(len(fn) for dp, dn, fn in os.walk(SITE_DIR))
print('Built %d files into %s (%d bytes)' % (nfiles, SITE_DIR, total))
if __name__ == '__main__':
build()