How to Achieve these 3 things?

Hello So I want to implement these 3 features in my workflow, but I came from writer background so no programming experience:

  1. how to add alias at the top of the note below the id because when I wanted to do it. It creates new Properties section below the #+TITLE: so I have 2 instead of 1 properties sections
    :proprties:
    #+title
    :proprties:

  2. How I can use tags in org roam like for example when I add #+roam_tags: :hi: nothing shows when I type it in the roam find. How to display filetag in roam find

  3. How to change the filename when I change #+title of the note I found some script that does it but the problem that it leaves an empty file with the old name
    This was the script:(I don’t use doom, so I removed the ! thing)

    (add-hook! 'after-save-hook
    (defun org-rename-to-new-title ()
    (when-let*
    ((old-file (buffer-file-name))
    (is-roam-file (org-roam-file-p old-file))
    (file-node (save-excursion
    (goto-char 1)
    (org-roam-node-at-point)))
    (slug (org-roam-node-slug file-node))
    (new-file (expand-file-name (concat slug “.org”)))
    (different-name? (not (string-equal old-file new-file))))
    (rename-buffer new-file)
    (rename-file old-file new-file)
    (set-visited-file-name new-file)
    (set-buffer-modified-p nil))))
    

Also, How I can add filetag to the original filename (filename_tags.org)

Sorry if my questions were stupid. Vibe Coding didn’t work this time :sweat_smile:

I am pasting a response to Claude Sonnet 4.6 below. I am not verifying any of this; please try and adjust.

These are good questions, not stupid at all. Let me go through each one.

1. Duplicate :PROPERTIES: drawer

This happens because you’re manually typing #+title: outside the drawer, while org-roam wants its properties (ID, aliases) inside the :PROPERTIES: drawer. The fix is to put aliases inside the same drawer as the ID:

:PROPERTIES:
:ID:       your-node-id-here
:ROAM_ALIASES: "My Alias" "Another Alias"
:END:
#+title: Your Note Title


The :PROPERTIES: drawer and #+title: are two different systems — drawers for node metadata, #+ keywords for file-level org settings. They coexist, they just shouldn’t be duplicated. If you’re getting a second drawer, you likely have one that org-roam created (with the ID) and then added aliases via a command that created a fresh one. The solution: use org-roam-alias-add (via M-x) instead of typing manually — it will put the alias in the correct existing drawer.

2. Tags not showing in org-roam-find

#+roam_tags: is the old v1 syntax. In org-roam v2, the correct keyword is:

#+filetags: :tag1:tag2:


Note the colon-wrapped format — that’s standard org-mode filetags syntax. After adding tags, you need to run M-x org-roam-db-sync to update the database. Then in org-roam-node-find, tags should appear next to the node title. If they still don’t show, check your org-roam-node-display-template — the default includes ${tags} but some configs override it.

3. The rename script leaving an empty file

The script you have is close but has a subtle issue: rename-buffer is being called before rename-file, which can cause Emacs to create a new empty buffer for the old filename in some situations. Here’s a corrected version:

(add-hook 'after-save-hook
  (defun org-rename-to-new-title ()
    (when-let*
        ((old-file (buffer-file-name))
         (is-roam-file (org-roam-file-p old-file))
         (file-node (save-excursion
                      (goto-char 1)
                      (org-roam-node-at-point)))
         (slug (org-roam-node-slug file-node))
         (new-file (expand-file-name (concat slug ".org")
                                     (file-name-directory old-file)))
         (different-name? (not (string-equal old-file new-file))))
      (rename-file old-file new-file t)
      (set-visited-file-name new-file t t)
      (org-roam-db-sync))))


Two key changes: the expand-file-name now includes (file-name-directory old-file) so it stays in the same directory rather than defaulting to wherever Emacs thinks home is, and set-visited-file-name with t t handles the buffer rename cleanly without leaving ghosts.

4. Including filetags in the filename

This is trickier because tags can contain characters that are invalid in filenames, and you have to decide which tags to include. A simple approach — append the first tag to the slug:

(defun org-rename-to-new-title ()
  (when-let*
      ((old-file (buffer-file-name))
       (is-roam-file (org-roam-file-p old-file))
       (file-node (save-excursion
                    (goto-char 1)
                    (org-roam-node-at-point)))
       (slug (org-roam-node-slug file-node))
       (tags (org-roam-node-tags file-node))
       (tag-suffix (if tags
                       (concat "_" (car tags))
                     ""))
       (new-file (expand-file-name
                  (concat slug tag-suffix ".org")
                  (file-name-directory old-file)))
       (different-name? (not (string-equal old-file new-file))))
    (rename-file old-file new-file t)
    (set-visited-file-name new-file t t)
    (org-roam-db-sync)))


One honest warning: auto-renaming on every save is aggressive. If your title changes mid-thought, the file renames constantly and org-roam’s link database can lag behind. You might want to bind it to a manual command instead — M-x org-rename-to-new-title when you’re done with a note — rather than running it on after-save-hook.

didin’t help. when it changes the filename it leaves empty file with the old name. I want to change #+title and also change filename to the new title WIHTOUT leaving empty file

(file+head "articles/${title}.org" "#+title: ${title}\n#+filetags: :article:\n")

when I run this command new properties section appear it doesn’t use the most top part so I have two properties section above and below #+title