USB for Typecho — a theme in the style of the U.SB blog

USB for Typecho

A Typecho theme by aijun modeled on the look of the U.SB blog, with light and dark color schemes

Overview

USB for Typecho is a Typecho theme built by aijun following the visual language of U.SB Design. Clean card-based layouts and a carefully tuned light/dark pair are the whole idea. There's no jQuery, no build step, and no separate backend — every front-end asset (JS, CSS, fonts, images) ships locally with the theme, so it makes zero requests to outside resources. It's pure Typecho templates plus native CSS and JS. Install it and it works.

Basics

ItemDetails
Theme nameUSB
Current version1.0.3 (changelog, 2026.10.01)
Works withTypecho 1.3.0
Demohttp://usb.nipang.cn/
Best forTech blogs, personal knowledge bases, long-form Markdown, project logs, experience write-ups
Theme modesLight, dark, follow system — and it remembers whatever the visitor picked by hand
Front-end dependenciesNo jQuery, no framework, no external fonts, no third-party CDN
LicenseTheme code is under the MIT License
DownloadUSB 1.0.3.zip(588.2KB)

Features

Look and theme

  • Light and dark schemes, with a default policy of follow system / light / dark set in the admin panel
  • Visitors can switch themes by hand and the choice is remembered locally (localStorage); with no manual choice it follows the system
  • One accent color in dark mode — a golden #ffcc00 — that keeps links, navigation, and buttons in harmony
  • Smooth theme transitions, styled scrollbars, tooltip bubbles, and other small refinements
  • The header logo switches automatically between a light and a dark image, with an adjustable height

Layout and typography

  • A starfield hero on the home page (twinkling stars plus star/heart trails that follow the cursor, disabled automatically under prefers-reduced-motion)
  • Two-column post cards on the home and archive pages: title, date, word count, reading time, excerpt, tag pills
  • Fully responsive: two columns on desktop, a single column with a hamburger menu on mobile
  • .prose typography for post bodies: dotted underlines on inline links, a wavy highlight on hover

Post pages

  • A floating table of contents (ToC): pinned to the side on wide screens, a drawer opened from a bottom button on mobile
  • Word count and estimated reading time (characters for Chinese, words for English, at roughly 300 per minute)
  • A post info card: title, permalink, author, publish date, last edited, license, tags
  • Ad slot: custom ad HTML, with a default placeholder ad when left empty
  • Sharing: Mastodon, X, Bluesky, Telegram, Email, and one-click link copy
  • Previous/next post navigation cards
  • Code blocks rendered as macOS-style windows (red/yellow/green dots, language label, copy button)

On-site features

  • Site search: a button in the header (shortcut Ctrl/Cmd + K), filtering titles and excerpts live on the client, with the index loaded on demand and cached
  • RSS entry point (header button plus footer icon)
  • Back to top (appears after scrolling a long page)
  • Nested comments, up to 6 levels deep, with the reply form restyling itself based on where it lands

Admin and management

  • On the Theme Settings page, a floating section menu on the left and content grouped into 6 sections on the right — no getting lost no matter how many fields there are
  • Theme settings support JSON import/export, so switching themes or machines is a one-click migration
  • Social links and blogroll links come with a visual editor, so you never hand-write JSON
  • The current theme version and release link are shown automatically at the top of the page
  • Compatible with the XCaptcha comment captcha plugin (enable it and it works, no theme edits needed)
  • Custom Gravatar source (cravatar.cn works as a faster option in China)

Syntax highlighting

