Remote file with fullstops not generating and failing build

I am using the pages from data workaround to import remote data into my site as content. However, one of the entries in the remote file has fullstops in its its name and thus appears blank when I run hugo in the base folder and the build fails. I am using the name field to generate the permalink for the files.

The file has a title of name: name-P.ag.. in the front matter which becomes name.p.ag...md in the remote folder. But on running the hugo command, the build fails

Error: Error building site: failed to render pages: open C:\hugo-site\public\remote-data\name-p.ag..\index.html: The system cannot find the path specified.

I am using the name field to generate the permalinks and I am not sure if the double dots .. are causing the issue.

I roughly tested and multiple dots may and may not cause issues.

You need to remember in template that

name: name-P.ag...md

and

name: "name-P.ag...md"

may be treated differently in different operating systems and different codes.

We would know more if you will share how this name field is read and used etc.

Hi! Why not simply rename the file if you find two consecutive dots in its title?

{{ $filename := $title }}
{{ if in $filename ".." }}
  {{ $filename = replace $filename ".." "-" }}
{{ end }}

Does this go in the index file for the remote/prebuild folder? Here is my code

{{- $URL := "https://remote-data.json" }}
{{ with resources.GetRemote $URL }}
{{ $data := . | transform.Unmarshal }}
{{ range $data.features }}
{{- with .properties }}
{{/* 1. */}} {{ $string := jsonify . }} 
{{/* 2. */}} {{ $filename := printf "remote/%s.md" (urlize .Name) }} 
 {{/* 3. */}} {{ $resource := resources.FromString $filename $string}} 
{{/* 4. */}} {{ $file := $resource.RelPermalink }}
{{ end }}
{{ end }}
{{ end }}

It would go here, when you define your $filename.

Excellent! I removed {{ $filename := $title }} and it works now.

1 Like

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