Skip to content

Override pathPrefix, skip HtmlBasePlugin, ignore baseHref, for one specific link. #3699

@nycki93

Description

@nycki93

Is your feature request related to a problem? Please describe.

I want to write a sub-section of my site with 11ty, but not the root site. Almost all of my links are going to stay within the sub-section, so it makes sense to use HtmlBasePlugin to transform them all. So when I want to go back to the top of the subsection, I write:

[back to top](/)

so far so good. However, what if I want one link to my actual for-real home page? I can't use / because that will be transformed. I tried opting out:

[home]({{ '/' | htmlBaseUrl('') }})

but this doesn't work; I think it's applying htmlBaseUrl a second time after the html is generated. Is there some sort of "marker" I can put on this link to say "okay htmlBaseUrl, this one is a for-real home link"?

Describe the solution you'd like

I want this code to be re-usable, so I don't want to specify an absolute url. I'd be happy with something like this:

[home](//)

or this:

[home](<root>/)

in other words, I think that htmlBaseUrl("//", "/pathprefix/") should return /, ignoring the path prefix just like it does for absolute urls.

Describe alternatives you've considered

Option 1: use an absolute url. The problem with this is that it makes the code less portable. I can't move the site or host it on multiple domains as easily, and I was hoping to hand this to a friend as a "zero-config" setup later.

Option 2: remove HtmlBasePlugin and instead use url() on every url except for my home link. This works perfectly but it feels weird to have that filter on every url on the site except for one. I'm using this option unless anyone has a better idea.

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions