# Reload page body when clicking a link in a custom header

**URL:** https://meta.discourse.org/t/reload-page-body-when-clicking-a-link-in-a-custom-header/90543
**Category:** Support
**Created:** [23 juni 2018 om 11:47 UTC](https://meta.discourse.org/t/reload-page-body-when-clicking-a-link-in-a-custom-header/90543 "2018-06-23T11:47:00Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![Canapin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/canapin/32/119591_2.png) [@Canapin](https://meta.discourse.org/u/Canapin)
#### Post date: [23 juni 2018 om 11:47 UTC](https://meta.discourse.org/t/reload-page-body-when-clicking-a-link-in-a-custom-header/90543/1 "2018-06-23T11:47:00Z")

</div>

Hi.  
Like many people, I’ve set up a custom header on top on my Discourse forum:

 ![image](https://global.discourse-cdn.com/meta/original/3X/7/1/7119dfb29450d87b762d562586eda51bbba8ebb8.png)

I wanted my top menu identical to my Wordpress site (I use WP-Discourse), this is why I kept the “Forum” menu item.

I would like this link to reload the forum body when clicked on, exactly when we click on the logo from the regular discourse header bar.

How can I achieve this?

---

<div class="post-metadata">

### Author: ![Johani](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/johani/32/176920_2.png) [@Johani](https://meta.discourse.org/u/Johani)
#### Post date: [23 juni 2018 om 11:52 UTC](https://meta.discourse.org/t/reload-page-body-when-clicking-a-link-in-a-custom-header/90543/2 "2018-06-23T11:52:15Z")

</div>

Do you mean reload as in cause the whole page to reload - reload the entire app - or do you just want the link to take you to the homepage within the app?

---

<div class="post-metadata">

### Author: ![Canapin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/canapin/32/119591_2.png) [@Canapin](https://meta.discourse.org/u/Canapin)
#### Post date: [23 juni 2018 om 12:04 UTC](https://meta.discourse.org/t/reload-page-body-when-clicking-a-link-in-a-custom-header/90543/3 "2018-06-23T12:04:08Z")

</div>

> [@Johani](#):
>
> or do you just want the link to take you to the homepage within the app?

This 🙂

---

<div class="post-metadata">

### Author: ![Johani](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/johani/32/176920_2.png) [@Johani](https://meta.discourse.org/u/Johani)
#### Post date: [23 juni 2018 om 12:06 UTC](https://meta.discourse.org/t/reload-page-body-when-clicking-a-link-in-a-custom-header/90543/4 "2018-06-23T12:06:04Z")

</div>

Try setting the `href` of the link to `"/"` Like so:

`<a href="/">FORUM</a>`

---

<div class="post-metadata">

### Author: ![Canapin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/canapin/32/119591_2.png) [@Canapin](https://meta.discourse.org/u/Canapin)
#### Post date: [23 juni 2018 om 12:07 UTC](https://meta.discourse.org/t/reload-page-body-when-clicking-a-link-in-a-custom-header/90543/5 "2018-06-23T12:07:33Z")

</div>

Hi, I already tried that as well as adding `data-auto-route="true"` with no success.

---

<div class="post-metadata">

### Author: ![Johani](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/johani/32/176920_2.png) [@Johani](https://meta.discourse.org/u/Johani)
#### Post date: [23 juni 2018 om 12:19 UTC](https://meta.discourse.org/t/reload-page-body-when-clicking-a-link-in-a-custom-header/90543/6 "2018-06-23T12:19:01Z")

</div>

Try something like this:

```plaintext
<a href="/" class="home-link">FORUM</a>

<script type="text/discourse-plugin" version="0.8.20">
$(function() {
  $("a.home-link").click(function() {
    require("discourse/lib/url").default.routeTo(
      $(event.currentTarget).attr("href")
    );
    return false;
  });
});
</script>

```

Where you give your link the classname `home-link` and run a tiny script when it’s clicked to force it to load within the app.

---

<div class="post-metadata">

### Author: ![Canapin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/canapin/32/119591_2.png) [@Canapin](https://meta.discourse.org/u/Canapin)
#### Post date: [23 juni 2018 om 15:36 UTC](https://meta.discourse.org/t/reload-page-body-when-clicking-a-link-in-a-custom-header/90543/7 "2018-06-23T15:36:44Z")

</div>

Hi, thanks for your reply.  
It doesn’t work, and here’s the output code on the page source:

```html
<script>Discourse._registerPluginCode('0.8.20', function (api) {

  $(function () {
    $("a.home-link").click(function () {
      console.log("test");
      require("discourse/lib/url").default.routeTo($(event.currentTarget).attr("href"));
      return false;
    });
  });
});</script>

```

---

<div class="post-metadata">

### Author: ![Johani](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/johani/32/176920_2.png) [@Johani](https://meta.discourse.org/u/Johani)
#### Post date: [23 juni 2018 om 15:44 UTC](https://meta.discourse.org/t/reload-page-body-when-clicking-a-link-in-a-custom-header/90543/8 "2018-06-23T15:44:29Z")

</div>

I’m not sure what’s going on on your side, but I’m positive that that would work. Here’s a basic live example on theme creator:

[https://theme-creator.discourse.org/theme/Johani/forum-link](https://theme-creator.discourse.org/theme/Johani/forum-link)

---

<div class="post-metadata">

### Author: ![Canapin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/canapin/32/119591_2.png) [@Canapin](https://meta.discourse.org/u/Canapin)
#### Post date: [23 juni 2018 om 15:49 UTC](https://meta.discourse.org/t/reload-page-body-when-clicking-a-link-in-a-custom-header/90543/9 "2018-06-23T15:49:03Z")

</div>

Hi, I’ not sure what I did before but it is indeed working. Thank you very much!

---

<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: [23 juli 2018 om 15:49 UTC](https://meta.discourse.org/t/reload-page-body-when-clicking-a-link-in-a-custom-header/90543/10 "2018-07-23T15:49:07Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
