# Link to subpage on parent menu

**URL:** <https://forum.getkirby.com/t/link-to-subpage-on-parent-menu/11695>\
**Category:** Questions\
**Tags:** v2\
**Created:** [November 22, 2018, 7:19pm UTC](https://forum.getkirby.com/t/link-to-subpage-on-parent-menu/11695 "2018-11-22T19:19:49Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![caplod](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/caplod/32/5211_2.png) [@caplod](https://forum.getkirby.com/u/caplod)\
**Post date:** [November 22, 2018, 7:19pm UTC](https://forum.getkirby.com/t/link-to-subpage-on-parent-menu/11695/1 "2018-11-22T19:19:50Z")

</div>

I have a menu where I want to include a link to a specific subpage on the parent menu.

- 01-Home
- 02-Products
- ← here link to Subpage 2
- 03-News
- Section  
– Subpage 1  
– Subpage 2
- Error
- Privacy

in the docs I found this: [https://getkirby.com/docs/cookbook/simple-redirects](https://getkirby.com/docs/cookbook/simple-redirects) but thats a redirect.  
I want to have the direct link to Subpage 2.  
Any ideas?

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [November 22, 2018, 7:31pm UTC](https://forum.getkirby.com/t/link-to-subpage-on-parent-menu/11695/2 "2018-11-22T19:31:30Z")

</div>

There are several ways to do that.

- You could - within your loop stop after the first two and then manually insert the link to the subpage.
- you could use a built-in field or custom field to build a custom menu
- …

```auto
<nav>
  <ul>
    <?php foreach($items->limit(2) as $item): ?>
       <li><a<?php e($item->isOpen(), ' class="active"') ?> href="<?= $item->url() ?>"><?= $item->title()->html() ?></a></li>
    <?php endforeach ?>
   <?php if($subpage = page('path-to-subpage'): ?>
      <li><a<?= $subpage->url() ?></a></li>
    <?php endif ?>
    <?php foreach($items->offset(2) as $item): ?>
       <li><a<?php e($item->isOpen(), ' class="active"') ?> href="<?= $item->url() ?>"><?= $item->title()->html() ?></a></li>
    <?php endforeach ?>
  </ul>
</nav>

```

---

<div class="post-metadata">

**Author:** ![caplod](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/caplod/32/5211_2.png) [@caplod](https://forum.getkirby.com/u/caplod)\
**Post date:** [November 23, 2018, 7:11am UTC](https://forum.getkirby.com/t/link-to-subpage-on-parent-menu/11695/3 "2018-11-23T07:11:28Z")

</div>

Thanks for the hint!  
Because the subpage always needed to be below products I did this:

```
<ul class="nav">
    <?php foreach($pages->visible() as $item): ?>
      <li><a<?php e($item->isOpen(), ' class="active"') ?> href="<?php echo $item->url() ?>"><?php echo html($item->title()) ?></a></li>
      <?php if(($item->uri() == 'products') && ($subpage= page('path-to-subpages'))): ?>
      <li><a<?php e($subpage->isOpen(), ' class="active"') ?> href="<?php echo $subpage->url() ?>"><?php echo html($subpage->title()) ?></a></li>
      <?php endif ?>
    <?php endforeach ?>
  </ul>
```

---

<div class="post-metadata">

**Author:** ![distantnative](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/distantnative/32/11319_2.png) [@distantnative](https://forum.getkirby.com/u/distantnative)\
**Post date:** [February 6, 2025, 5:25pm UTC](https://forum.getkirby.com/t/link-to-subpage-on-parent-menu/11695/4 "2025-02-06T17:25:46Z")

</div>