Using the Gruvbox palette: Gruvbox Light (cream paper, #fbf1c7) and Gruvbox Dark (#171412) adapt automatically to the theme mode. By default they follow the system or site theme, and switch along when a visitor picks one by hand. The highlighter is a local build of highlight.js 11.9.0 (assets/js/highlight.min.js), loaded only on posts and standalone pages, with no internet access needed.

Requirements

  • Typecho: 1.3.x stable (1.2.x also works; features are developed against 1.3)
  • PHP: 7.4 or newer; 8.0+ recommended (tested with 8.1, 8.2, 8.3)
  • Database: MySQL 5.7+ (including 8.x) or SQLite
  • Browser: any modern browser (the two most recent major versions of Chrome, Edge, Firefox, Safari); the search overlay and some animations rely on ES6+ and fetch
  • Network: none required. Fonts, syntax highlighting, images, and every other asset are bundled with the theme and fully functional on an intranet or offline (only outbound links such as sharing and ICP registration lookups need the internet)

Install and upgrade

Install

  1. Name the theme folder usb and upload it to the Typecho themes directory /usr/themes/
  2. Go to Console → Appearance in the admin panel and enable the theme
  3. Go to Appearance → Theme Settings, fill in what you need, and click Save Settings

Upgrade

  1. Back up your current theme settings: use Export JSON at the top of the Theme Settings page
  2. Overwrite the old theme files with the new version (theme settings live in the Typecho database and will not be overwritten, so replacing files is safe)
  3. To bust the site-wide static asset cache, just bump @version in index.php and force-refresh your browser to confirm

Page types

Every page in the theme is handled through Typecho's template system, in 8 types:

PageTemplateDetails
Homeindex.phpStarfield hero + site name + keywords + two-column post cards + pagination
Archive listarchive.phpCategory, tag, search, date, and author archives; same card layout as the home page, with the page number in the header
Postpost.phpBody + info card + share + ad slot + ToC + floating buttons + prev/next + comments
Generic standalone pagepage.phpDefault rendering for any standalone page without an assigned template (including body typography)
Tag cloud pagepage-tags.phpAll tags grouped A–Z by slug, with the # group last; can show tag counts and total post count
Archive pagepage-archives.phpA timeline grouped by year, showing the total number of posts
Blogroll pagepage-links.phpA card wall of blogroll links maintained in the visual editor
Comments modulecomments.phpCustom nested comment rendering plus the comment form (including logged-in handling and the captcha slot)
404 page404.phpReturns HTTP 404 for a nonexistent address, titled "Page not found"
Shared templates: header.php (navigation, search overlay, theme switching), footer.php (social bar, copyright and registration, back to top), functions.php (theme functions and the settings panel).

Header navigation builds itself: home + all categories + all standalone pages, with the current item highlighted automatically (a post highlights the category it belongs to). Adding categories or standalone pages requires no template changes.

Standalone page templates

page-tags.php, page-archives.php, and page-links.php are standalone page templates marked with @package custom. Create a standalone page in the admin panel and assign one:

  1. Admin Manage → Standalone Pages → New
  2. Enter a title (for example "Tags", "Archives", "Blogroll"); the body can be left empty
  3. Under Advanced Options → Template on the right, pick the matching template
  4. Publish, then visit that page's URL

Optional details:

  • Tag cloud page: a custom description field overrides the page subtitle (default copy shows if it's empty)
  • Archive and tag pages: counts appear automatically under the title
  • Blogroll page: data is maintained in the visual editor under Theme Settings → Blogroll, not in the page body

Theme settings

Where: Appearance → Themes (USB style) → Theme Settings.

The settings page uses a custom grouped layout:

  1. Version card at the top: "You are running USB for Typecho {version}. Click to view the latest release" — the version is read automatically from @version in index.php
  2. Theme config import/export card at the top: Export JSON / Import JSON
  3. Floating section menu on the left: six group anchors that highlight the current position as you scroll, with a Save Settings button at the bottom (it sits inside the menu but still submits with the form correctly)
  4. Content on the right: arranged in six sections, with headings clearly larger than field labels for a legible hierarchy, and a second Save Settings button at the bottom

Settings reference

All settings in the order they appear on the settings page, with defaults and what they do:

Appearance

SettingTypeDefaultNotes
Color schemeRadioFollow systemThe site's default theme policy; visitors can still switch by hand and that choice is remembered, with this policy applying when they haven't

Site info

SettingTypeDefaultNotes
Site subtitleText生命不息,折腾不止! (Life goes on, and so does the tinkering)Shown after the site name in the title
Hero keywordsText大鹏一日同风起·扶摇直上九万里Keywords under the home page title; falls back to the site subtitle when empty, separated by ·
Site icon URLTextEmptyBrowser favicon; enter an ico, svg, or png URL
Logo image URL (light)TextEmptyHeader logo used in light mode; a text title shows when empty
Logo image URL (dark)TextEmptyLogo swapped in automatically in dark mode; if empty, the light logo carries over
Logo height (px)Text28Caps the header logo height
ICP registration numberTextEmptyE.g. 京ICP备12345678号; hidden when empty; links to the MIIT lookup automatically
Public security registrationTextEmptyE.g. 京公网安备 11000000000000 号; hidden when empty; the number is extracted and linked to the MPS lookup

Posts

SettingTypeDefaultNotes
Table of contents (ToC)RadioShowApplies whenever a post has H2–H6 headings: floating on the right on wide screens, a bottom button and drawer on mobile
Word count and reading timeRadioShowShows word count and reading time on home cards and post pages
License nameTextCC BY-NC-SA 4.0The license name shown in the post info card
License URLTexthttps://creativecommons.org/licenses/by-nc-sa/4.0/The license field is hidden when empty
Post ad HTMLMultilineEmptyThe ad slot to the right of the license card; full HTML supported. When empty, a default "Ad space available" placeholder shows

Comments

SettingTypeDefaultNotes
Gravatar sourceTexthttps://gravatar.com/avatarAvatar source URL; https://cravatar.cn/avatar is a faster option in China

Blogroll

SettingTypeDefaultNotes
Social linksText (visual editor)EmptyThe social icon bar at the bottom of the footer; supports Github / X / Mastodon / Bsky / RSS / Email icons. Shows RSS by default when empty
Blogroll linksText (visual editor)EmptyThe link set shown on the standalone Blogroll page (name / URL / description)
Both social and blogroll links are stored as JSON in their input fields, but maintain them through the visual editor (the "+ Add" button and the per-row delete button). The editor syncs back to the field live, and changes take effect after saving.

Developer

SettingTypeDefaultNotes
Custom CSSMultilineEmptyAppended into <style> inside the page <head>; can override theme styles
Custom HTMLMultilineEmptyAny HTML injected into <head> (meta tags, external fonts, and so on)
Custom footer HTMLMultilineEmptyAny HTML before </body> (analytics, support chat scripts, and so on)

Import and export

The Theme config import/export card at the top of the settings page offers two actions:

  • Export JSON: gathers every setting above into a formatted JSON file for download (sb-theme-config.json), with no sensitive database information, safe to share
  • Import JSON: pick a previously exported file; after importing, the interface refreshes immediately (the social and blogroll editors rebuild right away), then click Save Settings to write it to the database

Typical uses: switching to another theme and back, or deploying to a new site — export, switch or migrate, enable the theme, import, save, and your settings move over intact.

Front-end behavior

InteractionDetails
Theme switchingSun/moon button in the header; the first visit follows the system (constrained by the Color scheme setting), and a manual choice is remembered
Site searchHeader search icon or Ctrl/Cmd + K; the search index loads on demand when opened (published posts only, up to 200, cached for 10 minutes), filters titles and excerpts as you type, and shows up to 30 results
Code blockspre inside post bodies gets window chrome automatically: red/yellow/green dots top left, a language label and Copy button top right (briefly showing "Copied" on success)
Table of contentsWith H2–H6 headings present: on desktop it floats right of the post title, follows scrolling and highlights the current section; on mobile a bottom-right button opens the drawer; clicking an entry scrolls smoothly to that heading
Share copyThe Copy link button copies "title + link" in one click and shows a checkmark with a "Copied" message
Back to topAppears after 400px of scrolling; floats as a group with the ToC button on post pages
Reply to a commentClicking Reply moves the form under that comment and restyles it (indented, with a cancel-reply link)
Registration linksICP and public security numbers in the footer link out to the official lookup sites
Cursor trailMoving the cursor across the hero area on the home page spawns star and heart particles (70ms throttling, capped count, disabled per motion preferences)

Directory layout

usb/
├── index.php            Home: hero + post cards + pagination
├── archive.php          Category / tag / search / date / author archive lists
├── post.php             Post page
├── page.php             Generic standalone page
├── page-tags.php        Tag cloud page (standalone template)
├── page-archives.php    Archive page (standalone template)
├── page-links.php       Blogroll page (standalone template)
├── comments.php         Comments module (nested rendering + form)
├── 404.php              404 page
├── header.php           Shared header: navigation / search overlay / theme preload script
├── footer.php           Shared footer: social bar / copyright and registration / back to top
├── functions.php        Theme functions, settings panel (grouped layout), theme hooks
├── screenshot.png       Theme preview for the admin panel
├── LICENSE              MIT license
├── README.md            Documentation
└── assets/
    ├── css/
    │   ├── tailwind.css    Precompiled Tailwind utilities (don't edit by hand; see developer notes)
    │   ├── theme.css       Theme design styles: color variables / prose / code window / ToC / comments
    │   └── highlight.css   Gruvbox syntax colors (light/dark adaptive)
    ├── js/
    │   ├── main.js             All front-end interaction (native JS, no dependencies)
    │   └── highlight.min.js    highlight.js 11.9.0 main bundle (local)
    └── fonts/
        ├── SpaceGrotesk-*.woff2    Latin body font (400/500/600/700, local)
        └── IoskeleyMono-*.woff2    Monospace font (for code and monospaced text)

FAQ

Q: If I switch themes and come back, are my settings still there?
Switching to another theme and re-enabling this one, or moving to a new site, both require Export JSON / Import JSON.

Q: Why don't my social or blogroll links show after importing JSON?
They should appear immediately, since the editor rebuilds on import. If the data looks unchanged, confirm that you imported JSON exported from this theme with all keys intact, then click Save Settings to write to the database — the page only reads from the database after a refresh.

Q: Why does my post have no table of contents or share/copy?

  • ToC: the post body needs at least two H2–H6 headings, and Table of contents must be enabled. H1 doesn't count.
  • Code window chrome: it only applies to <pre> inside .prose; copy relies on the clipboard API, which may fail as a fallback outside HTTPS (there's an execCommand fallback).

Q: Syntax highlighting isn't working.
Highlighting is triggered by the bundled highlight.js (assets/js/highlight.min.js) and loads only on posts and standalone pages, with no internet needed. If code isn't highlighted, check that the pre code language class is written correctly (a `language-xxx fence) and force-refresh your browser.

Q: Comment avatars aren't showing.
The default Gravatar source is https://gravatar.com/avatar. If it's unreliable where you are, change it to https://cravatar.cn/avatar under Theme Settings → Comments → Gravatar source.

Q: How do I change how many posts appear per page?
Settings → Reading → Posts per page in the admin panel. The theme follows automatically, on both the home page and archive lists.

Q: I want to tweak body styles or add analytics code.
Use the Developer section first: Custom CSS (a style block in head), Custom HTML (head), and Custom footer HTML (before </body>, good for analytics or support scripts). No template edits needed.

Q: What is the theme folder called?
The release package is usb. In the admin Appearance list the theme name comes from @package in index.php, independent of the folder name; JSON import and export are independent of it too.

Changelog

1.0.3 (current)

  • New image lightbox on post pages: any image wider than 200px in the body opens an immersive viewer on click — cycling through multiple images, zoom in and out, 90° rotation, drag to pan, closing on a click outside the image or on Esc. Zero third-party dependencies (native JS and CSS, no licensing burden). Styles live in the "Post image lightbox" section of theme.css, logic in initLightbox() in main.js
  • Fine-tuned Markdown table styles in post bodies: the left, right, and top borders are gone, leaving only row dividers and a closing emphasis line at the bottom
  • Fixed: inline emoji images mixed into a paragraph are no longer forced to center or break the line; they sit inline with the text again (full-width images on their own line are unchanged)
  • Fixed: the current page number in the archive pagination no longer changes color on hover and stays black-highlighted

1.0.1

  • Localized every site asset: removed the Google Fonts @import and the highlight.js CDN reference, and downloaded the fonts, the highlighter, and the ad placeholder image into the theme's assets/
  • Added a ?v= version parameter to static asset URLs (the version comes solely from @version in index.php, read by sb_theme_version()), so bumping it after an upgrade busts visitor caches
  • Redesigned Theme Settings: a version card and an import/export card at the top; a floating section menu and Save Settings on the left; content grouped into Appearance / Site info / Posts / Comments / Blogroll / Developer
  • The visual editors for social and blogroll links rebuild immediately after importing a config
  • Added a separate dark-mode logo setting (logoImgDark); removed the "site analytics code" field (use the Developer section's custom footer HTML instead)
  • Assorted fixes: tag cloud styles moved out of the template, share tooltip overlap, and color/hierarchy issues in light and dark modes

1.0.0

  • First release: the full page system, light/dark themes, and all features — search, ToC, syntax highlighting, sharing, the starfield, and more

License

The theme code is under the MIT License; see the LICENSE file bundled with the theme. The design language follows U.SB. The Ioskeley Mono font remains the property of its author — check its terms before redistributing.

Leave a Comment

Comments 11

  • 天泽
    天泽 2026-11-07 09:08 Reply

    简洁的模板,大气

  • ieast
    ieast 2026-10-19 15:09 Reply

    很清爽的模板,值得推荐

  • laogui
    laogui 2026-10-18 10:31 Reply

    你小子竟然还在更新博客

    • aijun
      aijunAuthor 2026-10-18 12:13 Reply

      🐶我很是勤奋的,你的博客也帮我做个链接呗

  • 老孙
    老孙 2026-10-04 08:10 Reply

    感觉非常nice支持一下

  • ComBox
    ComBox 2026-09-29 09:23 Reply

    这个模板看上去清爽,简洁。

  • zhou
    zhou 2026-09-09 21:18 Reply

    附件图片可以加上和你这个站点一样点击放大的功能吗?

    • aijun
      aijunAuthor 2026-10-04 10:37 Reply

      V1.0.3版本已更新,新增内容页图片灯箱功能。

    • aijun
      aijunAuthor 2026-09-10 08:59 Reply

      这个 USB 的模板,起初考虑的就是纯文本的博客。所以这个版本没有做这个效果。后面考虑加一下类 Fancybox 的图片效果。

  • Showfom
    Showfom 2026-09-03 23:51 Reply

    支持一下,不来个演示嘛

    • aijun
      aijunAuthor 2026-09-04 16:40 Reply

      好的,安装一个演示站。

Table of Contents