Ghost Export Tool Not Exporting Multiple Authors

I have used the local NPM Ghost tool to setup a simple website. I have added three users to Ghost. I have created a post with three authors. When I go into the Labs sections of Ghost settings and export my site data, the post’s JSON field reads “author_id”: “1”. This author_id of 1 refers to only one of the authors listed on the article. Where are the other authors being saved to in the JSON file.

I have explored Ghost’s codebase and found one comment, which may have been related to this issue here: https://github.com/TryGhost/Ghost/blob/main/core/server/data/importer/importers/data/posts.js

  this.dataToImport[postIndex][targetProperty] = _.filter(this.dataToImport[postIndex][targetProperty], ((object, index) => {
                return indexesToRemove.indexOf(index) === -1;
            }));

            // CASE: we had to remove all the relations, because we could not match or find the relation reference.
            // e.g. you import a post with multiple authors. Only the primary author is assigned.
            // But the primary author won't be imported and we can't find the author in the existing database.
            // This would end in `post.authors = []`, which is not allowed. There must be always minimum one author.
            // We fallback to the owner user.
            if (targetProperty === 'authors' && !this.dataToImport[postIndex][targetProperty].length) {
                this.dataToImport[postIndex][targetProperty] = [{
                    id: ownerUserId
                }];
            }
        };

Are multiple authors exported by the export tool?

Thank you for your help!

Can you list the steps to reproduce? From my understanding:

  1. Create a post. Add 2 authors to it.
  2. Export your site
  3. Import your site and go to the post that was created. There will be only 1 author.

I am not able to reproduce that.

"author_id": "1" means the referenced author is the owner of the site. The snippet of code you shared handles the edge case where a post has 0 authors, in which case the author is assigned to the owner user.

1 Like

Whoops, it looks like I misinterpreted the meaning of the “author_id” field. Thank you for clarifying my confusion.

Thank you!

1 Like