How do I write this redirect with a #?

I’m trying to redirect from a tag to a custom directory page:

/#industry-insights/ to /industry-insights/

In the redirects.yaml page, I tried the following but it’s not working

/#industry-insights/: ^/industry-insights/$

How can I get this to work?

1 Like

Browsers don’t send the hash when making a request -

https://example.com/about#our-team would be requested as https://example.com/about.

Can you clarify this statement? Internal tags (tags that start with #) do not have a tag page.

1 Like

Is this question about Ghost? Because it’s not possible to access a tag page with a # in it.

1 Like

Yeah it’s about Ghost. Using this theme, open to any solution to redirect a tag name that shows up as a filter.

1 Like

Paging @brightthemes !

1 Like

So what’s going on there is that there’s just one page, at /. And then there’s some javascript reading the #tagname and filtering what posts show up. If you can edit the theme files, it’ll be an easy change to make. Skip the javascript and just link directly to /tag/whatevertagname .

1 Like

Yes, @Cathy_Sarisky is right, the links are all pointing to the homepage with a different hash, so redirect is not the solution. As was suggested you can edit the theme files to replace #{{slug}} with /tag/{{slug}}.

Alternatively you can add the following in your code injection > site footer:

<script>document.querySelectorAll('.resources-filter a')?.forEach(filter => filter.setAttribute('href', filter.getAttribute('href').replace('#', '/tag/')))</script>

If you need further help you can contact me here: Contact | Bright Themes

2 Likes

Got it! The code injection worked great to get /tag/{{slug}}. I’m now trying to redirect from: /tag/industry-insights to /industry-insights/

This is what I have in the redirects.yaml: /tag/industry-insights/: ^/industry-insights/$ but it’s not redirecting correctly.

Any thoughts here? It’ll just go to the original tag page and say 404.

EDIT: got it to work! Linked directly to the web URL instead.

1 Like

You shouldn’t use redirects for that, that is defined in the routes.yaml file.
More details here:

2 Likes

Hm interesting, took a look through the documentation but still a bit confused… How would I write it in the routes.yaml?

By changing the taxonomies permalink, you can remove the hardcoded prefix tag and leave the {slug} only or add your own prefix.