willfaught/paige

Feature Request: Configuration To Open External Links in New Tab

allocgator opened this issue · 16 comments

Requesting feature for a configuration which opens external links in a new tab (from discussion #44).

So this would happen for any link anywhere on any page, including the menu, the article body, or the footer?

I'd like to better understand the need for this. Can you describe why/when this would be used?

zigmd commented

So this would happen for any link anywhere on any page, including the menu, the article body, or the footer?

Yes

I'd like to better understand the need for this. Can you describe why/when this would be used?

Let's say somebody adds an external profile like GitHub, StackOverflow, etc. When a visitor clicks the link which takes them there, they see a lot of things.

For instance on GitHub, there are pinned project, contributions, personal README, etc. And on StackOverflow there is frequently asked questions, answered questions, profile information, most recent votes, saved posts, etc. Some visitors may dive into that content and may not remember to come back to the personal blog, or how many clicks its going to take for them to get back to where they were on the personal blog.

External links like these have a lot of content to "hook" the visitor onto. Opening external links in a new tab is to ensure that the visitor has a way of getting back to the personal blog because there's less distraction, ads, etc. and it's more about the person.

External links like these have a lot of content to "hook" the visitor onto

It sounds like the need is only for "big" links like you described, is that right? Or is there a need to do this for any link, like a link to a definition on dictionary.com or a post on someone's personal blog?

zigmd commented

I think it's going to be easier to have a configuration flag which opens all external links in a new tab.

"Big" links are going to vary and tough to keep track of. IMO all external links are "big".

This is implemented in v0.67.0. Just published. See the new paige.external_link_new_tab site parameter.

Can you confirm it works for you?

zigmd commented

I'm not able to get it to work - I updated the theme and see

module patterns.se

go 1.21.0

require github.com/willfaught/paige v0.68.0 // indirect

in the go.mod file and added

[paige]
color = "#0d6efd" # Bootstrap primary color and theme color for Safari and Windows
external_link_new_tab = true # Open external links in new tabs
math = false # Enable math typesetting

at the bottom of the config file.

What is your base url and external link?

Also, what is the link syntax? Markdown or html?

zigmd commented

What is your base url and external link?

It's a website on a different domain. Navigation is from patterns.se to saurabh.sm and creativecommons.org and is happening in the footer. This is the repository URL.

Also, what is the link syntax? Markdown or html?

Markdown:

I've been delayed looking into this because I picked up a new feature right before the problem was reported. Will work on this afterward.

zigmd commented

Sure, thanks Will !

external_link_new_tab belongs under params.paige, but you have just paige. You want this:

[params.paige]
external_link_new_tab = true

@saurabh-mish Can you confirm that fixes the issue?

zigmd commented

Hi @willfaught

Yes it works !!

external_link_new_tab belongs under params.paige, but you have just paige.

Thanks a lot for pointing this out !!

[params.paige]
external_link_new_tab = true

Looks like this is not present is the README. Currently it looks like this

Looks like this is not present is the README. Currently it looks like this

That documents the configuration object shared by the site and pages:

There is a single parameter object with sensible defaults that can be overridden in site or page parameters:

In page front matter, it appears like this:

+++
[paige]
external_link_new_tab = true
+++

In site configuration, it appears like this:

[params.paige]
external_link_new_tab = true

@saurabh-mish I added a line to the readme that should clarify this: e4c6b38. Thanks for the feedback.