Skip to content

Add PostHog analytics, comprehensive SEO, and amber favicon#5

Merged
jonathanmoore merged 3 commits into
mainfrom
docs-analytics-seo-favicon
Apr 9, 2026
Merged

Add PostHog analytics, comprehensive SEO, and amber favicon#5
jonathanmoore merged 3 commits into
mainfrom
docs-analytics-seo-favicon

Conversation

@jonathanmoore
Copy link
Copy Markdown
Owner

Summary

Adds comprehensive analytics tracking, SEO optimization, and brand-aligned favicon to the VitePress documentation site.

Part 1: PostHog Analytics Integration ✅

  • Full event tracking: pageviews, search queries, outbound links, code copy
  • Privacy-focused config: identified_only profiles, no autocapture, no PII
  • Debounced search tracking (3+ chars, 500ms delay)
  • MutationObserver for dynamic search input detection
  • Events tracked:
    • $pageview - Every route change in SPA
    • docs_search - Search queries with result count
    • outbound_link_click - External links with context
    • code_copied - Code block copies with language

Part 2: SEO Enhancements ✅

  • Open Graph tags: og:image, og:site_name, og:locale for social sharing
  • Twitter Card tags: Large image card with brand assets
  • Structured data: JSON-LD with TechArticle schema for Google rich results
  • Auto-generated meta descriptions: From first paragraph of each page
  • Canonical URLs: Per-page via transformPageData hook
  • Sitemap.xml: Auto-generated with priorities and change frequencies
  • Theme color meta: Brand amber (#D4974A)

Part 3: Favicon Updates ✅

  • Updated favicon.svg background: dark (#141414) → amber (#D4974A)
  • Generated PNG favicons: 32x32, 16x16, 180x180 (apple-touch-icon)
  • Complete fallback chain for cross-browser/platform support
  • Created favicon generation script using sharp package

Testing Checklist

In the Netlify preview:

PostHog Analytics

  • Open browser DevTools console
  • Navigate between pages → verify no console errors
  • Use local search → verify docs_search events in PostHog
  • Click external link (GitHub) → verify outbound_link_click event
  • Copy a code block → verify code_copied event
  • Check PostHog dashboard for real-time events

SEO Meta Tags

Favicon

  • Check browser tab → amber "K" favicon visible
  • Test in Safari, Chrome, Firefox
  • Save to iPhone home screen → verify apple-touch-icon

Benefits

Analytics: Full visibility into docs usage patterns, popular pages, search behavior, and user engagement
SEO: Improved search engine discoverability, rich snippets in Google, better social sharing
Brand: Consistent amber (#D4974A) branding across all platforms
Privacy: Anonymous analytics, no PII tracking, GDPR-friendly

Files Changed

  • docs/.vitepress/config.js - SEO meta, sitemap, transformPageData
  • docs/.vitepress/theme/index.js - PostHog integration
  • docs/.vitepress/theme/posthog.js - PostHog setup with VitePress router
  • docs/.vitepress/theme/track-clicks.js - Click event tracking
  • docs/public/favicon.svg - Amber background
  • docs/public/*.png - Generated PNG favicons
  • package.json - Added posthog-js, sharp
  • scripts/generate-favicons.js - Favicon generation utility

🤖 Generated with Claude Code

jonathanmoore and others added 2 commits April 9, 2026 16:41
Part 1: PostHog Analytics Integration
- Install posthog-js package for event tracking
- Create PostHog plugin with manual pageview tracking for SPA
- Add click tracking for outbound links and code copy events
- Implement search query tracking with debouncing
- Track events: $pageview, docs_search, outbound_link_click, code_copied
- Privacy-focused config: identified_only profiles, no autocapture

Part 2: SEO Enhancements
- Add Open Graph meta tags (og:image, og:site_name, og:locale)
- Add Twitter Card meta tags for rich social sharing
- Implement structured data (JSON-LD) with TechArticle schema
- Auto-generate meta descriptions from first paragraph
- Add per-page canonical URLs via transformPageData
- Generate sitemap.xml with priorities and change frequencies
- Add theme-color meta tag with brand amber (#D4974A)

Part 3: Favicon Updates
- Update favicon.svg background from dark (#141414) to amber (#D4974A)
- Generate PNG favicons: 32x32, 16x16, 180x180 (apple-touch-icon)
- Add favicon generation script using sharp package
- Update head config with complete favicon fallback chain

Benefits:
- Full visibility into docs usage patterns and search behavior
- Improved search engine discoverability and rich snippets
- Better social sharing preview experience
- Brand-aligned favicon across all platforms
- Privacy-respecting analytics (no PII, anonymous tracking)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Change router.onAfterRouteChanged from property assignment to method call
- Remove router.isReady() which doesn't exist in VitePress router
- Use setTimeout instead for DOM-ready timing
- Add defensive check for router methods before calling

This fixes the console errors:
- "router.afterEach is not a function"
- "router.isReady is not a function"

VitePress uses a custom router implementation, not standard Vue Router.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@netlify
Copy link
Copy Markdown

netlify Bot commented Apr 9, 2026

Deploy Preview for kona-theme ready!

Name Link
🔨 Latest commit 3e16cd7
🔍 Latest deploy log https://app.netlify.com/projects/kona-theme/deploys/69d81fb717b981000947c40e
😎 Deploy Preview https://deploy-preview-5--kona-theme.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 9, 2026

Preview theme deployed

Theme: PR #5 - docs-analytics-seo-favicon

Preview Open store preview
Editor Open theme editor

- Remove unused 'to' parameter in PostHog route change callback
- Delete one-time generate-favicons.js script (PNGs already generated)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@jonathanmoore jonathanmoore merged commit 8e62785 into main Apr 9, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant