PHPackages                             acalcutt/grav-plugin-subpages - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. acalcutt/grav-plugin-subpages

ActiveGrav-plugin[Utility &amp; Helpers](/categories/utility)

acalcutt/grav-plugin-subpages
=============================

A Grav plugin to display subpages.

v1.0.3(1y ago)03MITPHPPHP &gt;=7.3.0

Since Jan 27Pushed 1y ago1 watchersCompare

[ Source](https://github.com/acalcutt/grav-plugin-subpages)[ Packagist](https://packagist.org/packages/acalcutt/grav-plugin-subpages)[ RSS](/packages/acalcutt-grav-plugin-subpages/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (3)DependenciesVersions (5)Used By (0)

Grav Subpages Plugin
====================

[](#grav-subpages-plugin)

[![Packagist](https://camo.githubusercontent.com/9abe4cbd77fe8f2c9fa7b6a7b65558f740be8ec8d07c6d9dc67f8504ab63f081/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6163616c637574742f677261762d706c7567696e2d73756270616765732e737667)](https://packagist.org/packages/acalcutt/grav-plugin-subpages)

This Grav plugin displays a list of direct, visible sub-pages for the current page. It's designed to be a simple and straightforward way to provide navigation to child pages.

Features
--------

[](#features)

- **Direct Subpages:** Displays only the immediate children of the current page.
- **Visibility Check:** Only shows pages that are explicitly visible (not hidden).
- **Routable Check:** Only shows pages that are routable.
- **Configurable List Style:** Allows you to choose between `ul` (unordered list) and `ol` (ordered list) in the plugin's configuration.
- **Easy Integration:** Uses a simple Twig include to display the list on your pages.
- **"Back to Parent" Link:** Adds a navigation link to the parent page (if not a root page), using `[..]` notation, for a concise and clean way to go back one level.

How It Works
------------

[](#how-it-works)

The plugin works by:

1. **Hooking into the Grav Events:** The plugin listens for Grav's `onPluginsInitialized` and `onTwigSiteVariables` events. It also uses `onTwigTemplatePaths` for loading template paths.
2. **Adding Template Path:** When the `onPluginsInitialized` event fires, the plugin adds its `/templates` directory to Grav's Twig template paths so it can find the correct template file.
3. **Fetching Subpages:** When `onTwigSiteVariables` fires, the plugin retrieves the current page object, then it uses the function `getVisibleSubpages` to get the subpages that are both visible and routable.
4. **Fetching Parent:** When `onTwigSiteVariables` fires, the plugin retrieves the current page object, then it uses the function `getParentPage` to get the current page's parent (or null if it doesn't have one).
5. **Passing Data to Twig:** The plugin makes this data available to your Twig templates through the `subpages`, `parent` and `subpages_config` variables.
6. **Rendering the Subpage List:** In your Twig template, you include `subpages.html.twig`, which loops through the `subpages` variable and renders the list of links. The style of list will depend on the `subpages_config.style`.

Installation
------------

[](#installation)

### With Grav Package Manager (GPM)

[](#with-grav-package-manager-gpm)

1. Navigate to the `/admin/plugins` page in your browser.
2. Search for "Subpages" and click the install button.

### Manually

[](#manually)

1. **Download:** Download the plugin from the [GitHub Releases](https://github.com/acalcutt/grav-plugin-subpages/releases) page or clone this repository to the `user/plugins/subpages` directory of your Grav site: ```
    cd user/plugins
    git clone https://github.com/acalcutt/grav-plugin-subpages subpages
    ```
2. **Enable the Plugin:**
    - Log in to your Grav Admin panel.
    - Navigate to "Plugins."
    - Find the "Subpages" plugin and enable it by toggling the switch.
    - Configure the list `style`. You can choose between `ul` for an unordered list or `ol` for an ordered list.
3. **Clear the Cache:** Clear the Grav cache, just in case.

Usage
-----

[](#usage)

1. **Add the Twig Include:** In the Twig template where you want to display the subpage list, add the following include:

    ```
    {% if config.plugins.subpages.enabled %}
      {% include 'subpages.html.twig' %}
    {% endif %}
    ```

    - This could be in your theme's `base.html.twig` file (or `default.html.twig` if you don't have a `base.html.twig`), or in a specific page's Twig template.
    - **Important:** The plugin adds the `subpages`, `parent`, and `subpages_config` variables to your Twig environment so that the `subpages.html.twig` template can access it.

Example
-------

[](#example)

Let's say you have a page structure like this:

```
/parent-page/
  /01.subpage-1/
  /02.subpage-2/
  /03.subpage-3/  (hidden)

```

If you navigate to `/parent-page/` and have the plugin enabled with a unordered list style, the output will be something like this:

[![Subpages Plugin Unordered List](screenshots/subpages_ul.png)](screenshots/subpages_ul.png)

If you are using the ordered list style, the output will look like this:

[![Subpages Plugin Ordered List](screenshots/subpages_ol.png)](screenshots/subpages_ol.png)

- Note that `subpage-3` is not listed as it is hidden (not visible)

Configuration
-------------

[](#configuration)

The plugin has the following configuration options under the "Subpages" section in the Grav admin panel:

- **Plugin Status (enabled):** Enable or disable the plugin.
- **Style:** Allows you to chose between `ul` for an unordered list or `ol` for an ordered list.
- **Show Previous Page Link (enabled):** Enable or disable the \[..\] Previous Page Link at the top of the list. Disabling this option makes the list of pages look like this.
    [![Subpages Plugin Unordered List](screenshots/subpages_ul_no-root.png)](screenshots/subpages_ul_no-root.png)
    [![Subpages Plugin Ordered List](screenshots/subpages_ol_no-root.png)](screenshots/subpages_ol_no-root.png)

Customization
-------------

[](#customization)

- **CSS:** Customize the appearance of the list by adding styles to the `.subpages-list` class in your theme's CSS file.
- **Template:** You can modify the `subpages.html.twig` template to change the HTML structure of the list to fit your needs.

Admin Preview Limitation
------------------------

[](#admin-preview-limitation)

- The subpages list may not be fully visible in the admin preview. This is expected behavior, as the admin preview is not designed to render all aspects of plugins or themes. It is meant for previewing content, not elements. The most important testing should always be done on the front-end of the website.

License
-------

[](#license)

This plugin is released under the [MIT License](LICENSE).

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance43

Moderate activity, may be stable

Popularity3

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity36

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~9 days

Total

3

Last Release

451d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/9384d85989b725b74a12ca2b869d9f18f4950aa59e17b9f4e8402ecbd4492bb1?d=identicon)[acalcutt](/maintainers/acalcutt)

---

Top Contributors

[![acalcutt](https://avatars.githubusercontent.com/u/3792408?v=4)](https://github.com/acalcutt "acalcutt (23 commits)")

---

Tags

plugingravnavigationsubpages

### Embed Badge

![Health badge](/badges/acalcutt-grav-plugin-subpages/health.svg)

```
[![Health](https://phpackages.com/badges/acalcutt-grav-plugin-subpages/health.svg)](https://phpackages.com/packages/acalcutt-grav-plugin-subpages)
```

###  Alternatives

[ergebnis/composer-normalize

Provides a composer plugin for normalizing composer.json.

1.1k37.3M2.1k](/packages/ergebnis-composer-normalize)[kartik-v/yii2-widget-sidenav

An enhanced side navigation menu styled for bootstrap (sub repo split from yii2-widgets)

364.0M8](/packages/kartik-v-yii2-widget-sidenav)[kartik-v/yii2-widget-affix

A scrollspy and affixed enhanced navigation to highlight page sections (sub repo split from yii2-widgets)

153.8M3](/packages/kartik-v-yii2-widget-affix)[coldtrick/widget_manager

Manage your widgets

214.3k](/packages/coldtrick-widget-manager)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
