Who this is for. A developer joining a site that already exists. Afterwards you can recognise the shape of the repository in front of you, know which differences matter, and find your way around it in a few minutes instead of a few days.

There is no single prescribed layout. A repository reflects the year it was started, the build tool its first developer preferred and how much the site has grown. Learn to recognise the shapes, and do not reorganise one you inherit to match another: a layout record in the admin names each page template by its path, so keep every page template at the path its layout names.

Four shapes side by side

Four production repositories, counted by tracked files:

Large, TwigMedium, SmartyMedium, Smarty, gulpSmall, Smarty
Tracked filesabout 1,500about 700about 580about 290
templates/495392208101
Sourcesrc/ 427, TypeScript and SCSSsrc/ 250src/ 249src/ 129
Build outputdist/ 80dist/ 38static/ 108dist/ 52
Served as isassets/ 446assets/ 2, failover/ 10nonenone
Build configuration.build/webpack.*.jswebpack.*.js at the rootconfig/gulp.js with webpack insidewebpack.*.js at the root
Engine set bya tracked .settings.jsonthe defaultthe defaultthe default

The large repository serves several brands from one codebase, so it carries an assets/ folder of brand images and a stylesheet entry per brand. The medium one keeps a static failover page in the repository. The small one is a plain marketing site. None of them is wrong.

What is the same in all of them

  • templates/ is the largest or close to it, laid out by module, with page templates under templates/pages/pages/.
  • There is one base template that every page extends, and it links the built CSS and JavaScript.
  • The build output is committed, and the platform builds nothing.
  • There is no application code: What is not in it.

Reading a repository you have not met

  1. Find the engine. A .settings.json with {"Globals": {"template": {"engine": "Twig"}}}, or {% tags in the templates, means Twig; otherwise Smarty. Tell whether a site is Smarty or Twig in thirty seconds.
  2. Read package.json. Its scripts block tells you the build tool, the output folder and which commands exist: Webpack and gulp builds.
  3. Open the base template. Search templates/ for <html; it is usually templates/includes/…/base-template.html or templates/includes/base.html. Follow what it includes, which bundles it links, and where it prints scripts.
  4. Map layouts to templates. In the admin, each layout names its template. The layouts list tells you which files in templates/pages/pages/ are live and which are leftovers.
  5. Read .gitignore before you trust what is committed: Check what is ignored.
  6. Read the history of the build output (git log -- dist/): long gaps between source changes and output changes mean someone has been deploying from an unbuilt branch.