# Exclude page template from sitemap

**URL:** https://forum.getkirby.com/t/exclude-page-template-from-sitemap/23882
**Category:** Questions
**Created:** [November 5, 2021, 1:14pm UTC](https://forum.getkirby.com/t/exclude-page-template-from-sitemap/23882 "2021-11-05T13:14:41Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Samuele](https://avatars.discourse-cdn.com/v4/letter/s/9f8e36/32.png) [@Samuele](https://forum.getkirby.com/u/Samuele)
#### Post date: [November 5, 2021, 1:14pm UTC](https://forum.getkirby.com/t/exclude-page-template-from-sitemap/23882/1 "2021-11-05T13:14:41Z")

</div>

Hi there!  
I’m trying to exclude from my sitemap all the page that have a specific template.

Here my snippet:  
(the template that I want to exclude is “form-item”

```auto
<?= '<?xml version="1.0" encoding="utf-8"?>'; ?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  <?php foreach ($pages as $p): ?>
    <?php if($p->template() !== 'form-item'): ?>
      <?php if(!strpos($p->url(), '/orders')): ?>
        <?php if (in_array($p->uri(), $ignore)) continue ?>
        <url>
            <loc><?= html($p->url()) ?></loc>
            <lastmod><?= $p->modified('c', 'date') ?></lastmod>
            <priority><?= ($p->isHomePage()) ? 1 : number_format(0.5 / $p->depth(), 1) ?></priority>
            <template> <?= $p->intendedTemplate() ?></template>
        </url>
      <?php endif ?>
    <?php endif ?>
  <?php endforeach ?>
</urlset>

```

---

<div class="post-metadata">

### Author: ![moonwalk](https://avatars.discourse-cdn.com/v4/letter/m/53a042/32.png) [@moonwalk](https://forum.getkirby.com/u/moonwalk)
#### Post date: [November 5, 2021, 1:20pm UTC](https://forum.getkirby.com/t/exclude-page-template-from-sitemap/23882/2 "2021-11-05T13:20:43Z")

</div>

> [@Samuele](#):
>
> ` <?php foreach ($pages as $p): ?>`

```auto
  <?php foreach ($pages->filterBy('template', 'not in', ['form-item']) as $p): ?>

```

Then remove the if statement.

If the template doesn’t exist, use `intendedTemplate` instead.

The reason why your if statement doesn’t work is because you are comparing a template object to a string. it would work like this:

```auto
    <?php if($p->template()->name() !== 'form-item'): ?>

```
