Serving a plaintext file from the root of a ghost site

I’m migrating a site to ghost and have certain plaintext files served from the root of the site that I wish to preserve, e.g.

Is there any way to actually support this? I understand that static assets can be added to the assets/ directory in the theme, but this does not preserve the existing url structure. I understand that custom routes can be added to load a handlebar template that contains this content, but Ghost forces trailing slashes, and errors on any attempt to upload a route without it.

Have I missed anything, or is this simply not possible?

You should just be able to drop a file into the root theme folder as well :slight_smile:

No, I’m afraid that doesn’t work. I did try it to be sure, but it makes sense that it doesn’t; if it did, you’d be able to request the other files in the root of the theme such as the README file and *.hbs template files.

Ghost only blocks certain extensions, so you’re actually able to upload txt files. I just tried it on a local installation and it works:

screenshot of a terminal showing the contents of test.txt show up in ghost/test.txt

As suggested in this thread, have you tried in incognito or using curl to prevent browser caching?

Thanks so much for following up. I just tried again, and indeed a test.txt file at the root of the theme does work as expected. I’m not sure now what made me believe it didn’t before.

1 Like