If you want to remove the file extension, then maybe youâll find .File.BaseFileName more convenient. (File variables | Hugo)
@pamubay is probably right, the problem is not coming from testcomp.md, but from somewhere else. In my case, I didnât have a _index.md file under /posts, and this was the full error:
Error:
Error building site:
failed to render pages:
*render of âsectionâ failed:
âC:\Users\agust\code\hugoprojl\layouts_default\baseof.html:14:7â:
execute of template failed: template: _default/list.html:14:7:
executing â_default/list.htmlâ at <substr $.File.LogicalName 0 -3>:
error calling substr:
calculated start position greater than end position: 0 > -3
And the bold part is the only clue of what is missingđ
Then it should work though. You could try to debug what is inside of $.File - maybe one of your posts does not have a LogicalName value. But @acanalis is right: You should use the proper file function. It will be safer with weird file names.
Another âblack boxâ thought: if you appoint variables with := they canât be re-appointed later on. With a more complete sample of your file it might be possible to see, if that is happening. From a non-Go-developers mind: I always appoint a variable once with := and then overwrite the value with =.