Fixing "This file should not be imported in this context." Layout Error

This post may contain referral links which may earn a commission for this site

Fixing "This file should not be imported in this context." Layout Error

Having trouble exporting and importing Divi builder layouts? These tips might help.

Recently, while trying to export / import a Divi Builder page, I received an error I hadn't seen before:

This file should not be imported in this context.

A quick google led me to see that this was a problem others have been having. In reply to one such comment, Elegant Themes' advise:

This means you are uploading the file to the wrong place, or you are uploading the wrong type of file… Go to Divi > Divi Library and click the "Import & Export" button. Also, be sure to unzip the file first and upload the .json file inside.

I was trying to export from a page and import to a blank page on another site, so there didn't seem to be any particular problem with the place I was uploading the file to. While I could have tried uploading it to the Divi Library directly, I was pretty sure I should be able to import directly to the page, and it was something I wanted to do, so I figured I'd save the Divi Library upload as a last resort.

Looking at the file I had exported, it was of the right file type (.json), and was not zipped. However, when I opened the file, I realized it was completely empty. Clearly there was a problem with the export which needed to be sorted before the import could be expected to work. I tried reloading the page I wanted to export, and re-exporting it. However, the exported file was again empty.

Changing where you import the layout to

It seems that the json layout files record the "context" in which they were saved. If you open a json layout file in a text editor you should see that it starts with something like : {"context":"et_builder", …

When uploading, Divi checks to ensure that the context it is being imported to is the same as the one it was exported from. So if the layout was exported from a page / post (context = "et_builder") you need to create a new page / post and import the layout into that. If on the other hand the layout was exported from the Divi library (context = "et_builder_layouts"), then the layout will need to be imported into the Divi Library (i.e. at "Divi > Divi Library > Import & Export").

So if you get the "can't import in this context" error, try importing into both the library and in a new draft page and see if one of those works for you.

Changing the Filename

Another thing that I have found to affect whether or not the export works is the choice of filename for the exported layout. In one case, I noticed that if the filename I entered contained spaces or hyphens, the downloaded file would be empty. Simply changing the filename to a single word (e.g. "layout") resulted in the download working correctly.

Try different upload methods

I found this on ET's support forum. One user apparently had different results with the different uploaders in Divi. Here is what they found:

Apparently there are 3 ways to add the .json File.

From dashboard > Divi > Divi Library . Did not work
From Visual Editor > where import/export icon is. Did Not work
From Page editor > Where import/export icon is. This one did work.

I believe the "Page editor" being referred to in the last item is what is now known as the Classic Builder. To access it, first enable the "Divi > Theme Options > Builder > Advanced > Enable Classic Editor" setting. Also, temporarily disable the "Enable The Latest Divi Builder Experience" option above it if you have that enabled already. Now go to the standard WordPress "Add New Page" or "Edit Page" screens and you should see the classic builder with its up / down arrow icon (the import/export icon), like so:

Changing file permissions

As Joakim points out in the comments, a file permission error might also trigger the context error:

Make sure WordPress has the correct permissions to upload files.
Instead of providing a permissions error, it will give you a context error.

Set correct permissions to the upload folder and make sure the group is www-data (or Whatever WP is run under)

Thanks Joakim!

Want get more out of Divi?

Hundreds of new features for Divi
in one easy-to-use plugin

52 Comments

  1. Omg, many thanks!!! Use Classic Editor and it's ok now.

    Reply
    • Great! I'm glad you got it working, Olga!

      Reply
  2. Thank you very much it helped me a lot !

    Reply
  3. Resetting the permalinks in Divi 4 can also resolve some instances of this problem.

    Reply
    • Thanks for the tip, Tom!

      Reply
    • all of this tips does not work

      Reply
      • Sorry to hear it, Jaxur. If you like, send me a copy of your layout file via my contact form and I'll see if I can figure out what's wrong. If you select "bug report" on the contact form you'll get an autoreponse email to which you can attach the file. Thanks!

        Reply
  4. Thanks a ton!

    Reply
    • You're welcome, Tina!

      Reply
  5. Which files need the permissions changing?

    Reply
    • I managed to solve this issue. In my case, the uploads folder was missing from my WP install. My web host (for some reason, prob security) had not allowed the creation of an uploads folder. I created one in FTP (filezilla) and it works now. 🙂

      Reply
      • Okay, great! Thanks for the update, Michael 🙂

        Reply
  6. Same mistake…. Nothing works…. Divi Support also not find nothing, but I get it… 😉
    I dont know why, but if you open the .json file with a text editor, the first line of the file was empty.
    Just Delete the first EMPTY line and the import works fantastic…

    Reply
    • Awesome, thanks for sharing that Pino. One thing that springs to mind is that occasionally plugins / child themes will accidentally output blank lines (due to closing PHP tags before the end of a file). Perhaps this is where your blank line came from… If you have a lot of layouts to export, you could try disabling other plugins before doing so to see if that gets rid of the blank line and saves you some work. Anyway, glad you figured it out and thanks again 🙂

      Reply
  7. Hello! Thanks so much for this.

    "From Page editor > Where import/export icon is. This one did work."

    I'm trying to find the import/export icon in the Page editor. I'd be grateful if you could upload a screenshot. Thanks!

    Reply
    • Hi Tania, I've just added some explanation and a screenshot to that section – I hope it helps!

      Reply
  8. Hi, Dan, thanks for sharing your tips.
    I also wanted to share what was causing in my case the issue, just in case anyone is in the same situation.
    I have a local copy of my site, and it had the debug mode activated. So the exported json started with a debug notice:
    "
    Notice: Constant WP_POST_REVISIONS already defined in…"

    After reading in this article that the file should start with context = "et_builder_layouts" (or context = "et_builder") I deleted all lines before it, and, once I did it, the issue was fixed.

    Reply
    • Ah, interesting. Thanks for that, Pablo – I hadn't come across that before, but it makes sense. I guess another fix (for anyone not wanting to edit the file itself) would be to disable debugging in wp-config.php and re-export the file. Thanks again!

      Reply
  9. Thank you! You saved me easily over 100 hours of work. You're a legend! Thanks again. 🙂

    Reply
    • You're welcome, Jaye!

      Reply
  10. Thanks mate. Had same issue. Importing into the page and not the library did the trick

    Reply
  11. Thank you for this amazing tip. God bless you

    Reply

Submit a Comment

Your email address will not be published. Required fields are marked *

Hundreds of new features for Divi
in one easy-to-use plugin

52 Comments

  1. Omg, many thanks!!! Use Classic Editor and it's ok now.

    Reply
    • Great! I'm glad you got it working, Olga!

      Reply
  2. Thank you very much it helped me a lot !

    Reply
  3. Resetting the permalinks in Divi 4 can also resolve some instances of this problem.

    Reply
    • Thanks for the tip, Tom!

      Reply
    • all of this tips does not work

      Reply
      • Sorry to hear it, Jaxur. If you like, send me a copy of your layout file via my contact form and I'll see if I can figure out what's wrong. If you select "bug report" on the contact form you'll get an autoreponse email to which you can attach the file. Thanks!

        Reply
  4. Thanks a ton!

    Reply
    • You're welcome, Tina!

      Reply
  5. Which files need the permissions changing?

    Reply
    • I managed to solve this issue. In my case, the uploads folder was missing from my WP install. My web host (for some reason, prob security) had not allowed the creation of an uploads folder. I created one in FTP (filezilla) and it works now. 🙂

      Reply
      • Okay, great! Thanks for the update, Michael 🙂

        Reply
  6. Same mistake…. Nothing works…. Divi Support also not find nothing, but I get it… 😉
    I dont know why, but if you open the .json file with a text editor, the first line of the file was empty.
    Just Delete the first EMPTY line and the import works fantastic…

    Reply
    • Awesome, thanks for sharing that Pino. One thing that springs to mind is that occasionally plugins / child themes will accidentally output blank lines (due to closing PHP tags before the end of a file). Perhaps this is where your blank line came from… If you have a lot of layouts to export, you could try disabling other plugins before doing so to see if that gets rid of the blank line and saves you some work. Anyway, glad you figured it out and thanks again 🙂

      Reply
  7. Hello! Thanks so much for this.

    "From Page editor > Where import/export icon is. This one did work."

    I'm trying to find the import/export icon in the Page editor. I'd be grateful if you could upload a screenshot. Thanks!

    Reply
    • Hi Tania, I've just added some explanation and a screenshot to that section – I hope it helps!

      Reply
  8. Hi, Dan, thanks for sharing your tips.
    I also wanted to share what was causing in my case the issue, just in case anyone is in the same situation.
    I have a local copy of my site, and it had the debug mode activated. So the exported json started with a debug notice:
    "
    Notice: Constant WP_POST_REVISIONS already defined in…"

    After reading in this article that the file should start with context = "et_builder_layouts" (or context = "et_builder") I deleted all lines before it, and, once I did it, the issue was fixed.

    Reply
    • Ah, interesting. Thanks for that, Pablo – I hadn't come across that before, but it makes sense. I guess another fix (for anyone not wanting to edit the file itself) would be to disable debugging in wp-config.php and re-export the file. Thanks again!

      Reply
  9. Thank you! You saved me easily over 100 hours of work. You're a legend! Thanks again. 🙂

    Reply
    • You're welcome, Jaye!

      Reply
  10. Thanks mate. Had same issue. Importing into the page and not the library did the trick

    Reply
  11. Thank you for this amazing tip. God bless you

    Reply

Submit a Comment

Your email address will not be published. Required fields are marked *