# \[SOLVED\] How to decrease build time? 25103 ms is a lot of time

**URL:** <https://discourse.gohugo.io/t/solved-how-to-decrease-build-time-25103-ms-is-a-lot-of-time/9627>\
**Category:** support\
**Created:** [December 17, 2017, 12:52pm UTC](https://discourse.gohugo.io/t/solved-how-to-decrease-build-time-25103-ms-is-a-lot-of-time/9627 "2017-12-17T12:52:45Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![diegoeis](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/diegoeis/32/2959_2.png) [@diegoeis](https://discourse.gohugo.io/u/diegoeis)\
**Post date:** [December 17, 2017, 12:52pm UTC](https://discourse.gohugo.io/t/solved-how-to-decrease-build-time-25103-ms-is-a-lot-of-time/9627/1 "2017-12-17T12:52:45Z")

</div>

Hello everyone.

I have one website, with many authors and a lot of posts/articles. I migrated from WP to Hugo about 6 months ago. To develop with Hugo, I just run `hugo server` or `hugo server --ignoreCache --disableLiveReload`, but the time of build is very long. See the statistics of Hugo below:

```auto
Built site for language pt-br:
0 of 1 draft rendered
0 future content
0 expired content
1771 regular pages created
3128 other pages created
0 non-page files copied
0 paginator pages created
240 authors created
1219 tags created
98 categories created
total in 25103 ms

```

I saw this video: [https://www.youtube.com/watch?v=CdiDYZ51a2o](https://www.youtube.com/watch?v=CdiDYZ51a2o)  
But I don’t have any tips to increase Hugo build performance. Can someone enlight me?

The code of website can be found here:

> **[tableless/tableless](https://github.com/tableless/tableless)**
>
> O site do Tableless em Hugo. Mais leve, impossível. - tableless/tableless

---

<div class="post-metadata">

**Author:** ![bep](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/bep/32/3332_2.png) [@bep](https://discourse.gohugo.io/u/bep)\
**Post date:** [December 17, 2017, 2:29pm UTC](https://discourse.gohugo.io/t/solved-how-to-decrease-build-time-25103-ms-is-a-lot-of-time/9627/2 "2017-12-17T14:29:34Z")

</div>

25 seconds is hardly “a lot of time” for all the work done here.

---

<div class="post-metadata">

**Author:** ![bep](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/bep/32/3332_2.png) [@bep](https://discourse.gohugo.io/u/bep)\
**Post date:** [December 17, 2017, 2:41pm UTC](https://discourse.gohugo.io/t/solved-how-to-decrease-build-time-25103-ms-is-a-lot-of-time/9627/3 "2017-12-17T14:41:06Z")

</div>

But …

running with `hugo --templateMetrics --templateMetricsHints` gives a few hints:

```bash
Template Metrics:

      cache cumulative average maximum
  potential duration duration duration count template
      ----- ---------- -------- -------- ----- --------
          0 53.289292513s 30.15806ms 64.62134ms 1767 theme/post/single.html
          5 47.147678647s 14.137234ms 43.196219ms 3335 theme/partials/header.html
          0 24.348549795s 15.58806ms 151.642563ms 1562 theme/_default/list.html
          0 1.159257693s 739.794µs 89.294725ms 1567 _internal/_default/rss.xml
        100 777.615582ms 440.076µs 8.225484ms 1767 theme/partials/sidebar.html
         10 584.000871ms 330.504µs 26.923459ms 1767 theme/partials/posthero.html
         59 481.344118ms 30.549µs 5.863613ms 15756 theme/partials/byauthor.html
         99 220.747866ms 124.505µs 7.099817ms 1773 theme/partials/footer.html
          0 172.671316ms 172.671316ms 172.671316ms 1 theme/section/todos-os-posts.html
          0 75.900584ms 75.900584ms 75.900584ms 1 _internal/_default/sitemap.xml
          0 57.226729ms 14.306682ms 15.693283ms 4 theme/page/single.html
         83 51.637655ms 29.223µs 1.491962ms 1767 theme/partials/disqus.html
         50 41.510745ms 23.478µs 5.660257ms 1768 theme/partials/postdate.html
          0 31.628304ms 31.628304ms 31.628304ms 1 theme/index.html
          0 1.711742ms 131.672µs 319.473µs 13 shortcodes/codepen.html
         57 737.978µs 245.992µs 378.668µs 3 theme/partials/postbox.html
          0 405.555µs 405.555µs 405.555µs 1 shortcodes/jsfiddle.html
          0 91.04µs 91.04µs 91.04µs 1 _internal/_default/robots.txt
          0 79.004µs 79.004µs 79.004µs 1 theme/404.html
        

```

- You can save 777 ms by using partialCached for the sidebar partial, and you can probably also do that for the footer.
- You can save a lot by doing less work in theme/post/single.html – you need to look at the related feature in Hugo to replace the intersect construct. [https://gohugo.io/content-management/related/](https://gohugo.io/content-management/related/)

---

<div class="post-metadata">

**Author:** ![diegoeis](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/diegoeis/32/2959_2.png) [@diegoeis](https://discourse.gohugo.io/u/diegoeis)\
**Post date:** [December 17, 2017, 10:01pm UTC](https://discourse.gohugo.io/t/solved-how-to-decrease-build-time-25103-ms-is-a-lot-of-time/9627/4 "2017-12-17T22:01:21Z")

</div>

Wow!  
I tried to use the partialCached another time, but, without tips of --templateMetrics and --templateMetricsHints, I did not see any changes. Now, I’m using the partialCached in Header, Footer and Sidebar.

But, the tip of related feature is gold. Thank you a lot!

```auto
Built site for language pt-br:
0 draft content
0 future content
0 expired content
1775 regular pages created
3134 other pages created
0 non-page files copied
0 paginator pages created
240 authors created
1219 tags created
98 categories created
total in 2181 ms

```

Just to resume the changes:

- Modify the related posts script to original solution of Hugo
- Use partialCached in Footer, Sidebar and Header.

---

<div class="post-metadata">

**Author:** ![diegoeis](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/diegoeis/32/2959_2.png) [@diegoeis](https://discourse.gohugo.io/u/diegoeis)\
**Post date:** [January 5, 2018, 4:42pm UTC](https://discourse.gohugo.io/t/solved-how-to-decrease-build-time-25103-ms-is-a-lot-of-time/9627/5 "2018-01-05T16:42:25Z")

</div>

Just to know: I remove the Tags from my taxonomies. I realize that I use tags just to make the Related Posts. But, I configure the Related to take Categories first, title in second after authors. Removing the Tags Taxonomy, the build on the server got much faster. This decrease the number of `other pages created` from 3134 to 714.

This gives me more freedom to organize where I can use the partialCached without break some page information. In past post, I said that I was using partialCached in Sidebar and Header. Doing this, I can get just 2181ms to build in development environment, but I can’t use cached in this partials because the info in that areas changes sometimes. So, I rollback the `partial` default include, but the build increase to something like ~5000ms. Removing the tags like I said before, I get ~2500ms. Results:

```auto
Built site for language pt-br:
0 draft content
0 of 2 futures rendered
0 expired content
1779 regular pages created
714 other pages created
0 non-page files copied
0 paginator pages created
107 categories created
241 authors created
total in 2696 ms

```

---

<div class="post-metadata">

**Author:** ![bep](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/bep/32/3332_2.png) [@bep](https://discourse.gohugo.io/u/bep)\
**Post date:** [January 5, 2018, 7:00pm UTC](https://discourse.gohugo.io/t/solved-how-to-decrease-build-time-25103-ms-is-a-lot-of-time/9627/6 "2018-01-05T19:00:34Z")

</div>

> [@diegoeis](#):
>
> . I realize that I use tags just to make the Related Posts. But, I configure the Related to take Categories first, title in second after authors.

Note that you can still use the tags values in related even if you don’t have a taxonomy configured for it.

---

<div class="post-metadata">

**Author:** ![diegoeis](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/diegoeis/32/2959_2.png) [@diegoeis](https://discourse.gohugo.io/u/diegoeis)\
**Post date:** [January 5, 2018, 7:18pm UTC](https://discourse.gohugo.io/t/solved-how-to-decrease-build-time-25103-ms-is-a-lot-of-time/9627/7 "2018-01-05T19:18:23Z")

</div>

Yeah. I’m using it, but with a small weight configured, since the categories is much to have taxonomy when authors write and tags don’t! 🙂

Thank for your help @bep.
