← Back

add-fitur-comments-django-with-giscus.app

debugging django giscus

Errors

  • data-stylesheet attribute doesn't exist in Giscus — caused 0 rules in CSS
  • WhiteNoise CompressedStaticFilesStorage served truncated CSS (3855 bytes vs 4667 on disk)
  • CORS block: Giscus iframe at giscus.app cannot fetch CSS from localhost:9000
  • Giscus cache: old broken data-stylesheet response cached, ?v= query string insufficient

Context

  • Blog: CodeNest Journal (Django 5.2, Docker, WhiteNoise, Cloudflare Tunnel)
  • Repo: endogh/codelifelog (private), discussions at endogh/blog-discussions (public)
  • Giscus config: data-theme pointing to custom CSS URL at log.codenest.id

Problem

Add comment section to every blog post. Need to: 1. Setup Giscus with dedicated discussions repo 2. Apply custom dark theme matching site palette 3. Make it work on production (localhost testing impossible for Giscus iframe CSS)

Investigation

  • Compared static/css/ source vs staticfiles/css/ output — sizes mismatch
  • Validated CSS syntax: braces balanced in source, truncated in served version
  • Traced CompressedStaticFilesStorage as the culprit — stale compressed cache
  • Verified CORS headers: Access-Control-Allow-Origin: * present but irrelevant for localhost

Root Cause

Three layered issues: 1. Wrong Giscus attribute (data-stylesheet → data-theme) 2. WhiteNoise served stale/truncated CSS from compressed cache 3. Localhost CSS URL inaccessible from Giscus iframe (network, not CORS headers)

Solution

  • Use data-theme (not data-stylesheet) with absolute URL
  • Custom CSS using GitHub Primer main { --color-*: } variables
  • Clean staticfiles cache + recollect before deploy
  • Push to production for testing (localhost impossible)

Insight

  • Giscus loads custom CSS inside its own iframe — must be publicly accessible
  • CompressedStaticFilesStorage can serve different content than source file
  • Giscus aggressive cache requires file rename (not query string) for cache bust

Gotchas

  • [00:20:37] penempatan comment masih kacau — script di extra_js block render setelah footer
  • [00:39:42] update color scheme comment — wrong approach (class-based vs CSS variables)
  • [01:01:33] color scheme not applied — data-stylesheet doesn't exist, need data-theme
  • [01:15:00] CSS 0 rules — WhiteNoise stale cache serving truncated file
  • [01:30:00] CORS localhost — Giscus iframe can't reach localhost, production only

Last updated 19 Aug 2026 00:23

Comments