Alias does not work in my current setup

What I’m trying to do

Hi, i am using my templates with YAML and this is my set-up:

I use the alias function a lot, for example here:

When I try to search for the alias, as example in image 3 - it does not show up?

Seems like my template set-up is not working

Things I have tried

I tried replacing alias, with aliases and other notations such as alias: (paragraph) - value1 , (paragraph) - value2

Can someone help?

Since August last year it’s recommended and/or enforced to use these built-in properties in the plural.
A similar note of mine looks like this:

---
title: DNS spirál
foreignTitle: false
aliases:
  - DNA spiral
status: nopublish-formatted
tags: 
publish: false
dateCreated: 2022-12-14
dateModified: 2024-03-30T15:58
---

# DNS spirál

More text.

As you can see, the value of my aliases is multi-line, which can be enforced with the Linter community plugin:

  • Never mind the alias2 and 3 there, those were for some temporary workaround and I neglected to delete them.

But it’s not necessary to install and customize that plugin if you have set up working Templates (core plugin) or Templater (third party plugin) templates.

Mind you, the latter (Templater) is more easily customized and can have JavaScript functions incorporated. – See more in forum threads.

From your screenshots, something doesn’t look right and I actually don’t think your Properties/YAML are in fact, Properties/YAML :thinking: … (it really doesn’t look like it :no_mouth: )

I think you might have an empty line between the very first 3 dashes --- indicating the start of the YAML block in Source Mode… which would prevent the YAML block to be parsed, displayed and used as Properties… (meaning that, for Obsidian, at the moment and if you have indeed a rogue empty line at the top of your template/note, this is just some normal markdown content but not a frontmatter block with keys and values to query…)

Your template should look like this in Source Mode:

---
title: {{title}}
date: {{date:YYYY-MM-DD}}
tags:
aliases:
backlinks:
---

And yes, as Gino mentions, the alias key has been deprecated and an aliases key needs to be used instead :blush:. (See here)

Right, it’s not valid YAML. Otherwise it still should have worked (possibly, not sure whether alias can still be used).

The first three dashes of valid YAML must be on the very first line of the note. Then the YAML keys and values on each line, then three dashes again to close the YAML block.
That’s all there is to it.

I am not entirely sure how that now works either :thinking:
I still have an alias key in one of my test vaults… I mean, it appears as:

---
alias:
---

… in Source Mode … but it’s displayed as aliases in Properties (in Live Preview)

As long as it’s empty, the alias key seem to be considered as another distinct key in the vault but as soon as I add a value to the alias key from Properties in Live Preview, it seems to be merged with the aliases key :woman_shrugging: .

The opposite though doesn’t seem to have the same effect: adding a value to an alias key in YAML in Source Mode doesn’t merge the key with aliases

1 Like

Interesting.

In fact, when it’s done, the older, valid value for aliases is not counted or working anymore but it’s still there in source mode.

Best not to confuse anyone around here.
A general pointer about properties is that you can use any YAML key name such as didItakeouttheTrash, but for core properties such as aliases, cssclasses, tags to work as expected one needs to use the plural forms shown in the Docs.

1 Like

thanks everyone! something is wrong indeed. So i leave one line fr (no other text is there, see screenshot 1), otherwise, it immediately aligned into this “properties” thing (see screenshot 2)

One free line:

Screenshot 2:

Delete the empty line as well above your first ---.

  • Actually, the valid YAML must be in your template so that all files created with it come out correctly formatted.

Also, better to copy and paste your source mode content in the future. Use a code fence of 3 backticks to display your content:

```
some content you paste in 
```

now i have this:



Basic template v2

title: {{title}}
date: {{date:YYYY-MM-DD}}
tags: 
aliases: 
backlinks:
---

The template name doesn’t need to be added in the file:

---
title: {{title}}
date: {{date:YYYY-MM-DD}}
tags: 
aliases: 
backlinks:
---
  • Nothing must come above the first three dashes.

Sorry that is exactly how i had it (the fist line is the header)

---
title: {{title}}
date: {{date:YYYY-MM-DD}}
tags: 
aliases: 
backlinks:
---

title: {{title}}
date: {{date:YYYY-MM-DD}}
tags:
aliases:
backlinks:

Wait do I need to add these: ``` in my obsidian as well? I thought that is just for the forum here

Just for the forum. They are called code fences.

ok so if i have it like this it still does not work :

---
title: Untitled 7
date: 2024-03-31
tags: 
aliases: 
	- test7
backlinks:
---

List items for key values need two whitespaces before the dash, not four.

---
title: Untitled 7
date: 2024-03-31
tags: 
aliases: 
  - test7
backlinks:
---

something is still wrong:


---
title: Untitled 7
date: 2024-03-31
tags: 
aliases: 
  - test7
backlinks:
---

i also keep getting these straight lines:
![grafik|690x393](upload://cLohV8AW6b4zucDTIDCreKT0S3V.png)

Oh, sorry, I see you did generate the file.
The YAML is still not valid.

Is there an empty line above the first three dashes?

Yes it is! Because if i leave that, it gets formated into “properties” which i don’t like (see screenshot)

ok figured it out! Just need to change the appearance in the editor so its not seen as “properties” but rather in yaml

thanks so so much!!