0
votes

I've deployed my Hugo website using Netlify, but after my latest changes I keep getting the same error that is as follows:

Failed during stage 'deploying site': Invalid filename 'tags/c#/page/1/index.html'. Deployed filenames cannot contain # or ? characters

I can't find any file in my repository that contains such a path and my index.html doesn't contain any of those invalid characters either. I have attempted to revert the changes but I still receive the same deployment error.

Where should I be looking in my repo files to diagnose this problem?

2

2 Answers

0
votes

That is pointing to an auto-generated file that lists those pages that have 'C#' as a tag in the front matter. So look for pages that have something like:

tags: [ 'C#']

in it.

In order fix, you will need to change the tag to 'c-sharp' or something similar.

Or - check that preserveTaxonomyNames is not in your site.yml (or is set to false).

0
votes

This error happens when we use C# tag or other that contains # in our post/markdown because Hugo will generate static files in public folder according to the tag such as tags/c#/index.xml.

We certainly can replace with other tag like C-Sharp or similar but if we still want to see C# tag in our post there is a workaround for that.

After replacing the tag with C-Sharp for example.

tags: ["C-Sharp"]

We need to override html file where this new tag will appear, then replace following code

<a href="{{ "/tags/" | relLangURL }}{{ . | urlize }}/">{{ . }}</a>

with

<a href="{{ "/tags/" | relLangURL }}{{ . | urlize }}/">{{ replace . "-Sharp" "#" }}</a>

Please notice we replace -Sharp with # so that C# will still appear on our post but the url will be [your-site]/tags/c-sharp/ and Hugo won't generate tags/c#/index.xml in public folder. Therefore, we can avoid the error.

This is summarized from here.