How to Put some of the assets in subdomain

Right now all of my files are served with domain example.com. I want to filter some extentions, for example mp3 & mp4 and put them under media.example.com subdomain. Is it possible with jekyll or perhaps a plugin?

it should not be any problem at all to use assets from a different domain you just have to use their correct url.

I do this all the time for stuff on S3. You do need to make sure that if your main site is ssl then the other items have to have an ssl url also.

have you tried this and had a problem?

No. I don’t want to use it like this way. I want to normally put my asset in asset folder and give absolute or relative paths like /assets/media/audio.mp3 then the plugin would convert the paths to subdomain accordingly. I want to be able to see the media when I do jekyll serve

I don’t understand, if you use the sub domain why would you not see the media when you do jekyll serve? no internet access?

what is your reason for wanting to do this? maybe that will make it more clear what you are trying to do.

That way I need to first upload my media in the correct place, then use it inside my posts. Its not convenient imo.

I don’t quite understand the edge-case scenario here…

You mean to say that when you’re serving the site in development ENV, you need the media links to resolve to the resource in your local assets directory, but when in production ENV, you want the media-links to resolve to https://media.example.com ?

If yes, I guess it can be achieved with some configuration settings and liquid if block… (tacky…) but then again, if you’re hosting anywhere other than GitHub Pages, then you can craft a plugin for a custom liquid filter say media_url and then use it in your templates…

A

Yes. Exactly I want something similar and I was thinking if there is a plugin for this task out there.

none that I know of… but its relatively simple to write one yourself if you’re not hosting on GitHub Pages…

I’ve seen a few plugins that do this, most for the purpose of using a CDN.

If you search around you can find more, here’s just the first one I came across.

And another one. https://gist.github.com/cermakcz/e4067680e2477fe10c6c5ecc04068c52