Moving Imports And Partials? Which One Is Faster?

Dear All

I used Jekyll before I migrated to Hugo. On my Jekyll before, I avoid using so many liquid and includes method, because it will open the file that I includes, and it takes more time to build.

I know that most of Hugo themes uses imports and partials for easier development purpose. But I want more simpler file and structure. So, I move most of the code inside imports and partials to the parents file.

My question:
Does moving the code inside imports and partials to the parents file can improve performance and building time? Which one is faster?

Regards

Here’s my current build results ->

3:08:24 PM: Build ready to start
3:08:27 PM: build-image version: 9e0f207a27642d0115b1ca97cd5e8cebbe492f63
3:08:27 PM: build-image tag: v3.3.2
3:08:27 PM: buildbot version: ef8d0929ed0baabafd8bbb7d0b021e1fc24180c0
3:08:27 PM: Fetching cached dependencies
3:08:27 PM: Starting to download cache of 119.0MB
3:08:28 PM: Finished downloading cache in 877.059013ms
3:08:28 PM: Starting to extract cache
3:08:31 PM: Finished extracting cache in 3.671813064s
3:08:31 PM: Finished fetching cache in 4.581074372s
3:08:31 PM: Starting to prepare the repo for build
3:08:32 PM: Preparing Git Reference refs/heads/master
3:08:33 PM: Found netlify.toml. Overriding site configuration
3:08:33 PM: Different publish path detected, going to use the one specified in the toml file: 'public' versus '/' in the site
3:08:33 PM: Different build command detected, going to use the one specified in the toml file: 'hugo --gc --minify' versus '' in the site
3:08:33 PM: Starting build script
3:08:33 PM: Installing dependencies
3:08:33 PM: Started restoring cached node version
3:08:36 PM: Finished restoring cached node version
3:08:37 PM: v10.16.3 is already installed.
3:08:38 PM: Now using node v10.16.3 (npm v6.9.0)
3:08:38 PM: Attempting ruby version 2.6.2, read from environment
3:08:40 PM: Using ruby version 2.6.2
3:08:40 PM: Using PHP version 7.2
3:08:40 PM: Installing Hugo 0.57.2
3:08:40 PM: Hugo Static Site Generator v0.57.2-A849CB2D/extended linux/amd64 BuildDate: 2019-08-17T17:57:54Z
3:08:40 PM: Started restoring cached go cache
3:08:40 PM: Finished restoring cached go cache
3:08:40 PM: unset GOOS;
3:08:40 PM: unset GOARCH;
3:08:40 PM: export GOROOT='/opt/buildhome/.gimme/versions/go1.12.linux.amd64';
3:08:40 PM: export PATH="/opt/buildhome/.gimme/versions/go1.12.linux.amd64/bin:${PATH}";
3:08:40 PM: go version >&2;
3:08:40 PM: export GIMME_ENV='/opt/buildhome/.gimme/env/go1.12.linux.amd64.env';
3:08:40 PM: go version go1.12 linux/amd64
3:08:40 PM: Installing missing commands
3:08:40 PM: Verify run directory
3:08:40 PM: Executing user command: hugo --gc --minify
3:08:40 PM: Building sites …
3:08:40 PM: WARN 2019/08/18 08:08:40 Page's .URL is deprecated and will be removed in a future release. Use .Permalink or .RelPermalink. If what you want is the front matter URL value, use .Params.url.
3:08:40 PM: WARN 2019/08/18 08:08:40 found no layout file for "HTML" for "taxonomyTerm": You should create a template file which matches Hugo Layouts Lookup Rules for this combination.
3:08:40 PM: WARN 2019/08/18 08:08:40 found no layout file for "HTML" for "section": You should create a template file which matches Hugo Layouts Lookup Rules for this combination.
3:08:40 PM: WARN 2019/08/18 08:08:40 found no layout file for "HTML" for "taxonomyTerm": You should create a template file which matches Hugo Layouts Lookup Rules for this combination.
3:08:40 PM:                    |
3:08:40 PM:  EN
3:08:40 PM: +------------------+----+
3:08:40 PM:   Pages            | 37
3:08:40 PM:   Paginator pages  |
3:08:40 PM:  3
3:08:40 PM:   Non-page files   |  0
3:08:40 PM:   Static files     |  5
3:08:40 PM:   Processed images |  0
3:08:40 PM:   Aliases
3:08:40 PM:  |  3
3:08:40 PM:   Sitemaps         |  1
3:08:40 PM:   Cleaned          |  0
3:08:41 PM: Starting post processing
3:08:40 PM: Total in 56 ms
3:08:40 PM: Skipping functions preparation step: no functions directory set
3:08:40 PM: Caching artifacts
3:08:40 PM: Started saving pip cache
3:08:41 PM: Finished saving pip cache
3:08:41 PM: Started saving emacs cask dependencies
3:08:41 PM: Finished saving emacs cask dependencies
3:08:41 PM: Started saving maven dependencies
3:08:41 PM: Finished saving maven dependencies
3:08:41 PM: Started saving boot dependencies
3:08:41 PM: Finished saving boot dependencies
3:08:41 PM: Started saving go dependencies
3:08:41 PM: Finished saving go dependencies
3:08:41 PM: Build script success
3:08:41 PM: Starting to deploy site from 'public'
3:08:41 PM: Creating deploy tree 
3:08:41 PM: 0 new files to upload
3:08:41 PM: 0 new functions to upload
3:08:41 PM: Post processing done
3:08:41 PM: Site is live
3:09:02 PM: Finished processing build request in **35.378011488s**

Is that good?

That’s definitely one of the faster builds on our system! It’s rare to see one that runs anything finish in under a minute considering the cache import/save and the rest of the setup like installing go and proper hugo versions.

I think a more useful question is how fast your site loads now :slight_smile: It should be faster than before, or the build time is pretty irrelevant, right?

1 Like

The load speed performance is faster now. By the way, what is the best way to improve building time process? Maybe via gitignore files or else?

@BayuAngora, the actual build command is completing in under a second. I don’t think you will be able to do much to improve that. (I do love Hugo’s performance!)

The rest of the time is spent doing the work of the build image itself (cloning the repo, installing the hugo version configured, etc). I don’t see any place where there is room for improvement.

1 Like

Thanks, Luke. Also, I always served images on external CDN to improve performance.