Uploading Hello World Package (.h5p file) fails =>


This was already discussed here https://h5p.org/node/617131 ... but i am not able to solve the issue for me.

I am running a Moodle 3.9 stable release with the H5P Plugin installed.

I created the hello world package following the official tutorial.

Uploading the .h5p file in the moodle content bank:

I figured out that the issue is related to how directories are archived in the zip file. But I did not found a way to solve this. I tried zipping the package under Ubuntu and windows 10 using different tools. With no success.

For example Arithmetic-Quiz Zipfile vs my Hello World Zipfile (i used 7-Zip)

Please provide information how to create a valid h5p package file under windows 10.




Moodle Error


Arithmetic Quiz Zipfile Structure vs my Hello world Zipfile Structure

otacke's picture

Hi awertner!

The proper and documented way to create H5P libraries is by using git repositories and H5P CLI, not manually zipping everything. I don't remember exactly, but if you really want to do it the hard way, then there's a particular flag that needs to be set when zipping. Might have been -D and/or -X to discourage directory entries and to exclude extra file attributes.


Hi otacke,

I prefer the proper way and will give it a try.




otacke's picture

Hi Alfred!

Once you have it running you'll like it, I think :-D The tool can automatically strip files that shouldn't be in the archive, pack libraries recursively, help you with translations, etc. The only quirk is that it expects to be working on git repositories, so if your folder with the H5P content isn't one, you'll have to add a dummy file .git/config to trick it.


Now i am working on a git repository and using the H5P command line interface.
And i can create the package file with the h5p pack command.
Very nice, worked out fine.

Looking in the packed files folder structure, the library folder as root folder is included.
Like this:
...and so on

Importing the .h5p file in moodle fails because it expects the folder structure on the level "inside" the library folder.

I could not figure out how to achieve this with the h5p pack command.
I am working under windows 10, Ubuntu Subsystem.


otacke's picture

Hi Alfred!

There are (unfortunately) two types of H5P files, and that might be the origin of the confusion.

content files

Content files are the packages that can be downloaded by using the reuse button below H5P content or by fetching them from the host system's export folder. They contain

  • the h5p.json file that tells H5P what the file bundle consists of,
  • the content folder with content.json telling H5P what parameters were used in the editor to create the content,
  • the content folder with all the media assets that were used, e.g. images or videos,
  • all the libraries that the content type uses.

This allows you to share the files and be (quite) sure that they can be used on another platform even if that is missing some of the libraries. H5P will install those that are missing from the package if that's not prohibited by the admin.

Those content files need to be uploaded using the H5P Hub.

library packages

Library packages are just a bunch of H5P libraries within one archive - no h5p.json, no content folder. That's what H5P cli creates. For example, if you have library.json, semantics.json and at least one JavaScript file with your code (e.g. helloworld.js) in the folder h5p-hello-world, you'd use

h5p pack h5p-hello-world ~/output.h5p

to create a library package named output.h5p in your home directory. That package would contain a folder named after the machine name that's defined in your library.json followed by the version number, so e.g. H5P.HelloWorld-1.0. That folder then would contain the files required for the library. The h5p.json file and the content folder should ot be inside your development folder that you pack with H5P cli; they are only required by content.

Those library packages cannot be uploaded using the H5P Hub, but they must be uploaded on the H5P library page.

Hope that helps.