# How do I have a custom index page while using the previous index page aswell?

**URL:** <https://discourse.gohugo.io/t/how-do-i-have-a-custom-index-page-while-using-the-previous-index-page-aswell/48078>\
**Category:** support\
**Tags:** modules, pagination\
**Created:** [February 2, 2024, 3:29pm UTC](https://discourse.gohugo.io/t/how-do-i-have-a-custom-index-page-while-using-the-previous-index-page-aswell/48078 "2024-02-02T15:29:52Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yeti](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/yeti/32/21209_2.png) [@Yeti](https://discourse.gohugo.io/u/Yeti)\
**Post date:** [February 2, 2024, 3:29pm UTC](https://discourse.gohugo.io/t/how-do-i-have-a-custom-index-page-while-using-the-previous-index-page-aswell/48078/1 "2024-02-02T15:29:52Z")

</div>

Hello! Total newbie to hugo here!

I’m using this theme [CaiJimmy/hugo-theme-stack: Card-style Hugo theme designed for bloggers (github.com)](https://github.com/CaiJimmy/hugo-theme-stack) in my hugo site. I understand that `layouts/index.html` is where the landing page of the site lives. I want to have my own custom index.html as a replacement to that file, so I replace it. But I also want that previous `index.html` from the theme. Therefore, I create a file called `projects.html` in `layouts/` and paste the code in. Then I create a file called `content/projects.md` with the frontmatter `layout: projects` but that does not display anything, and probably falls back to `layouts/_default/single.html` How do I use this code to display projects.html(the `index.html` from the theme)?

```html
{{ define "main" }}
    {{ $pages := where .Site.RegularPages "Type" "in" .Site.Params.mainSections }}

    {{ $notHidden := where .Site.RegularPages "Params.hidden" "!=" true }}
    {{ $filtered := ($pages | intersect $notHidden) }}
    {{ $pag := .Paginate ($filtered) }}

    <section class="article-list">
    
        {{ range $index, $element := $pag.Pages }}
            {{ partial "article-list/default" . }}
        {{ end }}

    </section>

    {{- partial "pagination.html" . -}}
    {{- partial "footer/footer" . -}}
{{ end }}

{{ define "right-sidebar" }}
    {{ partial "sidebar/right.html" (dict "Context" . "Scope" "homepage") }}
{{ end }}

```

I also tried putting this under `layouts/_default/projects.html` and use them there but then I would get this error

```auto
ERROR Rebuild failed: render: failed to render pages: render of "page" failed: layouts\_default\projects.html:11:41": execute of template failed at <$pag.Pages>: error calling Pages: runtime error: invalid memory address or nil pointer dereference

```

What can I do here?  
Thanks for any support in advance!

---

<div class="post-metadata">

**Author:** ![jmooring](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jmooring/32/4214_2.png) [@jmooring](https://discourse.gohugo.io/u/jmooring)\
**Post date:** [February 2, 2024, 4:17pm UTC](https://discourse.gohugo.io/t/how-do-i-have-a-custom-index-page-while-using-the-previous-index-page-aswell/48078/2 "2024-02-02T16:17:04Z")

</div>

1) Create the template: `layouts/_default/projects.html`

2) Create the content: `content/projects/_index.md` (must be a section page)

3) Add front matter to the content:

```auto
layout = 'projects'

```

---

<div class="post-metadata">

**Author:** ![Yeti](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/yeti/32/21209_2.png) [@Yeti](https://discourse.gohugo.io/u/Yeti)\
**Post date:** [February 2, 2024, 4:50pm UTC](https://discourse.gohugo.io/t/how-do-i-have-a-custom-index-page-while-using-the-previous-index-page-aswell/48078/3 "2024-02-02T16:50:48Z")

</div>

That works! thanks a lot

---

<div class="post-metadata">

**Author:** ![system](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/system/32/1_2.png) [@system](https://discourse.gohugo.io/u/system)\
**Post date:** [February 4, 2024, 4:51pm UTC](https://discourse.gohugo.io/t/how-do-i-have-a-custom-index-page-while-using-the-previous-index-page-aswell/48078/4 "2024-02-04T16:51:14Z")

</div>

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.
