Skip to content

Naming is Hard

"There are only two hard things in Computer Science: cache invalidation and naming things."
— Phil Karlton

In our Theme/[ThemeName]/Assets/Lava we have/had about 50-100 files all w different naming conventions, kebab case, snake case, w no directory type for blocks or components, just everything dumped in, and named ... uniquely. It didn't work; Tough to read,

Naming Convention

Lets start w our convention strategy

Naming ConventionDescriptionExampleUsage Context
kebab-caseWords separated by hyphens, all lowercasemy-variable-nameURLs, CSS classes, file names

Naming Framework

Easy and Intuitive mental model / schema but also leaves room for future proofing!

Start w the end in mind

Here is what we are after File path pattern example:
<directory>/<namespace>/<file name>Example:
blocks/connect/tabs-es.lava

Here is an exception/gotcha:

  • Namespace is an optional subfolder used to group related files within a directory.
  • If no namespace is needed, files live directly inside <directory>/.
  • Example: blocks/connect/tabs-es.lava (namespace = connect).

Perspective

Same ideas organized as a table:

DirectoryNamespace (Subfolder)Use CaseExample File Path
blocks/Optional: groups related blocksFull UI blocks used in a single zoneblocks/connect/tabs-es.lava
components/Optional: groups related componentsReusable layout/content units (cards, filters)components/card-grid.lava
layouts/Rarely usedLayout scaffolding shared across pageslayouts/page-header-with-bg.lava
partials/Optional: groups related partialsSmall reusable markup bits (includes)partials/latest-messages-es.lava
pages/Optional: groups page templatesFull page templatespages/signup-finder-results.lava

Question

Is there something I am missing? How might this be done better?! Like, how do you want to do version control?

Share your feedback

Explore and learn. Released under the MIT License.