You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

105 lines
3.3 KiB

4 years ago
  1. +++
  2. title = "External"
  3. description = "Create links with external icon and custom behavior."
  4. categories = ["navigation"]
  5. tags = ["links", "security", "privacy"]
  6. html_attributes = ["href", "class", "referrerpolicy", "target", "type", "rel"]
  7. custom_attributes = ["text", "trusted"]
  8. snippets_used = ["external", "button", "alert"]
  9. [[copyright]]
  10. owner = "Josh Habdas"
  11. date = "2019"
  12. license = "agpl-3.0-or-later"
  13. +++
  14. Basic usage:
  15. ```html
  16. {{</* external href="https://after-dark.habd.as" text="After Dark" /*/>}}
  17. {{</* external href="https://after-dark.habd.as" /*/>}}
  18. ```
  19. {{< external href="https://after-dark.habd.as" text="After Dark" />}}
  20. {{< external href="https://after-dark.habd.as" />}}
  21. Shorthand usage:
  22. ```term
  23. {{</* external "https://after-dark.habd.as" "After Dark" /*/>}}
  24. {{</* external href="https://go.habd.as/after-dark" /*/>}}
  25. {{</* external "wss://fs1.habd.as:80" /*/>}}
  26. ```
  27. {{< external "https://after-dark.habd.as" "After Dark" />}}
  28. {{< external href="https://go.habd.as/after-dark" />}}
  29. {{< external "wss://fs1.habd.as:80" />}}
  30. {{< hackcss-alert type="info" >}}
  31. <strong>Note:</strong> URIs such as those using the <code>wss</code> scheme may be considered unsafe by the {{< external "https://golang.org/pkg/html/template/" "Go template package" />}}. Learn more in the package {{< external "https://golang.org/pkg/html/template/#hdr-Security_Model" "Security Model" />}}.
  32. {{< /hackcss-alert >}}
  33. With a trusted URL:
  34. ```html
  35. {{</* external trusted="true" href="wss://fs1.habd.as:80" /*/>}}
  36. {{</* external trusted="true" href="irc://chat.freenode.net:6667/after-dark" /*/>}}
  37. ```
  38. {{< external trusted="true" href="wss://fs1.habd.as:80" />}}
  39. {{< external trusted="true" href="irc://chat.freenode.net:6667/after-dark" />}}
  40. With external link styling removed:
  41. ```html
  42. {{</* external rel="noopener" href="https://blog.domain.example" /*/>}}
  43. ```
  44. {{< external rel="noopener" href="https://blog.domain.example" />}}
  45. With internal link opening in a new window:
  46. ```html
  47. {{</* external href="/404.html" text="Error Page" /*/>}}
  48. ```
  49. {{< external href="/404.html" text="Error Page" />}}
  50. With structured data type:
  51. ```html
  52. {{</* external itemtype="significantLink" href="https://habd.as" /*/>}}
  53. ```
  54. {{< external itemtype="significantLink" href="https://habd.as" />}}
  55. With site-wide [Referrer Policy](/feature/referrer-policy) overridden:
  56. ```html
  57. {{</* external referrerpolicy="unsafe-url" href="http://goo.gl" /*/>}}
  58. ```
  59. {{< external referrerpolicy="unsafe-url" href="http://goo.gl" />}}
  60. With markdown image and link styling removed:
  61. ```markdown
  62. {{%/* external rel="next" href="https://source.unsplash.com/collection/983219/2160x1440" %}}
  63. ![Example image](https://source.unsplash.com/collection/983219/1080x720 "View Random Image Enlarged")
  64. {{% /external */%}}
  65. ```
  66. {{% external rel="next" href="https://source.unsplash.com/collection/983219/1080x720" %}}
  67. ![Example image](https://source.unsplash.com/collection/983219/1080x720 "View Random Image Enlarged")
  68. {{% /external %}}
  69. With interactive [Button](../button) to run a [Fuzzy Search](/feature/fuzzy-search):
  70. ```html
  71. {{</* external rel="search" target="_self" href="/search/?s=button" >}}
  72. {{< hackcss-button type="primary" text="Search" />}}
  73. {{< /external */>}}
  74. ```
  75. {{< external rel="search" target="_self" href="/search/?s=button" >}}
  76. {{< hackcss-button type="primary" text="Search" />}}
  77. {{< /external >}}