Can't upload routes.yamls for dynamic routing. Error "Please select a valid YAML file to import."


#1

My setup is as follows:

  • Ubuntu/Linux server (16.04)
  • Ghost-CLI version 1.9.2
  • Ghost version 2.1.1
  • I use Firefox on Ubuntu, but tried Chromium as well as the Ghost-desktop app for Ubuntu
  • No special configuration I believe

I wanted to change the routes.yaml file in order to have a static home page, but every time I upload a routes.yaml file (exactly named that), I get the error “Please select a valid YAML file to import”. Another user had (has?) apparently a similar problem with respect to multi-language support. @Kate and @Hannah suggested that it is a problem with linux (the serverside, I assume) missing some YAML content type…

I tried to do ‘npm install yaml’ on my server, but it doesn’t change anything. I did so, assuming that (i) Ghost uses npm to do checks on routes.yaml; (ii) that the missing package is the node yaml package. There are other yaml packages for node though.

My question: What can/should I do to install all the YAML content types on my linux server?

Thanks,
Marc


#2

I believe the suggestion is that it might be due to Ubuntu on your local computer not applying a content type, rather than the server. It definitely works on the server.


#3

@marc

If you open the developer tools in Firefox and record the upload request, you can see which Content-Type header is sent to the server.


#4

@Kate

If I understand you correctly, you mean the Content-Type of the HTTP request? If so, it is

Content-Type: multipart/form-data; boundary=---------------------------… (some numbers)

And yes, I get a 415 error, which is an Unsupported Media error.

So, if I understand correctly, other browsers on other platforms submit this as (say) Content-Type: YAML, and all would be good. What can I do on Ubuntu to get around this?

Having said that, I updated the content/settings/routes.yaml file on the server directly, and it didn’t have an effect (although that may have been a caching issue, since I changed it and went to the homepage). Is that the right place to edit the routes.yaml file?

Thanks for the superquick response.


#5

If you change the routes.yml file, you need to restart your ghost instance for the changes to take effect


#6

@marc

Can you look at the request payload?

------WebKitFormBoundaryKcqPPJhXM3OOyPlf
Content-Disposition: form-data; name="routes"; filename="routes.yaml"
Content-Type: application/octet-stream

#7

@Kate Edit: Found it:

-----------------------------9025189121765679086983847821
Content-Disposition: form-data; name=“routes”; filename=“routes.yaml”
Content-Type: application/x-yaml

routes:

collections:
/:
permalink: /{slug}/
template:
- index

taxonomies:
tag: /tag/{slug}/
author: /author/{slug}/

-----------------------------9025189121765679086983847821–

@vikaspotluri123 That turns out to work (although my configuration is all wrong it seems, and interating this process won’t be fun - but it’s possible). Thanks!


#8

Here we go. This content type is currently not accepted by the Ghost server.
I just pushed this fix, will be released tomorrow :slight_smile:


#9

Great, I will try it tomorrow (or the day after, since I am on GMT) and let you know if it works.


#10

I’ve installed the new ghost, and uploading routes.yaml worked right away. Thanks @Kate