# How does the routing in templates work?

**URL:** <https://discourse.gohugo.io/t/how-does-the-routing-in-templates-work/37586>\
**Category:** support\
**Created:** [March 10, 2022, 1:38pm UTC](https://discourse.gohugo.io/t/how-does-the-routing-in-templates-work/37586 "2022-03-10T13:38:23Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![WoJWoJWoJ](https://avatars.discourse-cdn.com/v4/letter/w/87869e/32.png) [@WoJWoJWoJ](https://discourse.gohugo.io/u/WoJWoJWoJ)\
**Post date:** [March 10, 2022, 1:38pm UTC](https://discourse.gohugo.io/t/how-does-the-routing-in-templates-work/37586/1 "2022-03-10T13:38:23Z")

</div>

I am trying to design my own theme starting from [`blank`](https://github.com/Vimux/blank). The test site builds fine and is indeed empty but functional.

I however fail to understand how the routine in themes work. Specifically, my problem is that I do not see where the main skeleton for the final web page is - that one that will build `<header>`, `<body>`, etc. I expected to find there the logic of switching between views: what to parse when looking at the home page, what at a blog entry, what at a standalone page, etc.

To take the example of this starter theme, I see `https://github.com/Vimux/blank/tree/master/layouts/index.html`, but it is just the definition of **one of the** `main` blocks. There are other such definitions in `https://github.com/Vimux/blank/tree/master/layouts/_default` for instance.

**Where do I code the logic/decision to use a specific template file? (one of the several with the definition of `main`)**

I expect that some “routing” (not dynamic one - a routing that is then compiled into a set of pages with links to other pages) must be defined somewhere where you say that the page `/` is generated from `<something>` and a page `/blog/hello-world` is generated from `<something else>`.

---

<div class="post-metadata">

**Author:** ![davidsneighbour](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/davidsneighbour/32/24507_2.png) [@davidsneighbour](https://discourse.gohugo.io/u/davidsneighbour)\
**Post date:** [March 10, 2022, 2:00pm UTC](https://discourse.gohugo.io/t/how-does-the-routing-in-templates-work/37586/2 "2022-03-10T14:00:23Z")

</div>

You come from the wrong side at the issue 🙂 Hugo has it’s own rules about templates and has a “lookup order” for templates. There are sections (folders in /content) and layouts (frontmatter configuration) and list pages and single pages… Maybe read the docs about this and start here:

> **[Hugo's Lookup Order](https://gohugo.io/templates/lookup-order/)**
>
> Hugo searches for the layout to use for a given page in a well defined order, starting from the most specific.

---

<div class="post-metadata">

**Author:** ![WoJWoJWoJ](https://avatars.discourse-cdn.com/v4/letter/w/87869e/32.png) [@WoJWoJWoJ](https://discourse.gohugo.io/u/WoJWoJWoJ)\
**Post date:** [March 10, 2022, 3:05pm UTC](https://discourse.gohugo.io/t/how-does-the-routing-in-templates-work/37586/3 "2022-03-10T15:05:34Z")

</div>

Thank you very much - this is the documentation I was looking for. I managed to build a pair of `index.html` (the template) and `index.md` (the content that work).

I have the feeling that how one approaches these files (content vs templates) for the “structural files” (that is everything outside content that is added, such as posts) really depends on whether this is a one-shot kind of site (in which case the content part could go into the template one), or something intended to be reused (in which case `index.for instance makes sense as it will change).

The worst feeling is that I know there is a lot of power in Hugo but the documentation i sometimes hard to navigate despite being very complete. This makes me think that a “tutorial” section (and how-to) with content from contributors (simple users such as myself) could be worthwhile.

---

<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:** [March 12, 2022, 3:05pm UTC](https://discourse.gohugo.io/t/how-does-the-routing-in-templates-work/37586/4 "2022-03-12T15:05:41Z")

</div>

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