Why the properties code i copied cannot show


just like this, it cannot show in read mode
and it cannot show in properties

They need to be placed at the start of a file, with the first line having three ---

Example:

---
title: A New Hope # This is a text property
year: 1977
favorite: true
cast: # This is a list property
  - Mark Hamill
  - Harrison Ford
  - Carrie Fisher
---

Do your files use the right format?

The screenshot below shows source mode in the left pane; reading view in the middle pane, and file properties in the lower part of the right pane.

If your files are already using this format, can you share a screenshot of a sample file taken in source mode?

Here is the source text of the file in screenshot. If you paste (and match style) that into a test file, it should display correctly.

---
title: A New Hope
year: 1977
favorite: false
cast: 
  - Mark Hamill
  - Harrison Ford
  - Carrie Fisher
---

==Make sure the opening three `---` are on the first line of the file.==

The screenshot below shows `source mode` in the left pane; `reading view` in the middle pane, and `file properties` in the lower part of the right pane. 

![](https://forum.obsidian.md/uploads/default/optimized/3X/8/6/86ba49d763ff28ce1244e2441f32f23881e611bb_2_1380x834.jpeg)

If your files are already using this format, can you share a screenshot of a sample file taken in `source mode`?

Here is the source text of the file in screenshot. If you paste (and match style) that into a test file, it should display correctly.
1 Like

you are right, the --- should be at the start of the file
but I got confused that I just copied the template from a youtuber and it works well there but not here, and when I add some code to the top, it canot show in the read mode


it just missing

the code

---
<%* 
let url = 'https://www.tianqi.com/shanghai/'
let res = await request({url: url,method: "GET"});
res = res.replace(/\s/g,'') 
r=/<ddclass="weather">[\s\S]*?<\/dd>/g
let data = r.exec(res)[0] 
r = /<span><b>(.*?)<\/b>(.*?)<\/span>/g
data = r.exec(data)
let weather='上海'+' '+data[1]+' '+data[2]
-%>
type: OKR
tags:
  - review/daily
date: <% tp.file.creation_date("YYYY-MM-DD-dddd") %>
weather: <% weather %>
Habit_1:
Habit_2:
Habit_3:
Habit_4:
---

sorry, I am new to obsidian, I want it to enhance my efficiency

1 Like

Good to hear it is now working for you. Already looking very impressive.

Enjoy :hugs::smiley::partying_face:

EDIT: I might have misunderstood. If it is not working yet, that’s because the text in your code is a template, which needs to be executed and made into a new note before the properties will display correctly. I will check it later when I am on a device running Obsidian. Someone else might give an explanation before I have time to get to Mac. Apologies if I have misunderstood at all.

In the hope this helps …

Templater needs to be installed, enabled, and configured.

  1. Make sure the cursor is on line one in the file
  2. Press CMD P to open the command palette
  3. Select Templater: Open Insert Template modal
  4. Insert the template that contains the code. In this example the template is called templater1. Users can name templates as they want

See the two images below.

steps

1 Like

whatever i succeed or not, thank you so much

What I have Done?

I followed the steps:

  1. enable templates and templater
  2. ctrl+p(cause I use windows)
  3. find the option**templater**:open insert template modal
  4. choose the template article Daily

the OUTCOME:

templates settings

templater settings

I am sure the two plugins have been enabled

so odd​:cry::cry:

Hi.

Below is the test vault I used. Perhaps this will help you to identify what is needed for Templater to work for you. :crossed_fingers:

3june.zip (87.7 KB)

It’s so strange, the one you gave me is OK, I must have some configuration errors, hahaha. Thank you very much.
By the way, I want to ask you, is there any useful accounting method? I want to record my daily consumption,
and I want to embed the todolist set in the previous day’s note in my note template. How can I do it?

What’s the odd part? It looks like it inserted and resolved correctly in your test, you just have the note in source mode.

Just make sure that you don’t confuse the core “Templates” plugin and its commands with the community “Templater” plugin and its commands. Doesn’t seem like you did in this case, but it’s a common pitfall.

If you want Templater to execute the code when you create your daily notes, make sure to enable “Trigger Templater on new file creation”.

I believe there is something amiss as the keys and values appear to be duplicated. A configuration issue? Templater triggered twice? (Or I might have misunderstood, of course.)

Ah, you’re right, thanks for pointing that out. However, it appears that there is a simple solution, because these properties also appear twice in the screenshot of the daily note template. So it’s appears to be a matter of correcting the template.

Looks like @Jackxmk applied the template on itself by accident.

1 Like

Hope you have been able to identify the configuration you need. Very happy to help.

Dataview is very good at collating data. Probably best to start a new thread with specific details of what you want to achieve and a sample of the data fields you want to track. Hopefully, someone will be able to help.

I don’t track tasks in Obsidian. Again, it is probably best to start a separate thread that other people on the forum will see and be able to respond to with their specialist knowledge. If you can give details of what you want and samples of the type of data you want to track, I am sure someone will be able to offer you help and advice.

Best.

I think you are right in that the duplication is coming from the template.

Didn’t know if that was down to how it has been written (by the OP) or if the mixing of TemplateS and TemplateR is somehow corrupting the individual template file.

I only use TemplateR and didn’t know how to advise the OP about using TemplateS at the same time. Useful to have extra input and advice. Much appreciated. :star_struck:

1 Like

The second set of properties is resolved by Templater, so it appears that @Jackxmk may have accidentally inserted the template into itself.

You’re welcome :slight_smile:

1 Like

Below is a small example of tracking daily exercise. To help with recording daily consumption, it would be useful to know what is being tracked and how the data is being recorded.

---
Run: 1h 55m
---

> [!info] Run Total
> ```dataview 
> TABLE WITHOUT ID 
> sum(filter(flat(rows.Run), (r) => typeof(r) = "duration" )) as "Total Time"
> WHERE Run
> GROUP BY true
> ```

```dataview
TABLE WITHOUT ID
link(file.link, dateformat(file.day, "ccc, dd MMM")) as Date, 
Run
FROM "daily"
WHERE Run
SORT Date DESC
```

thank you so much, you are the kindest person I have ever meet.:smiling_face_with_three_hearts::smiling_face_with_three_hearts:

1 Like

thank you so much, you are the kindest person I have ever meet.:nerd_face::nerd_face::smiling_face_with_three_hearts::smiling_face_with_three_hearts::star_struck::star_struck:

1 Like