Skip to content

Conversation

@KStocky
Copy link
Contributor

@KStocky KStocky commented Nov 23, 2025

This is a proposed fix for #801.

I have made this PR because #820 seems to have been abandoned.

There is a difference in implementation with my PR, though.

Instead of providing another way to specify the URL, this PR proposes to allow writers to override the link text.

Why implement it this way?

By providing a new option called full_url you are giving people another unrelated way of creating URLs that is not compatible with the current way. This may lead to unexpected behaviour (e.g. what should happen if a base_url and full_url are specified?). Additionally, since it would be adding a new way of creating URLs, the logic to implement it is messier.

With the name_override way, we are not introducing a new way of specifying URLs. We are instead just allowing people to override the text of the generated URL with another string.

With this method the URL will ALWAYS be generated with base_url + filename.
With the change being the link text is named_override | default filename

I feel like this is a bit cleaner both in terms of expectations from the user, and from an implementation perspective.

@netlify
Copy link

netlify bot commented Nov 23, 2025

Deploy Preview for hugo-hextra ready!

Name Link
🔨 Latest commit de484c8
🔍 Latest deploy log https://app.netlify.com/projects/hugo-hextra/deploys/692359c113e8a00008b38684
😎 Deploy Preview https://deploy-preview-882--hugo-hextra.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@KStocky KStocky changed the title Override link text for code blocks feat: Override link text for code blocks Nov 23, 2025
@imfing
Copy link
Owner

imfing commented Nov 28, 2025

Thanks for the explanation! The reason I originally preferred the full_url approach is that it allows authors to completely override the generated URL instead of always using base_url as a mandatory prefix.

With the current model, I’m not sure how one could easily support cases where the final URL shouldn't include the base_url at all.

@KStocky
Copy link
Contributor Author

KStocky commented Dec 5, 2025

To be clear, with this approach, base_url can be used as the full URL. base_url + filename still provides the full URL. Except we now allow filename to be empty.

I guess that is the negative to this approach. base_url implies that it can't be the full URL.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants