如何将`url`站点变量设置为`jekyll serve –host …`中指定的主机和端口?
如何从jekyll插件中访问jekyll serve
运行网站的主机和端口,从正确的位置加载我的资产与绝对链接?
当我运行jekyll serve --host example.local --port 1234
我想将url
var(在_config.yml中设置为example.com)更改为给定的主机和端口,以便我可以使用{{ site.url }}/css/site.css
而不获取我的生产资产。 如果没有指定其他内容,那么获取默认的localhost:4000
也会很不错。
如果你想获得带端口的完整url,你可以这样做:
{% assign fullUrlWithPort = site.host | prepend:"http://" | append:":" | append: site.port %}
默认情况下, {{ fullUrlWithPort }}
会为您提供http://127.0.0.1:4000
。
如果你启动一个jekyll serve --host myhost --port 1234
它会给你一个http://myhost:1234