How to Add a Seasonal Theme to Your Website (Halloween Example)

By Marko Denic
Contents
  1. Demo: flip the switch.
  2. 1. Turn it on by date, on the server
  3. 2. Load the theme files only inside the window
  4. 3. Swap the palette with CSS variables
  5. 4. Draw decorations that stay out of the way
  6. 5. Respect reduced motion
  7. Swap a few words, too
  8. Watch out for page caching
  9. FAQ

A seasonal theme is a temporary layer on top of your normal site: one date check on the server that loads an extra stylesheet and script, a palette swap done with CSS variables, and decorations that never get in the way. When the dates pass, it turns itself off. No deploy, no cleanup.

For Halloween, this site got a pumpkin palette, cobwebs, a hanging spider and a few bats. You can still see it at markodenic.com/?halloween. Here is how it works, so you can reuse it for any holiday.

Demo: flip the switch.

I build fast, beautifulspooky websites.

Read the blog

1. Turn it on by date, on the server

Decide on the server, not in the browser, so the themed page arrives in the first paint with no flash of the normal colors. Compare month and day only (m-d), so the same code works every year. A window that crosses New Year needs || instead of &&. The query parameter is a preview switch that works any day of the year.

current_time() uses the timezone set in WordPress. Outside WordPress, use date('m-d') and check your server’s timezone.

php
function md_seasonal_theme() {
    if (isset($_GET['halloween'])) {
        return 'halloween';
    }

    $today = current_time('m-d');

    if ($today >= '10-25' && $today <= '11-01') {
        return 'halloween';
    }

    // Wraps the new year, so it's an OR, not an AND.
    if ($today >= '12-15' || $today <= '01-06') {
        return 'winter';
    }

    return null;
}

2. Load the theme files only inside the window

The seasonal CSS goes in the head, after your main stylesheet, and the script goes before </body>. Outside the window, visitors download nothing extra. The file name comes from the function above, never straight from the URL, so nobody can make the page load a file of their choice.

php
<!-- header.php, after the main stylesheet -->
<?php if ($season = md_seasonal_theme()): ?>
    <link rel="stylesheet" href="<?php echo get_stylesheet_directory_uri(); ?>/seasonal/<?php echo $season; ?>.css">
<?php endif; ?>

<!-- footer.php -->
<?php if ($season = md_seasonal_theme()): ?>
    <script type="module" src="<?php echo get_stylesheet_directory_uri(); ?>/seasonal/<?php echo $season; ?>.js"></script>
<?php endif; ?>

3. Swap the palette with CSS variables

If your colors already live in CSS custom properties, the whole recolor is a few lines. The seasonal file loads after the main one, so its :root rules win the tie. Override your dark mode selector too, or dark mode keeps the old accent. Check the new accent’s contrast against your backgrounds, because orange text on white fails much sooner than blue does. Orange reads as fun and energetic (more on that in the psychology of colors in web design), and a purple-black background does the rest in dark mode. Need a starting point? Pick from these shades of orange.

css
/* halloween.css */
:root {
    --color-primary: oklch(0.6 0.19 45);
    --color-bg-secondary: oklch(0.97 0.02 70);
}

.dark {
    --color-bg: oklch(0.13 0.025 300);
    --color-primary: oklch(0.72 0.18 55);
}

4. Draw decorations that stay out of the way

Add decorations with JavaScript as fixed SVGs, so your templates stay untouched. pointer-events: none lets clicks go straight through them, and keeping them in the corners or the margins outside the content column means they never cover text. Setting pathLength="1" on each path lets one dash animation draw any shape, whatever its real length: the cobweb above draws itself strand by strand this way. The spider follows the page as you scroll with a requestAnimationFrame loop.

css
.web {
    position: fixed;
    top: 0;
    right: 0;
    z-index: 60;
    width: 280px;
    pointer-events: none;
}

/* each <path pathLength="1" style="--d: 0.2s"> */
.web path {
    fill: none;
    stroke: currentColor;
    stroke-dasharray: 1;
    stroke-dashoffset: 1;
    animation: draw 0.7s ease-out var(--d) forwards;
}

@keyframes draw {
    to { stroke-dashoffset: 0; }
}

5. Respect reduced motion

Swinging spiders and flying bats are exactly what prefers-reduced-motion exists for. Keep the still parts (palette, cobwebs) for everyone and skip anything that moves. Remove one-off elements like the bats when their animation ends, so they don’t sit in the DOM all day.

javascript
const reduced = matchMedia('(prefers-reduced-motion: reduce)').matches;

web(); // a still cobweb is fine for everyone

if (!reduced) {
    spider();
    bats();
}

// in bats(): clean up once a bat has crossed the screen
bat.addEventListener('animationend', (e) => e.target === bat && bat.remove());

Swap a few words, too

Colors alone read as a bug. One or two copy changes make it feel intentional: here the homepage headline says “spooky” instead of “beautiful”. Do it in the template with the same check, and update any aria-label that describes the changed content.

A small easter egg goes a long way. Click the spider and it runs back up its thread, with a short message in a role="status" element so screen readers announce it.

Watch out for page caching

A full-page cache (a caching plugin, a CDN that caches HTML) stores the page with or without the theme and keeps serving that copy until it expires. Purge the cache on the first and the day after the last day, or the theme starts and ends late.

FAQ

Does a seasonal theme hurt SEO?

No, as long as URLs and the main content stay the same. Changing a word in a heading for a few days is fine. Make sure your canonical URL ignores query strings, so the ?halloween preview isn’t treated as a separate page.

Does it slow the site down?

Only inside the window, and only by the extra files. Here that’s about 4 KB of CSS and 4 KB of JavaScript, loaded as a module script, which is deferred by default, so it never blocks rendering.

How do I do this on a static site without PHP?

Run the same m-d check in a small inline script in the <head> and add a class to <html>, then scope the seasonal CSS to that class. Because it runs before the first paint, there’s no flash. The date then comes from the visitor’s clock, not the server’s.

Should visitors be able to turn it off?

If the theme only changes colors and adds still decorations, no. If you add sound, or anything that moves all the time, yes: give them a way to turn it off.