Is it possible to replace the resource path during rendering in order to use jsDelivr acceleration

In China, for various reasons, the page access speed on GitHub Pages is very slow.

Tried to use Cloudflare, but still no good access speed for mainland China. Recently I discovered that
jsDelivr provides a global CDN service, it supports CDN for GitHub files, and the access speed is very good.

So I want to know if it is possible to replace the path of static resources (such as JS, CSS, images, etc.) when Hugo renders.

For example, the

! [dog_img] (dog.png)

Replaced in the generated page

https://cdn.jsdelivr.net/gh/user/repo@version/dog.png

In addition, replace files such as JS with corresponding paths

https://cdn.jsdelivr.net/gh/jquery/jquery@3.2.1/dist/jquery.min.js

After this operation is realized, I believe that more people will join Hugo’s ranks.

I am afraid that what you propose is not feasible as there are already thousands of Hugo users all over the planet with different needs and requirements that rely on other CDNs than jsdelivr.

However in your individual project you can pass the external part of the jsdelivr CDN URL by using the Markdown Render Hook Templates so that:
! [dog_img](dog.png) ---> https://cdn.jsdelivr.net/gh/user/repo@version/dog.png

Also nothing is stopping you from using external URLs for your other JS or CSS assets.

This topic was automatically closed after 16 hours. New replies are no longer allowed.