How to remove space (%20) and replace it with (-) for internal links?

I convert wikilinks to Markdown to host them online.

I don’t have problem with single small case links.

eg: In wikilink : [[simple]] → converted into mdlink [simple](simple) → resolves on web browser/post/simple/

But when there is whitespace & uppercase its different.

[[My Link]] is converted into [My Link](My%20Link) . It points to the right note on obsidian but gives 404 on the host.

The host requires My%20Link to be my-link. so that it could point to/post/my-link
Hence links are not directed properly and gives 404.

I have a lot of files with filenames in caps & spaces in between.

Is there a way I can convert [[My Link]] into [My Link](my-link) easily & point it to My Link.md in obsidian ?

Can I use slugs for this ? may be slugs & alias can be used manually but is there an easier way ?

I want both website & obsidian link to same file.

In addition to [My Link](My%20Link), also [My Link](<My Link>) should work within Obsidian. Does that work better on your host?

What do you use for publishing? Does that have any options to transform links for you?

1 Like

I use Hugo (with Github).

It converts all caps to smallcase & all all space to hyphens.

it works well for one letter smallcase filename, but otherwise it gives 404.

I’d check Hugo’s documentation if you haven’t already. This seems like something that should be configurable.

1 Like

The plugin github-publisher has an option called “slugify mdlink” which does exactly that (ie convert to lower case and replace space %20 by hyphen)

2 Likes

:+1: Yes, the plugin github-publisher does have, but Github keep revoking the token used in the plugin, because the token value is publicly displayed in the repo. Anyone can see the token value. So Github revokes the token each time it is used.

Maybe the plugin dev can fix this.

Yes, [My Link](<My Link>) does solve the problem.

Is there easy way to convert wikilinks to this format.

I use a plugin " wikilinks-to-mdlinks-obsidian" but it does the conversion without <>.

Obsidian Publisher seems to have security issue of exposing github token. Hence github revokes it.

Parts of me think that using regex replace is one option, but it does require some experience. Extending the plugin is another (which I see you and some others have already done).

A third option is a semiautomatic of searching for mdlinks with spaces, but without the angular brackets. And if found you change them manually. I’ll see if I can whip up a regex later today, but can’t do it right now.

1 Like

If u think there is a security breach with github-publisher plugin, please raise an issue bug report in its github repo. The plugin’s author is quite active and responsive. She might verify and issue a fix if necessary

1 Like

Are you using github-publisher with Hugo ? Just wanted to know if it is problem from my end.

No, not with hugo. Im playing with mkdocs-material since the github-publisher has many conversion script only for mkdocs template (ie. Wikilink to mdlink, dataview snapshot, generate backlink…)

1 Like

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