Running multiple jekyll app simultaneously - jekyll

I was wondering if it is possible to run multiple jekyll app at the same time.
I have installed foreman but it doesn't seem to be able to change the app port when an other one is already running.
At the moment I have to set the jekyll port manually in the Procfile
web: jekyll --server 5000
Is it in anyway possible to do this automatically?

I think I am a bit late, but here is the answer for those, who have the same problem.
Equally to Ruby on Rails the command --port 3000 can be used.
So it would look like this:
$ jekyll serve --port 8888
Edit: As mentioned in the documentation you can also simply add the option port: 8888 in your _config.yml file.
The new generated file would look like this:
name: Your New Jekyll Site
pygments: true
port: 8888
Port 8888 is used here for the example
Further Reading:
Jekyll Configuration
These are just a few of the available configuration options. Many configuration options can either be specified as flags on the command line, or alternatively (and more commonly) they can be specified in a _config.yml file at the root of the source directory. Jekyll will automatically use the options from this file when run. For example, if you place the following lines in your _config.yml file:
source: _source
destination: _deploy
Then the following two commands will be equivalent:
$ jekyll build
$ jekyll build --source _source --destination _deploy
So using the command line
jekyll serve --port 8888
is the equivalent to putting port: 8888 into your _config.yml.

Sure. As your question already suggests, just run the different instances on different server ports (using 5000 instead of the default 4000). Remember that you can specify the server (and all other command-line options) in the _config.yml file if you don't want to specify it in the run command. Please clarify if I've misunderstood the question.

Related

Is there a directory that will place items in the root of _site on build?

