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

Recently, while trying to export / import a Divi Builder page in the Divi theme, 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!

Check your Images

Rudy notes in his comment that removing modules which had large background GIFs fixed his import issue:

 I decided to go step by step by importing each of the modules of the layout. I realized that in 2 modules I had 2 GIF files as a background, each weighing 1 MB.
When I deleted those collections in the library, the import worked for me.
I don't know if it will be the type of file or the size of the file.

Thanks Rudy!

Increase Upload Max Filesize

Ernesto found that increasing the Upload Max Filesize setting fixed it for him:

To know what's your upload max size limit simply go to your Dashboard on your wordpress site and select Media, then select Add New, look where it says "Maximum upload file size", you will see your file limit there.

Mine said 2MB, and the json template page that I wanted to import was 5MB. Obviously is more than what is allowed to upload.

To fix this is super simple, just contact tech support and ask them to raise your max upload limit.

Or if you're like me and want to fix it in 2 minutes, here's what i did…

I first tried to delete images from the webpage that I wanted to import, that way I can bring down the file size below 2mb, but then I changed my mind and decided to increase the max limit size in my hosting account because is easier that way.

I first tried the php.ini option but that didn't work. What did it for me was adding the values to the .htaccess file instead, in the root directory of your website.

Oftentimes you can access the htaccess file via FTP or you can log into your cPanel and click where it says File Manager, in the file manager locate the folder "html public" or where-ever the root folder is, it usually contains your homepage such as index.php.

Once you see the .htaccess file, right click and select Edit, a page will open with lots of weird code in it, scroll to the bottom of that code and add this code at the end:

php_value upload_max_filesize 64M
php_value post_max_size 64M
php_value max_execution_time 300
php_value max_input_time 300

Click save or update, and you're done.

Go check the max file again, go to your wordpress dashboard and click Media, Add New, if your max file size changed to 64MB it means it worked. Make sure you refresh the page so that it gives you an accurate max size limit.

If it didn't work, change the max limit to 10MB, and add it to the htacess code:

php_value upload_max_filesize 10M
php_value post_max_size 10M
php_value max_execution_time 300
php_value max_input_time 300

If that doesn't work, contact your tech support and ask them to raise your upload max limit.
That should fix it. :)

Note: Be sure to take a backup before making any changes to the .htaccess file, since errors in that file can make your site inaccessible.

Thanks Ernesto!

Use Divi Cloud

If none of the above work, or if you regularly transfer layouts between sites, you might like to try transferring your layout using Divi Cloud, a feature built into Divi since v4.17.

Divi Cloud lets you save layouts from your source site directly to your Elegant Themes account. These layouts can then be accessed from any of your sites, without the need to export / import them.

You can save 50 layouts for free. Unlimited layouts are available with a paid subscription.

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

Divi Booster

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

