Post Visibility
ModernDuang provides fine-grained control over which posts appear where. By setting the visibility field in a post's frontmatter, you can hide posts from listing pages (homepage, archives, categories, tags) or make them completely inaccessible.
Visibility Levels
Usage
Set the visibility field in your post's frontmatter:
Default Visibility
When visibility is not set, the post behaves normally:
The post appears on the homepage, archives, category pages, tag pages, and is accessible via its URL.
Local Hidden (visibility: local)
The post will not appear on:
- Homepage post list
- Archives page (
/archives) - Category pages (
/categories) - Tag pages (
/tags)
However, anyone who knows the post URL can still access it directly. Ideal for:
- Posts you want to share via link but not display publicly in listings
- Internal reference documents
- Test pages
Global Hidden (visibility: global)
The post is completely hidden:
- Does not appear on any listing page
- Direct URL access returns a 404 page
- Post content is not rendered
Ideal for:
- Content you truly don't want anyone to see (soft delete)
- Temporarily taking down content while keeping the source file
How It Works
The visibility feature is implemented in the theme's scripts/visibility.js:
visibility: global: Theafter_post_renderfilter clears the post content and sets the layout to404, so direct access returns a 404 page.- List filtering: The
is_visiblehelper function filters out posts withvisibility: localorvisibility: globalwhen generating listing pages.
Full Example
Notes
- The
visibilityfield is optional — you only need to add it to posts whose visibility you want to restrict. - Posts with
visibility: localmay still be indexed by search engines (since the page is publicly accessible). To block search engines, addrobots: noindexto the frontmatter. - Posts with
visibility: globaldo not produce a valid HTML page at build time, but the source file remains intact. - This feature only takes effect during Hexo generation. It does not affect the behavior of the local development server (
hexo server).
Related Pages
- Configuration Reference — All frontmatter options
- 404 Page — Custom 404 page