I have a bunch of static files (basically favicons, apple-site-icons, etc) that I want to be at the root of _site when it's built. Currently they're just sitting at the root of my main code folder (along with _posts, _scss, _layouts, etc). It builds fine but it would be nice to move them into a subdirectory so the main directory isn't cluttered up (it's an OCD thing).
Is there any folder where I can put these items so they automatically copy to the root of _site when I build? I know I can write a script to do this and trigger it after the build, and there's probably an extension I could lean on, but I'm looking for a solution that just automatically moves them when I run jekyll build for simplicity.
NBD if I can't do it, just curious because I'm kind of a neat freak.
Thanks!
Jekyll allows you to do exactly that using permalinks.
Permalinks are the output path for your pages, posts, or collections. They allow you to structure the directories of your source code different from the directories in your output.
A simple example extracted from the official page is a case where you have /my-pages/about-me.html with the front matter as follows:
---
permalink: /about/
---
This way you specify the output url. In this example, you could access it in local with localhost:4000/about/
The source option. You can specify this in your _config.yml or as a command line option (https://jekyllrb.com/docs/configuration/options/). How you set this has slightly different requirements/implications.
First, move everything that belongs to the Jekyll site into a folder (e.g. "src").
Then set one of these up (assuming you have a Gemfile):
Command line option with root Gemfile:
Keep Gemfile in the root folder
Run bundle install
Run bundle exec jekyll serve --source src
Command line option with nested Gemfile:
Run BUNDLE_GEMFILE=src/Gemfile bundle install
Run BUNDLE_GEMFILE=src/Gemfile bundle exec jekyll serve --source src
Config file option:
Keep Gemfile and _config.yml in the root folder
Add source: src somewhere in your _config.yml
Run bundle install
Run bundle exec jekyll serve
Each solution here might work better with other external services building your site. There are likely other ways to set this up, but this should get you started.

How can I trigger a script when local jekyll file changes?

I am running a jekyll server for a local site with bundle exec jekyll serve. When I make edits to a file in the site, jekyll regenerates the files automatically. I'd also like a script I have to be triggered to automatically to refresh my browser. How can I trigger this script?
In short words, run Jekyll with the --livereload parameter.
The command will look like this:
bundle exec jekyll serve --livereload
For more information, call help command:
jekyll help serve
Here are the parameters that may be useful:
-l, --livereload Use LiveReload to automatically refresh browsers
--livereload-ignore ignore GLOB1[,GLOB2[,...]] Files for LiveReload to ignore. Remember to quote the values so your shell won't expand them
--livereload-min-delay [SECONDS] Minimum reload delay
--livereload-max-delay [SECONDS] Maximum reload delay
--livereload-port [PORT] Port for LiveReload to listen on
You can of course combine options.
For example:
To run second project with Jekyll at the same time you need to set other port and another port for LiveReload.
bundle exec jekyll serve --livereload --livereload-port 8080 --port 4001
And now in your browser you can see the second project at http://localhost:4001/ or http://0.0.0.0:4001/

error executing $jekyll serve --watch --baseurl ""

I want to make a blog using Jekyll , so have made a public repository in my github account and made gh-pages branch and set it to default branch and later deleted master branch . Also, I have made _config.yml file whose contents are as follows.
markdown:redcarpet
baseurl:/amar
exclude:['readme.md']
when I want to turn on Jekyll , using this command
$jekyll serve --watch --baseurl ""
I am getting this error
dhcp-54-132:amar Amar$ jekyll serve --watch --baseurl " "
WARNING: Error reading configuration. Using defaults (and options).
Configuration file: (INVALID) /Users/Amar/Documents/jekyll-blog/amar/_config.yml
Source: /Users/Amar/Documents/jekyll-blog/amar
Destination: /Users/Amar/Documents/jekyll-blog/amar/_site
Incremental build: disabled. Enable with --incremental
Generating...
done in 0.062 seconds.
Auto-regeneration: enabled for '/Users/Amar/Documents/jekyll-blog/amar'
WARNING: Error reading configuration. Using defaults (and options).
Configuration file: (INVALID) /Users/Amar/Documents/jekyll-blog/amar/_config.yml
Server address: http://127.0.0.1:4000 /
Server running... press ctrl-c to stop.
Can someone please help me, also as I am new to Jekyll , so please do not downvote me . Thanks in advance
There needs to be a space for the options and its values
markdown:redcarpet
should be
markdown: redcarpet
and so on in _config.yml file
There should be space after tags in .yml file, and this has to be done for all of the tags.

Gitlab with non-standard SSH port (on VM with Iptable forwarding)

My gitlab is on a virtual machine on a host server. I reach the VM with a non-standard SSH port (i.e. 766) which an iptable rule then forward from host:766 to vm:22.
So when I create a new repo, the instruction to add a remote provide a mal-formed URL (as it doesn't use the 766 port. For instance, the web interface give me this:
Malformed
git remote add origin git#git.domain.com:group/project.git
Instead of an URL containing :766/ before the group.
Wellformed
git remote add origin git#git.domain.com:766/group/project.git
So it time I create a repo, I have to do the modification manually, same for my collaborator.
How can I fix that ?
In Omnibus-packaged versions you can modify that property in the /etc/gitlab/gitlab.rb file:
gitlab_rails['gitlab_shell_ssh_port'] = 766
Then, you'll need to reconfigure GitLab:
# gitlab-ctl reconfigure
Your URIs will then be correctly displayed as ssh://git#git.domain.com:766/group/project.git in the web interface.
if you configure the ssh_port correctly in config/gitlab.yml, the webpages will show the correct repo url.
## GitLab Shell settings
gitlab_shell:
...
# If you use non-standard ssh port you need to specify it
ssh_port: 766
ps.
the correct url is:
ssh://git#git.domain.com:766/group/project.git
edit: after the change you need to clear caches, etc:
bundle exec rake cache:clear assets:clean assets:precompile RAILS_ENV=production
N.B.: this was tested on an old Giltab version (v5-v6), and might not be suitable for modern instance.
You can achieve similar behavior in a 2 step process:
1. Edit: config/gitlab.yml
On the server, set the port to the one you use:
ssh_port: 766
2. Edit ~/.ssh/config
On your machine, add the following section corresponding to your gitlab:
Host sub.domain.com
Port 766
Limit
You will need to repeat this operation on each user's computer…
References
GitLab and a non-standard SSH port
Easy way to fix this issue:
ssh://git#my-server:4837/~/test.git
git clone -v ssh://git#my-server:4837/~/test.git
Reference URL

Auto regeneration is not working with _config.yml?

I installed jekyll and run it from cli:
jekyll --server --auto
But when I change _config.yml I can't see that my changes where applied and I have to restart server every time.
I really need to restart server every time when I change _config.yml? Or there is some workaround?
I believe you are correct; that changes to _config.yml always require restarting the server.
After all, _config.yml provides options that you can override in the call to Jekyll. So it is unclear how auto should behave if an option is called on the command line run of jekyll which overrides some of the _config.yml settings, and then the config is edited. Which would take precedence then? the _config.yml or the original command line argument?
If you have the server running, you don't need to restart it. A (little bit) quicker way to is to run jekyll build or bundle exec jekyll build after editing your _config.yml file.
Parker Moore, maintainer of Jekyll, confirms that _config.yml changes are not autogenerated or picked up by a running, watching Jekyll server.
No I remember why we can't do this: if you change either source or destination, you're eff'd, so we said 👎 to this suggestion. Definitely use _data if you're using custom data. Otherwise, a quick ^C and restart should be 👌
https://github.com/jekyll/jekyll/issues/2302#issuecomment-43160557
I really need to restart server every time when I change _config.yml?
Or there is some workaround?
There is some workaround:
1) Install watchy.
npm i -D watchy
2) Restart on config change (for example as a package.json script)
"scripts": {
"restart": "watchy -w _config.yml -- bundle exec jekyll serve --drafts --watch",
(--drafts is unrelated, but I am assuming you do this locally in dev/authoring mode...)