84 Comments

    • Thanks for sharing, Daniel, and awesome that there’s already a fix in the works :)

      Reply
  1. I tried all these options. However it turned out to be an age old WordPress problem – a plugin conflict. If you have a plugin that exports/imports data then it may be altering the behaviour of the core JSON creation code.

    So my advice is to deactivate each of the plugins starting with the data export ones.

    I haven't yet identified which one was causing the conflict (haven't had time yet) but once I turned all the export plugins off the core Divi export functionality worked fine.

    Reply
    • Ah, interesting. Thanks for pointing this one out, Hawke. I'm not surprised to hear plugin conflicts can cause this – they seem to be able to be able to cause pretty much any problem out there! If you do happen to figure out which plugin it was, I'd love to know! Thanks!

      Reply
  2. I was having the same issue and none of the solutions mentioned worked. (I was working in XAMPP building a site on my localhost FYI)

    I got the php.ini file changes I needed to make from Elegant Themes and it finally worked! Hopefully, this helps someone else with my issue.
    >>>
    Its likely to be an issue related to limited server resources. Please make sure that your server meets wordpress requirements, so please confirm with your web host if your website have:

    PHP 7 or greater
    MySQL 5.6 or greater OR MariaDB 10.0 or greater
    The mod_rewrite Apache module
    A minimum of 256M memory.

    Please also ask your hosting company to set these php directives with the corresponding values in your server's php.ini file:

    post_max_size 128M
    max_execution_time 180
    upload_max_filesize 256M
    max_input_time 600
    max_input_vars 5000

    Reply
    • Great! I'm glad you got it working, Stephanie, and thanks for taking the time to share what worked for you :)

      Reply
    • SOLVED!

      I tried every method online to solve this import problem and the real cause was the Limit Size.

      To know what's your upload max size limit simply go to your Dashboard on your wordpress site and select Media, then select Add New, look where it says "Maximum upload file size", you will see your file limit there.

      Mine said 2MB, and the json template page that I wanted to import was 5MB. Obviously is more than what is allowed to upload.

      To fix this is super simple, just contact tech support and ask them to raise your max upload limit.

      Or if you're like me and want to fix it in 2 minutes, here's what i did…

      I first tried to delete images from the webpage that I wanted to import, that way I can bring down the file size below 2mb, but then I changed my mind and decided to increase the max limit size in my hosting account because is easier that way.

      I first tried the php.ini option but that didn't work. What did it for me was adding the values to the .htaccess file instead, in the root directory of your website.

      Oftentimes you can access the htaccess file via FTP or you can log into your cPanel and click where it says File Manager, in the file manager locate the folder "html public" or where-ever the root folder is, it usually contains your homepage such as index.php.

      Once you see the .htaccess file, right click and select Edit, a page will open with lots of weird code in it, scroll to the bottom of that code and add this code at the end:

      php_value upload_max_filesize 64M
      php_value post_max_size 64M
      php_value max_execution_time 300
      php_value max_input_time 300

      Click save or update, and you're done.

      Go check the max file again, go to your wordpress dashboard and click Media, Add New, if your max file size changed to 64MB it means it worked. Make sure you refresh the page so that it gives you an accurate max size limit.

      If it didn't work, change the max limit to 10MB, and add it to the htacess code:

      php_value upload_max_filesize 10M
      php_value post_max_size 10M
      php_value max_execution_time 300
      php_value max_input_time 300

      If that doesn't work, contact your tech support and ask them to raise your upload max limit.

      That should fix it. :)

      Please let me know if it worked for you so that others know that this solution working.

      Reply
      • Hey Ernesto, great news that you were able to resolve it, and thanks so much for the detailed write-up of your solution – Much appreciated. I'll add it to the post now. Cheers!

        Reply
  3. thank you so much its work for me

    Reply
  4. I had really should be added to the "checklist of possible fails" is: 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=

    Reply
    • Thanks for this Joakim! I've added a section to the post with your advice. Cheers!

      Reply
  5. Thanks for this tip. I saved to the Library and exported from there and it worked fine!

    Reply
  6. I am still having the error even with all the solutions above. What else could I possibly do?

    Reply
    • It seems like the biggest problem is that the exported file ALWAYS exports empty.

      Reply
      • Hi Erica, I'm not sure what else to suggest – I haven't come across any other solutions beyond what I've already included in the post.

        If you're willing to send me login details to your site (via the contact form linked in the header above), I'll see if I can figure it out.

        Other than that, I'd suggest contacting Elegant Themes support and hopefully they can give you an answer. If so, I'd love to hear what solves it for you.

        Reply
    • I had this problem and it turns out I ran out of space in my hosting. Once it was increased, I was able to. Not sure if this would fix your problem…

      Reply
      • Cool, thanks for sharing your solution, Carol!

        Reply
  7. For me persistence seems to have paid off. I tried the various suggestions to no avail and then instead of importing in Divi library reverted to importing in page view. The first time it didn't work but then second time I clicked import and went into a new browser tab for a few minutes to do something else and lo and behold it uploaded! No clue why but the problem seems to be intermittent.

    Reply
  8. Has anyone found a solution to this 1% sticking issue. I have tried everything i have read online to sort this but im having no luck at all. Really starting to pull my hair out trying to sort this

    Reply
    • Hey Rob, there seems to be a few people having trouble with this. I haven't personally experienced it, so haven't been able to look into it myself.

      Taking a look on ET's support forums, they have some suggested settings for memory, upload file sizes, etc, though it's not clear if these actually solve the issue. See here for those settings if you haven't tried them out already:

      https://www.elegantthemes.com/forum/viewtopic.php?f=187&t=692628&hilit=Can%27t+import+layout+stops+at+1%25&start=10

      Interestingly one of the comments in that thread suggests that if you wait long enough (i.e. 15 mins), the import may complete.

      I've also added an additional section to the post about the three different upload methods. Perhaps one of the others will work for you?

      If you're interested in having me take a look (e.g. by logging into your site and trying it myself), please drop me a message via the contact form linked in the header. I'd be keen to see this issue in action.

      Reply
      • Hi Dan. Many thanks for your help, iv dropped you a message through contact form for you to log in and take a look. I really do hope you can find the answer as its driving me INSANE

        Reply
      • I'm having issues on one of my sites with this. But I went to another site that also has divi, and imported the layout I wanted, and then exported it to my machine…on the one where it actually worked, it stayed at 1% almost all the way to the end. and I didn't think it was going to work, but at the the last second, the progress bar just zipped to the end and it was done. The progress bar doesn't work like typical stuff…it stays at 1% until the end of the download, and then, it's just finished. stupid, right?

        Reply
        • Ha ha, yeah, that's not particularly helpful, is it?! After exporting to your machine were you then able to import it to the site you're trying to use it on, or are you still unable to do that?

          Reply
  9. I too have experienced this problem; the fix here worked. But, now a new problem actually two more has arisen. The up-loader hangs at 1% then locks the screen and then I had an upload stop show a red x in a circle and then close.

    This is becoming really irritating. What good does it do to save time by portability if it takes hours of research and trail an error.

    Another frustrating is the lack of an answer for the ability to upload json files via FTP. Countless customers have asked with no response. If it can't be done then say so, if it can, please give us the info so we can all move on.

    I don't like leaving on a negative note. I love Divi, it's an awesome theme with no more bugs than any other theme. It helps supplement my retirement income, so for that I thank you for a cost effective means to make extra income. But, please fix this bug!

    Reply
    • Hi Bob,

      Thanks for getting in touch. I'll just start by clearing up that I'm not part of the Divi team, or associated with Elegant Themes in any way. I'm just a regular Divi user and independent developer of Divi add-ons, and share solutions I've found to my own / my reader's Divi questions. The Elegant Themes' support forums are the best place to get in contact with ET themselves.

      I don't think there is any way to upload json files via FTP. I believe the uploaded json files are processed and stored directly into the database, so there's no place storing the layouts as json files. Plus, I'm not aware of any code that will process the json files from any location on the server – only through the uploader interface itself. So I suspect this is one to move on from for the time being.

      I'm not sure what is causing the uploader behavior you're seeing (as I haven't encountered that before), but if you'd be willing to let me login and take a look, or try out your .json file on my own site please let me know. Please send any login details, etc, through the contact form (linked in the site header).

      Thanks!

      Reply
  10. I'm having this issue as well, annoyingly! Saving it to the library is not working for me, neither is changing the file name.

    Reply
    • Sorry to hear it got you too, Nik! I'm not sure what else to suggest, but if you'd be willing to let me log into your site and take a look I might be able to figure it out. If you do, send me the URL / login details through my contact form, along with details of the page you're trying to export. Thanks!

      Reply
  11. Sorry for my bad english,
    If you have this same problem and you already have wordpress on a server, try giving write permissions to the wp-config folder, if you use linux navigate to the folder you want to give permission and use this command

    Chmod -R777.

    I've been searching for the solution for a few days and this worked, I hope it helps

    Reply
    • Thanks for sharing, Alejandro. I take it you meant the "wp-content" folder, right?

      One thing, I'd be wary of setting the permissions on the folder to 777. WordPress recommends avoiding 755 as the default permission for folders, and avoiding 777. If you do need to set it to 777 to get this to work, I'd change it back to 755 as soon as possible.

      Reply
      • The problem here is a missing or not writable /wp-content/uploads folder. When the uploads folder is missing (after a new WordPress install) and WordPress cannot create it because it cannot write or create anything in the wp-content folder it can help if you make the wp-content folder writable with "chmod -c 777 wp-content".

        After importing the Divi templates you can change it back to how it was. But you will keep problems every new month if you upload for example photos for posts. Because every month a new folder must be created in uploads/2017/xx.

        These problems are caused by write permissions of the webserver for files and folders. I think the solution was to give the webserver the right permissions.

        Leaving anything with 777 rights is very dangerous and makes your system vulnerable for hackers!

        Reply
        • Thanks for sharing this, dimitri. I'm sure others will find it useful. Cheers!

          Reply
      • Many thanks for that solution, after Chmod 777 the "wp-content" folder it worked fine. After hanging 15-20sec at 1% it loaded up the file, afterward, Chmod back to 755 to avoid security risk.

        Br

        Reply

Submit a Comment

Comments are manually moderated and approved at the time they are answered. A preview is shown while pending but may disappear if your are cookies cleared - don't worry though, the comment is still in the queue.

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