Jekyll-admin Rewrites Relative Asset URLs

Ubuntu 18.04LTS
Jekyll 4.0.0
[URL notes have added spaces in them]

I’ve got jekyll-admin installed and set up for Internet use with an nginx reverse proxy configuration, similar to

I’m using a cloned Github Jekyll repo, and have set the jekyll-admin root to the Jekyll repo’s “_site” directory, which mostly works.

Where it breaks down is when jekyll-admin rewrites all of the asset URLs to use “localhost : 4000” instead of “mydomain . com : 4040” [see nginx reverse proxy note, below]

This is a FILE rewrite, not a virtual rewrite, so, in fact, all of the relative asset links in my “_site” directory now have “http: // localhost : 4000” prepended to them!

i.e. my links are set up like “/images/image.png” and jekyll-admin rewrites them as “http: // localhost : 4000 /images/image.png” … which is no good.

Not only can I not deploy from “_site”, but in jekyll-admin, all of the “View” links go to localhost : 4000 instead of using my domain:port, so they are all broken.

How can I prevent jekyll-admin from modifying my relative asset links?
I just want them to remain as relative links.

Thanks in advance for any comments and tips.

[Note about nginx reverse proxy]

I already have Apache listening on port 80, so I chose port 4040 as my jekyll-admin port for use with nginx. Make sure you listen to something other than port 4000 in your reverse proxy config, or nginx will just loop until it runs out of workers.

I am familiar with Jekyll Admin.

Is this something you can do to fix the URL in your page by hand or with a filter? Or nginx config?

Jekyll Admin could maybe be configured to change the inserted URL or you can use a manual change or includes file or a custom Jekyll filter which you use everywhere. But Jekyll Admin doesn’t actually serve the images so I’d say your problem doesn’t sound like Jekyll Admin.

Other ideas - set your url in the config or the command line with the localhost and nginx port when you build. Or not port.

Thank you for your replies!

When the repo is freshly-cloned, there is no mention of localhost:4000 in any file, however I am no longer thinking it’s jekyll-admin that’s “updating” my URLs, because it happens even when I’m not loading the jekyll-admin plugin. Simply cloning the repo (no localhost:4000) and then ‘jekyll serve’ is enough … the relative URLs in the HTML all get ‘localhost:4000’ added to them.

That is, all of the asset URLs, and the “View” URLs in the jekyll-admin interface,have “http://localhost:4000” prepended to them.

I had to set up the nginx reverse proxy to be able to use anything other than localhost:4000. I do see that our file in the original repo references navigating to localhost:4000, however that string is not anywhere in any of the HTML (or other) files, until I launch jekyll.

I have also tried forcing the correct URL:port using _config.yml’s url parameter, with no success.

Please note that, in jekyll-admin after it has been launched, the links to the HTML files and the jekyll-admin menu items are fine, using the correct URL and port, but the “View” buttons and all of, for example, the image links are broken because of localhost:4000 being hard-coded into them.

I suppose I could write a script to remove that string, after jekyll inserts it, but I would prefer to be able to change the config or something, so it never gets added, at all.

Alrighty, then … here’s the hack I ended up with.

Please note that I had attempted to do things as Jekyll expects, like
jekyll serve --host [IP ADDRESS] --port [PORT] --trace
But Jekyll was coughing up hairballs on that type of activity, so I went with a straight hack.

Two files needed to be hacked, one from Jekyll and one from Jekyll-Admin

1) /home/[user]/gems/gems/jekyll-4.0.0/lib/jekyll/commands/serve.rb
I hacked this file so the links/images in the rendered pages would use my IP:PORT
I commented out the default_url definition entirely (earlier hack attempts using that definition borked Jekyll) and replaced it with one that is hard-coded to use my host IP and port, as set up in nginx.

2) /home/[user]/gems/gems/jekyll-admin-0.10.0/lib/jekyll-admin/urlable.rb
I hacked this file so the links/images in the CMS would use my IP:PORT
I changed[“host”].sub(‘’,‘localhost’) to use my host IP instead of localhost, and changed[“port”] to substitute my port for port 4000.

Pulled in a fresh clone of the project, started Jekyll with no additional parameters and it works!
The complete file hacks are below.
If there is interest, I have the complete Jekyll/Jekyll-Admin setup process as a HOWTO to post.
Thanks for your interest, MichaelCurrin!

  1. Modify /home/[user]/gems/gems/jekyll-4.0.0/lib/jekyll/commands/serve.rb
    //so rendered page links/images work non-localhost
    def default_url(opts)
    config = configuration_from_options(opts)
    config["ssl_cert"] && config["ssl_key"],
    "[IP ADDRESS]",

  2. Modify: /home/[user]/gems/gems/jekyll-admin-0.10.0/lib/jekyll-admin/urlable.rb
    //so CMS links/images work non-localhost
    def host["host"].sub("","[IP ADDRESS]");
    def port["port"].sub("4000","[PORT]");

@Stupidscript Glad you found a solution and detailed it here.

Seeing as localhost:4000 is hardcoded into Jekyll admin - do you think you could setup Nginx to serve on port 4000 and then get Jekyll to serve on another?


jekyll server --port 3000

(or update the config file).

And also adjust your Nginx config to serve on 4000 and pass through to 3000.

This solution might only work well locally - you’ll probably want nginx on 443 for HTTPS on remote prod env. But it means no hacking on Jekyll files.