Automate Copying and Pasting the Current Page Title and URL with Keyboard Maestro


An action I perform multiple times per day is adding web page links to my Obsidian daily notes. I keep track of everything interesting or useful I come across.

When I first started my daily notes habit, I would manually copy the URL from the browser, then switch back to Obsidian, then format the link in Markdown format, and if I wanted the full title of the web page, I would go back to the browser, look for the title, select it, copy it, switch back to Obsidian, then paste it in between the square brackets.

I quickly realized that this should be automated, and the first tool I reach for is Keyboard Maestro. It’s absolutely worth the $36. It’s by far the easiest and fastest way to automate this particular workflow without writing a single line of code.

Now, all I have to do is press ⌃⌥⌘L while a browser is in focus, and then ⌘-V in Obsidian, which Keyboard Maestro automatically puts in focus for me. The whole workflow takes less than 2 seconds, instead of 20 seconds.

Let’s say this happens 5 times per weekday. That’s 90 seconds (18x5) saved per day. Over a year, with 4 weeks of vacation, that’s 48 weeks x 5 days/week x 90 seconds/day = 6 hours saved!

In upcoming guides, I’ll show you how to automate this action using three other tools — Alfred, Raycast, and macOS Shortcuts — all of which require a script. Also, stay tuned for video versions of these tutorials. Subscribe to my brand new YouTube channel and my newsletter to be notified when they come out.

To keep this page light in size, the screenshots are low quality, but if you click on them, you’ll get the high-res image.

Here’s how easy it is to do this in Keyboard Maestro:

  1. Launch Keyboard Maestro
  2. ⌘-N to create a new Macro (or File -> New Macro)
  3. It should look like this: Keyboard Maestro New Macro
  4. In the right pane, replace “Untitled Macro” with a descriptive name like “Paste URL and title of current web page in Markdown”
  5. Click on the “New Trigger” green button and select “Hot Key Trigger”, which should be the first choice.
  6. Type in your desired hot key, such as ⌃⌥⌘L (control-option-command-L)
  7. Click on the “New Action” green button at the bottom of the right pane. You should now see an Actions pane on the left that you can search through: Keyboard Maestro New Action
  8. Search for “set clipboard”, then double-click on “Set Clipboard to Text”. You should end up with this: Keyboard Maestro Set Clipboard to Text
  9. Inside the text field, type [](), then with the cursor inside the square brackets, click on “Insert Token” above the top right of the text field, then choose “Front Browser”, then “Front Browser Document Title”. You can also directly type %FrontBrowserTitle%. This is Keyboard Maestro’s magic sauce. It comes with all kinds of variables out of the box that can fetch data for you without having to write scripts. Keyboard Maestro Insert Token
  10. Place the cursor inside the parentheses, and this time either type %FrontBrowserURL%, or select “Front Browser -> Front Browser Document URL” via the Insert Token dropdown. You should end up with this: Keyboard Maestro Front Browser Document URL token
  11. In the Actions pane, delete the search text “set clipboard”, and search for “activate”, then double-click on “Activate a Specific Application”. It will default to “Finder”.
  12. Click on the “Activate:” dropdown, and select your desired app where you keep your links. You should end up with something like this: Keyboard Maestro activate application

That’s it! Click the “Edit” button under the right pane to get out of Edit mode, and give your hot key a try. Make sure you have a browser in focus before you press your keyboard shortcut.

Important Notes

This should work in all Chromium and WebKit browsers, but not in Firefox. Firefox doesn’t play nice with automation tools 😢. If the page title is missing when you paste from the clipboard, you’ll need to allow JavaScript from Apple Events. Here’s how:

In Safari

From the menu bar, go to Develop -> Allow JavaScript from Apple Events

If you don’t have the “Develop” menu in Safari’s menu bar, go to Safari’s preferences, then the Advanced tab, then click on “Show Develop menu in menu bar”.

In Chrome

Go to View -> Developer -> Allow JavaScript from Apple Events

In Microsoft Edge

Go to Tools -> Developer -> Allow JavaScript from Apple Events