# Styling anchors in email digest

**URL:** https://meta.discourse.org/t/styling-anchors-in-email-digest/38344
**Category:** Support
**Tags:** activity-summary
**Created:** [Janvier 22, 2016, 3:35 UTC](https://meta.discourse.org/t/styling-anchors-in-email-digest/38344 "2016-01-22T15:35:23Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![joebuhlig](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/joebuhlig/32/193054_2.png) [@joebuhlig](https://meta.discourse.org/u/joebuhlig)
#### Post date: [Janvier 22, 2016, 3:35 UTC](https://meta.discourse.org/t/styling-anchors-in-email-digest/38344/1 "2016-01-22T15:35:23Z")

</div>

Continuing the discussion from [Styling email digest](https://meta.discourse.org/t/styling-email-digest/13061):

I did a lot of searching and came up lacking. Is there a way to alter the styling of the email digests? The only thing I’m interested in changing is the anchor text. I’d like it to match the rest of my site’s branding. I couldn’t find a way to do it through the Customize feature, but I may not be thinking about it right. Thanks.

---

<div class="post-metadata">

### Author: ![simon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon/32/339122_2.png) [@simon](https://meta.discourse.org/u/simon)
#### Post date: [Janvier 22, 2016, 8:33 UTC](https://meta.discourse.org/t/styling-anchors-in-email-digest/38344/2 "2016-01-22T20:33:33Z")

</div>

There might be better ways, but you can add styles to emails in a plugin by calling `Email::Styles.register_plugin_style` and passing it a block that acts on the email (the email is a Nokogiri document at this point).

This will make the links red and bold. The problem is that it will make **all** the links red and bold. To target just the ones you want will take a bit of fiddling around.

```rb
# name: email-styles
# version: 0.1

after_initialize do
  require_dependency 'email/styles'
  Email::Styles.register_plugin_style do |doc|
    doc.css('a').each do |element|
      element['style'] = "color:red; font-weight:bold;"
    end
  end
end

```

You’ll need to restart Sidekiq to see the change.

---

<div class="post-metadata">

### Author: ![joebuhlig](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/joebuhlig/32/193054_2.png) [@joebuhlig](https://meta.discourse.org/u/joebuhlig)
#### Post date: [Janvier 22, 2016, 9:15 UTC](https://meta.discourse.org/t/styling-anchors-in-email-digest/38344/3 "2016-01-22T21:15:29Z")

</div>

Good to know. I may do that. Seems a bit difficult to require a plugin for styling.

---

<div class="post-metadata">

### Author: ![simon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon/32/339122_2.png) [@simon](https://meta.discourse.org/u/simon)
#### Post date: [Janvier 22, 2016, 10:05 UTC](https://meta.discourse.org/t/styling-anchors-in-email-digest/38344/4 "2016-01-22T22:05:06Z")

</div>

Yes it does. Maybe things could be changed in the Discourse code so that values from the site’s color scheme are passed to `Email::Styles` as options.

For example adding:  
`cta_color: ColorScheme.hex_for_name('tertiary')` to email\_opts in `user_notifications.rb` makes it possible to set the call-to-action button background color to `@opts[:cta_color]`

---

<div class="post-metadata">

### Author: ![joebuhlig](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/joebuhlig/32/193054_2.png) [@joebuhlig](https://meta.discourse.org/u/joebuhlig)
#### Post date: [Janvier 22, 2016, 10:24 UTC](https://meta.discourse.org/t/styling-anchors-in-email-digest/38344/5 "2016-01-22T22:24:35Z")

</div>

Might make sense for either a PR or a plugin to pull the customizations into the emails.

---

<div class="post-metadata">

### Author: ![joebuhlig](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/joebuhlig/32/193054_2.png) [@joebuhlig](https://meta.discourse.org/u/joebuhlig)
#### Post date: [Janvier 25, 2016, 1:32 UTC](https://meta.discourse.org/t/styling-anchors-in-email-digest/38344/6 "2016-01-25T13:32:47Z")

</div>

Before I start looking for time to do this, does anyone know if this is on the roadmap or if there’s a desired method for how this is done in the future?

---

<div class="post-metadata">

### Author: ![joebuhlig](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/joebuhlig/32/193054_2.png) [@joebuhlig](https://meta.discourse.org/u/joebuhlig)
#### Post date: [Février 12, 2016, 6:41 UTC](https://meta.discourse.org/t/styling-anchors-in-email-digest/38344/9 "2016-02-12T18:41:44Z")

</div>

I went ahead and put together a PR for this.

> <https://github.com/discourse/discourse/pull/4008>
>
> This PR adds the tertiary color for the site to the user digest email. It adds a… new variable to the digest method of user\_notifications.rb for the anchor color and uses that to create inline styling within the email.

---

<div class="post-metadata">

### Author: ![joebuhlig](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/joebuhlig/32/193054_2.png) [@joebuhlig](https://meta.discourse.org/u/joebuhlig)
#### Post date: [Février 16, 2016, 5:06 UTC](https://meta.discourse.org/t/styling-anchors-in-email-digest/38344/10 "2016-02-16T17:06:24Z")

</div>

Just let me know what you need from me on this. I’d love to see this make it into core.

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [Décembre 19, 2018, 11:42 UTC](https://meta.discourse.org/t/styling-anchors-in-email-digest/38344/11 "2018-12-19T23:42:16Z")

</div>



---

<div class="post-metadata">

### Author: ![simon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon/32/339122_2.png) [@simon](https://meta.discourse.org/u/simon)
#### Post date: [Décembre 19, 2018, 11:56 UTC](https://meta.discourse.org/t/styling-anchors-in-email-digest/38344/12 "2018-12-19T23:56:13Z")

</div>

Anchor text in the digest now uses the site’s color theme.

---

<div class="post-metadata">

### Author: ![simon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon/32/339122_2.png) [@simon](https://meta.discourse.org/u/simon)
#### Post date: [Décembre 19, 2018, 11:56 UTC](https://meta.discourse.org/t/styling-anchors-in-email-digest/38344/13 "2018-12-19T23:56:18Z")

</div>


