• English
  • 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

    LevelFront MatterShown in ListingsAccessible by URL
    Default (Public)Not setYesYes
    Local (Hidden from listings)visibility: localNoYes
    Global (Fully hidden)visibility: globalNoNo (returns 404)

    Usage

    Set the visibility field in your post's frontmatter:

    ---
    title: My Hidden Post
    date: 2024-01-01
    categories: Tech
    visibility: local
    ---

    Default Visibility

    When visibility is not set, the post behaves normally:

    ---
    title: A Regular Post
    date: 2024-01-15
    ---

    The post appears on the homepage, archives, category pages, tag pages, and is accessible via its URL.

    Local Hidden (visibility: local)

    ---
    title: Draft Notes
    date: 2024-02-20
    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)

    ---
    title: Private Notes
    date: 2024-03-10
    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: The after_post_render filter clears the post content and sets the layout to 404, so direct access returns a 404 page.
    • List filtering: The is_visible helper function filters out posts with visibility: local or visibility: global when generating listing pages.

    Full Example

    ---
    title: My Personal Journal
    date: 2024-05-01
    categories: Life
    tags:
      - journal
    visibility: local
    description: This post is hidden from listings but accessible via direct link.
    ---
    
    ## May 1, 2024
    
    The weather was nice today. I started building my blog with the ModernDuang theme.
    
    This post has `visibility: local`, so it won't appear on the homepage or archives page,
    but you can still read it if you access it via the direct link.

    Notes

    • The visibility field is optional — you only need to add it to posts whose visibility you want to restrict.
    • Posts with visibility: local may still be indexed by search engines (since the page is publicly accessible). To block search engines, add robots: noindex to the frontmatter.
    • Posts with visibility: global do 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).