Serve files under directory beginning with "."

I need to serve a file under a directory like .well-known but it seems that this is not allowed. The file is supposed to be accessed through https://domain-name/.well-known/filename, but this results in a 404 error. I have this directory inside my static directory currently. Does anyone know what to do here?

static/
└── .well-known/
    └── myfile.txt

Now run hugo.

public/.well-known/
└── myfile.txt

The site builds properly.

Can you view the file in the browser when you run hugo server and visit
http://localhost:1313/.well-known/myfile.txt?

If I remember correctly, this is a hardcoded filter for the /static dir only (there have been a recent discussion about this on GitHub).

Long story short, I suspect you need to put that directory inside /content.

Can you view the file in the browser when you run hugo server and visit
http://localhost:1313/.well-known/myfile.txt?

No, this is where I’m stuck. I have the directory structure as in your first example but the file doesn’t get served (404). If I remove the dot from the folder name and visit http://localhost:1313/well-known/myfile.txt then this works.

Long story short, I suspect you need to put that directory inside /content.

This doesn’t seem to work either.

(there have been a recent discussion about this on GitHub)

Would you be able to point me to where I can find this discussion?

Just to make sure we are both looking at the same thing, please try:

git clone --single-branch -b hugo-forum-topic-33131 https://github.com/jmooring/hugo-testing hugo-forum-topic-33131
cd hugo-forum-topic-33131
hugo server

Then visit http://localhost:1313/.well-known/myfile.txt

1 Like

Yes, this file loads perfectly fine for me, so there must be some kind of filtering condition in my own repository.

Where should I look for this configuration?

What’s in your configuration file(s)?

You could also share your repository…

As it turns out, after restarting the server, the file is now showing up properly. There must have been some kind of caching going on that didn’t detect the “.” directory when I added it initially (but which detected other new directories). Thanks for taking the time to help nonetheless!