In Obsidian, customizing the appearance of links in the editing view requires creating and applying a custom CSS snippet. By default, links like [2024-10-07](2024-10-07.md) may be styled as external links because Obsidian doesn't inherently recognize them as internal links unless they follow specific patterns or configurations. To make these .md file links appear the same as internal links in the editor, follow the steps below:
1. Enable Custom CSS in Obsidian
Before you can add custom styles, ensure that Obsidian allows the use of custom CSS snippets.
-
Open Settings:
- Click on the gear icon in the bottom left corner of Obsidian or press
Ctrl + , (Windows/Linux) or Cmd + , (Mac).
-
Navigate to Appearance:
- In the settings sidebar, select Appearance.
-
Enable Custom CSS:
- Ensure that the CSS snippets option is enabled. If you're using a newer version of Obsidian, this might already be active.
2. Create a Custom CSS Snippet
You'll need to create a CSS file that Obsidian can use to apply your custom styles.
-
Open the Snippets Folder:
- In the Appearance settings, scroll down to the CSS snippets section.
- Click the folder icon to open the snippets directory (
.obsidian/snippets) in your file explorer.
-
Create a New CSS File:
- Inside the snippets folder, create a new file named, for example,
internal-links-editor.css.
-
Edit the CSS File:
- Open
internal-links-editor.css in your preferred text editor and add the following CSS code:
/* Style internal .md links in the editor to match internal link styling */
.cm-s-obsidian span.cm-link[href$=".md"] {
color: var(--text-link) !important; /* Matches the internal link color */
text-decoration: underline !important; /* Optional: underline to mimic internal links */
/* You can add more styles here if needed */
}
Explanation of the CSS:
.cm-s-obsidian: Targets the Obsidian-specific CodeMirror (the editor component) styling.
span.cm-link[href$=".md"]: Selects all link spans where the href attribute ends with .md.
color: var(--text-link): Applies the standard internal link color defined by Obsidian.
text-decoration: underline: Ensures the links are underlined, similar to typical internal links. Adjust or remove as desired.
!important: Ensures that these styles override any existing styles.
-
Save the CSS File:
- After adding the CSS, save the file.
3. Apply the CSS Snippet in Obsidian
-
Return to Obsidian:
- Go back to the Obsidian app.
-
Enable the Snippet:
- In Settings > Appearance > CSS snippets, you should see
internal-links-editor.css listed.
- Toggle the switch next to it to enable the snippet.
-
Reload Obsidian (If Necessary):
- Sometimes, Obsidian requires a reload to apply new CSS changes. You can reload by pressing
Ctrl + R (Windows/Linux) or Cmd + R (Mac).
- Alternatively, close and reopen Obsidian.
4. Verify the Changes
-
Open a Markdown File:
- Navigate to a markdown file that contains links like
[2024-10-07](2024-10-07.md).
-
Check the Editing View:
- Enter Edit mode (if not already in it).
- The
.md links should now appear with the same color and styling as internal links.
Additional Customizations
-
Adjusting Styles:
If you want to further customize the appearance, such as changing the underline style or adding hover effects, you can modify the CSS accordingly. For example:
.cm-s-obsidian span.cm-link[href$=".md"] {
color: var(--text-link) !important;
text-decoration: underline dotted !important;
}
.cm-s-obsidian span.cm-link[href$=".md"]:hover {
color: var(--text-accent) !important;
}
-
Handling Different Link Structures:
If your links have different structures or additional patterns, you might need to adjust the CSS selectors to accommodate those cases.
Troubleshooting
By following these steps, you can ensure that your .md links in Obsidian's editing view are styled consistently with internal links, enhancing readability and maintaining a cohesive appearance across your notes.