|
| 1 | +--- |
| 2 | +layout: default |
| 3 | +title: How to style backlinks |
| 4 | +nav_order: 2 |
| 5 | +parent: How Tos |
| 6 | +--- |
| 7 | + |
| 8 | +# How to style backlinks |
| 9 | + |
| 10 | +{: .no_toc } |
| 11 | + |
| 12 | +<details open markdown="block"> |
| 13 | + <summary> |
| 14 | + Table of contents |
| 15 | + </summary> |
| 16 | + {: .text-delta } |
| 17 | +1. TOC |
| 18 | +{:toc} |
| 19 | +</details> |
| 20 | + |
| 21 | +--- |
| 22 | + |
| 23 | +## Motivation and assumptions |
| 24 | + |
| 25 | +In Tasks results, by default each task is displayed with its filename, |
| 26 | +and the name of the previous heading, for example `(ACME > Steps to world domination)`. |
| 27 | +This is called a **backlink**. |
| 28 | + |
| 29 | +If you don't like how backlinks look, this guide shows how you can modify their appearance. |
| 30 | + |
| 31 | +We assume that you know how to [use CSS snippets in Obsidian](https://help.obsidian.md/How+to/Add+custom+styles#Use+Themes+and+or+CSS+snippets). |
| 32 | + |
| 33 | +## Default backlink style |
| 34 | + |
| 35 | +Here is an example task block that does not hide any components of the output: sometimes you want to see all the information in each task. |
| 36 | + |
| 37 | + ```tasks |
| 38 | + not done |
| 39 | + description includes trash |
| 40 | + ``` |
| 41 | + |
| 42 | +This screenshot shows what this might look like, with some sample data: |
| 43 | + |
| 44 | + |
| 45 | + |
| 46 | +Notice that the backlinks (the blue file and heading names) can quite dominate the results, visually. |
| 47 | + |
| 48 | +## Built-in options |
| 49 | + |
| 50 | +We could use `hide backlink`, but then we would lose the ability to navigate to the source file. |
| 51 | + |
| 52 | +We could also use `short mode`, which would replace the backlink text with an icon, but this would hide all the other properties of the task, such as due date and recurrence. |
| 53 | + |
| 54 | +## Using CSS to de-emphasize the backlinks |
| 55 | + |
| 56 | +We can de-emphasize the text in the backlinks, with [this CSS snippet](https://github.com/obsidian-tasks-group/obsidian-tasks/blob/gh-pages/resources/sample_vaults/Tasks-Demo/.obsidian/snippets/tasks-plugin-backlinks-small-grey.css): |
| 57 | + |
| 58 | +```css |
| 59 | +/* By David Phillips (autonia) https://github.com/autonia |
| 60 | + From https://github.com/obsidian-tasks-group/obsidian-tasks/discussions/622#discussioncomment-2649299 |
| 61 | +*/ |
| 62 | +.tasks-backlink { |
| 63 | + font-size: 0.7em; |
| 64 | + opacity: 0.6; |
| 65 | + filter: grayscale(60%); |
| 66 | +} |
| 67 | +``` |
| 68 | + |
| 69 | +Which gives us this result: |
| 70 | + |
| 71 | + |
| 72 | + |
| 73 | +## Using CSS to replace the backlinks with icons |
| 74 | + |
| 75 | +Or we can replace the backlink text with an icon, with [this CSS snippet](https://github.com/obsidian-tasks-group/obsidian-tasks/blob/gh-pages/resources/sample_vaults/Tasks-Demo/.obsidian/snippets/tasks-plugin-backlinks-icon.css): |
| 76 | + |
| 77 | +```css |
| 78 | +/* By Anna Kornfeld Simpson (@AnnaKornfeldSimpson) https://github.com/AnnaKornfeldSimpson |
| 79 | + From https://github.com/obsidian-tasks-group/obsidian-tasks/discussions/834#discussioncomment-3028600 |
| 80 | +
|
| 81 | + Then converted to embed the icon inside this .css file, to remove the need |
| 82 | + for an internet connection, as follows: |
| 83 | + 1. Link icon downloaded from https://twemoji.twitter.com |
| 84 | + https://github.com/twitter/twemoji/blob/master/assets/svg/1f517.svg |
| 85 | + licensed under the CC-BY 4.0 |
| 86 | + 2. SVG encoded for embedding here with https://yoksel.github.io/url-encoder/ |
| 87 | +*/ |
| 88 | +li.plugin-tasks-list-item > span.tasks-backlink > a { |
| 89 | + content: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 36 36'%3E%3Cpath fill='%238899A6' d='M15 9l6-6s6-6 12 0 0 12 0 12l-8 8s-6 6-12 0c-1.125-1.125-1.822-2.62-1.822-2.62l3.353-3.348S14.396 18.396 16 20c0 0 3 3 6 0l8-8s3-3 0-6-6 0-6 0l-3.729 3.729s-1.854-1.521-5.646-.354L15 9z'/%3E%3Cpath fill='%238899A6' d='M20.845 27l-6 6s-6 6-12 0 0-12 0-12l8-8s6-6 12 0c1.125 1.125 1.822 2.62 1.822 2.62l-3.354 3.349s.135-1.365-1.469-2.969c0 0-3-3-6 0l-8 8s-3 3 0 6 6 0 6 0l3.729-3.729s1.854 1.521 5.646.354l-.374.375z'/%3E%3C/svg%3E"); |
| 90 | + height: .9em; |
| 91 | +} |
| 92 | +``` |
| 93 | + |
| 94 | +Which gives us this result: |
| 95 | + |
| 96 | + |
0 commit comments