Zettelkasten Forum


Should I put hyphens instead of spaces in my filenames?

Hey everyone,

I just started my first Zettelkasten using Obsidian. I saw a lot of people naming their notes like this:

YYYYMMDDHHMM-this-is-the-title.md

I’d prefer using this form:

YYYYMMDDHHMM this is the title.md

Is there any technical reason for not using spaces and instead using hyphens or something similar?

I hope this topic was not yet covered anywhere, I couldn’t find any threads via the search function.

Thanks

Pogo

Comments

  • The main reason I do this (and maybe others) is that if you write scripts to do things automatically, it makes it a lot easier if the filename does not contain spaces, because many scripting languages treat two pieces of text separated by a space as two different words or commands.

    You can get around this by putting the filename in quotes, like this
    "YYYYMMDDHHMM this is the title.md"
    but I find it easier to just make sure all filenames do not have spaces.

  • Yeah, I'll echo @Jeremy's point. I landed on lowercase-joined-by-hypens (sometimes known as "kebab case") a while back because it simplifies working with the shell, standard Unix tools, and vim's concept of a "word".

    On that last note, I've had the following in my .vimrc for years:

      " include '-' in words.  counts for both movement commands and autocomplete.
      " to test, try moving across and autocompleting for some-words-bunched-up
      " this is an experiment - mainly i want to use inline dashes in identifiers
      " in markdown documents, and so forth
      set iskeyword+=-
    

    In general, if the tooling were better, this wouldn't really matter, but as it stands I've found that whitespace in filenames is usually more trouble than it's worth.

  • But isn’t it so much more work for you on a daily basis to put all these hyphens in the filenames? You have to write the title twice, once in the filename and also put hyphens in there and then again write it in the title section of your note. Without the hyphens you can just copy and paste the title from the filename into the title section of the note.
    Or do you have any other workflow which simplifies this? For now it seems to me that the extra trouble you have in writing the title twice for every note isn’t worth it. Especially if you can work around spaces in filenames when using scripts. Shouldn’t I be writing new notes a lot more often than I would be writing different scripts?

  • There are a couple of answers to this. One is an Automator action (if you are on a Mac) that instantly makes filenames web friendly. I access that with a right-click on the filename.

    The other is manual; when I create a new note, I type the name once in the Omnibar with hyphens and then use copy title before parting it along with my standard front matter into the body of the note.

Sign In or Register to comment.