Skip to main content
templates holds one document per template in the template gallery. The files of a template (the project zip and the PDF) are not here: they are kept in filestore under template/<_id>/v/<version>/. The collection belongs to the template-gallery web module (services/web/modules/template-gallery). The schema is the Mongoose model Template in services/web/modules/template-gallery/app/src/models/Template.mjs; the logic is in services/web/modules/template-gallery/app/src/TemplateGalleryManager.mjs and TemplateGalleryHelper.mjs next to it.

Fields

Who Writes It

Only site admins and the user in OVERLEAF_TEMPLATES_USER_ID may call these three routes (services/web/modules/template-gallery/app/src/Router.mjs:55-62,70-84, PermissionsMiddleware.mjs:8-19).

Who Reads It

Indexes

Mongoose autoIndex is off (services/web/app/src/infrastructure/Mongoose.mjs:7). tools/migrations/20190912145030_create_templates_indexes.mjs (unique project_id, user_id, name) is tagged server-pro and saas, so it does not run in CE, which runs only the server-ce migrations (server-ce/init_scripts/900_run_web_migrations.sh).

Notes

  • Upstream treats templates as a stale collection and drops it on its own site (tools/migrations/20241002180623_drop_unused_collections.mjs, tagged saas). In Ayakaleaf Pro the template gallery module uses it.
  • Sorting by name uses a case-insensitive collation, and the comment at TemplateGalleryManager.mjs:186-188 notes that a name index would need the same one. CE has no name index, so Mongo sorts in memory.
  • Deleting the source project or the owner does not delete the template.
Last modified on November 14, 2026