How can I host a plain text file at the root of my site?


#1

I have a ghost blog at https://blairmacintyre.me that I moved from jekyll.

I use keybase for secure messaging, and one of their “proofs of id” is to prove you own various sites. To provide I own blairmacintyre.me, I must host a plain text file at https://blairmacintyre.me/keybase.txt

I tried adding a route:

  /keybase.txt/:
    template: keybase
    content_type: txt

and putting the text in keybase.hbs, but that resulted in a simple webpage with the text wrapped

<body><pre>
...
</pre></body>

I’m hoping there’s something obvious I’m missing.


#2

Hey @blairmacintyre

Unfortunately Ghost doesn’t currently support adding files at the root of your site.

If you are able to have keybase read from a directory, you could include the file in your theme - though I suspect this won’t be good enough proof for keybase?

How is your Ghost site hosted? If you have a http server (e.g. nginx) in front of it, you could add a rule to your config to serve the keybase.txt file at that level.

e.g. for nginx

location /keybase.txt { alias /path/to/keybase.txt }

#3

My site is ghost pro, so it’s hosted on ghost.org … sorry that wasn’t clear.

There’s no way to change where keybase pulls the proof from.

If there’s no supported way to do this, is it possible for you to simply handle this with a rule, for all ghost installs, like you do for robots.txt?

UPDATE: looking at that URL, it appears to be returning just the txt in the file now, and keybase seems happy. Did you change anything, or did the route start working? The HTTP response headers don’t seem to be saying it’s a txt mime type, but only the txt is being returned without any HTML decoration.


#4

This sounds way to complex. You can drop the .txt file in your theme root and that will simply work.


#5

Nope, that doesn’t work; I get an error page with

422
Validation (isSlug) failed for slug

if I put the file there without a route of some form. Putting a route results in an default page with not “content” part.


#6

and … after trying out the @HauntedThemes suggestion, and switching back to the previous approach I tried, that’s not working again.

Weird.


#7

@blairmacintyre I missed that you were a Ghost(Pro) user, send an email over to support@ghost.org and we’ll get you sorted with something.


#8

Fabien, thanks! I’d sent mail to support@ghost.org pointing at this post, over the weekend; Sarah Frantz had replied this morning letting me know that you’d replied here. I’ll let you and her coordinate and see what a good solution is. Supporting keybase directly would be pretty nice, though, especially since it’s trivial.


#9

@blairmacintyre Hopefully this is final update - I made a mistake earlier and was incorrect in saying we couldn’t have a custom file at the root of the domain.

@HauntedThemes Was correct when they said you can add the keybase.txt at the root of the theme.

I’ve tested this on my personal Ghost(Pro) instance and can confirm it works.

I think you should revert any changes to routes.yaml you made to do with this, (if you need them, here are the default routes.yaml)

You should then add the keybase.txt file to the root of your theme, zip it up, and upload.

Sorry for the confusion :weary: I hope this gets you sorted - let me know if you still have issues :hugs:


#10

@fabien I tried it, it didn’t seem to work. I’ll try again. Perhaps I messed something up. Will let you know asap.


#11

Tried again. I’m still getting the 422 error at https://blairmacintyre.me/keybase.txt

I put a text file at the top level of the the theme, where all the .hbs files are.


#12

I think you may have run into some caching issues, when visiting that URL I see what looks like a verification file for your keybase identity!


#13

I’m still seeing 422 in Firefox after clearing those sites out of the cache (weird), but Safari shows the file.

Also, I was a bit confused … the inspector on both browsers (when FF was getting the file) both show the text file as being wrapped in some HTML … however, the resource inspector on Safari shows that the downloaded file is the plain text, so I think the inspectors are showing what it’s displaying, not what it downloaded. Silly browsers.

UPDATE: it keeps giving me 422 because the browser keeps auto-completing the URL to http://blairmacintyre.me/keybase.txt/ (adding the trailing slash). If I carefully remove that, it’s all good.

So, to recap, as @HauntedThemes suggested up top, and you confirmed @fabien, “just put the file at the root of the them.” :joy::joy::joy:

So, I think things are ok, I’ll report back if they aren’t.


#14

Now, the only task I have remaining is to manually fix all ~150 old posts that I moved from jekyll -> ghost 1.0 -> ghost 2.0. The process didn’t carry the jekyll permalinks over to the ghost slug, and the dates are (mostly) all off by 1 day, so I need to fix those and redo all the markup. Tedious but straightforward. And it’s looking pretty awesome.


#15

I’m glad you got this sorted! And good to hear you’re enjoying Ghost :relaxed:


closed #16

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