Range can't iterate over 日本語 (cannot find which source file causes problem)

Continuing the discussion from Stuck trying to debug error:

I have several files in my repo and apparently one has an unquoted tag.

The base repo is here. https://thunderrabbit@bitbucket.org/thunderrabbit/barefoot-rob.git

It has submodules in content/themes and content/journal They are loaded via ssh, but are public repos.

How do I figure out which markdown file is causing this error?

ERROR 2019/06/21 08:55:51 render of "page" failed: execute of template failed: template: _default/single.html:18:23: executing "sidebar" at <partial "pages/sidebar.html" .>: error calling partial: "/Users/thunderrabbit/barefootROB-hugo/themes/hugo-myportfolio-theme/layouts/partials/pages/sidebar.html:19:25": execute of template failed: template: partials/pages/sidebar.html:86:19: executing "partials/pages/sidebar.html" at <partial "utils/list-keywords.html" (dict "type" "tags" "context" . "scratch" .Scratch "removeDuplicates" true)>: error calling partial: execute of template failed: template: partials/utils/list-keywords.html:10:3: executing "partials/utils/list-keywords.html" at <partial "utils/get-keywords.html" (dict "type" .type "context" .context "scratch" .scratch "removeDuplicates" .removeDuplicates)>: error calling partial: "/Users/thunderrabbit/barefootROB-hugo/themes/hugo-myportfolio-theme/layouts/partials/utils/get-keywords.html:19:25": execute of template failed: template: partials/utils/get-keywords.html:19:25: executing "partials/utils/get-keywords.html" at <.context.Params.tags>: range can't iterate over 日本語

Here’s the relevant bit:

partials/utils/get-keywords.html:19:25: executing “partials/utils/get-keywords.html” at <.context.Params.tags>: range can’t iterate over 日本語

So I would use grep, or your text editor, to search for:


Thank you. I (already) did that but couldn’t find the problem. I tried to create a fancy regex to find unquoted instances of 日本語, but couldn’t figure that out, either.

Here is the result of the search


The tags in many of your journal entries are a mess. I hacked together a quick Perl script to quote each tag and wrap them all in an array, and now the site builds fine for me:

#!/usr/bin/env perl

use File::Find;
use File::Slurp;

find(\&wanted, ".");

sub wanted {
	return unless /\.md$/;
	my $text = read_file($_);
	if ($text =~ /^tags: *(.*)$/m && index($1, "[") == -1) {
		write_file($_ . ".old", $text);
		my @tags = split(/\s*,\s*/, $1);
		my $tags = '[';
		$tags .= '"' . join('","', @tags) . '"'
			if @tags;
		$tags .= ']';
		$text =~ s/^tags: *(.*)$/tags: $tags/m;
		write_file($_, $text);

(not every tag needed to be quoted, but even setting aside the Japanese ones, you’ve got some oddballs in there, and given the build time, I wasn’t going to keep iterating to find out exactly which ones needed fixing)

As a side note, the theme you’re using is not designed to handle large amounts of content; it took just under 10 minutes to build under Hugo 0.55.6 with 7,009 MD files in content, where my blog takes about 15 seconds to build successfully with 8,500 MD files:

                   |  EN    
  Pages            | 10095  
  Paginator pages  |     0  
  Non-page files   |  6106  
  Static files     |    35  
  Processed images |     0  
  Aliases          |     0  
  Sitemaps         |     1  
  Cleaned          |     0  

Total in 595760 ms



Thank you @jgreely for the tag cleaning Perl script It is enshrined for keeps next to the markdown files it cleaned up.

Double thank you for the note that the theme was not well suited for lots of files. I ended up going back to purehugo, which is fast even with lots of files.

[SOLVED] The original problem in my case was due to not having push/pulled the latest commits of the repo in which I had already cleaned the tags. smh.