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

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.

Related

How do I redirect an old Netlify + Jekyll site address, to the new address?

I created a Jekyll site, hosted at Netlify, at old.address.com. Now I want to redirect to new.address.com. But the Netlify docs doesn't seem to work or I don't understand the docs. This is what I did:
I added, to _config.yml: (because Netlify says Jekyll excludes '_...' files)
include:
- _redirects
And I added a _redirects file. I just copy-pasted Netlify's generated instructions into that file, this is the content:
# Redirect domain aliases to primary domain
https://jekyll-comments.demo.ed.community/* https://jekyll-demo.talkyard.io/:splat 301!
http://jekyll-comments.demo.ed.community/* https://jekyll-demo.talkyard.io/:splat 301!
https://jekyll.demo.talkyard.io/* https://jekyll-demo.talkyard.io/:splat 301!
http://jekyll.demo.talkyard.io/* https://jekyll-demo.talkyard.io/:splat 301!
And this has no effect. What's the problem / what am I doing wrong?
This is how the directory looks like:
$ ls -1
404.html
about.md
_config.yml
Gemfile
_includes
index.md
_layouts
_posts
_redirects <—— added as per Netlify's instructions
_sass
_site
$ ls -1 _posts/
2018-01-01-like-about-jekyll.markdown
2018-01-02-installation-instructions.markdown
2018-01-02-kind-creatures.markdown
The config file is just the default one:
title: ...
email: ...
baseurl: "" # the subpath of your site, e.g. /blog
url: "" # the base hostname & protocol for your site, e.g. http://example.com
twitter_username: ...
github_username: ...
# Build settings
markdown: kramdown
theme: minima
plugins:
- jekyll-feed
talkyard_comments_server_url: ...
include:
- _redirects
Please note that although there are fairly many details above, it's all just various default stuff. So it's not specific to my problem. It should apply to all new Jekyll sites.
Disclaimer: I work for Netlify
We have a specific section on this in our documentation: https://www.netlify.com/docs/redirects/#handling-hostnames-and-protocols-differently
...and your snippet should work since it follows those conventions.
The only prerequisites to make that work are:
1) that you have your site configured in our UI to answer to ALL of those names - so:
jekyll-comments.demo.ed.community
jekyll-demo.talkyard.io
jekyll.demo.talkyard.io
2) and that all names are set up the same in DNS (CNAME to yournetlifysitename.netlify.com)
The only way to add "extra" names to your Netlify configuration is as domain aliases, which are configured in the Domain settings panel right next to your "main" custom domain.
Since your _redirects looks correct to me, if you have the prerequisites configured as suggested, the most likely failure mode is that you don't end up with your redirects actually applied for some reason (usually - they didn't get deployed because they didn't exist in a file called _redirects, in your publish folder, after the build), but your include in the jekyll config should allow that file to persist in that location. That jekyll config is the "right" way to do it but for other site generators, we sometimes advise people to copy the redirects into place after build: jekyll build && cp netlify_redirects.txt _site/_redirects
You can download whatever files are in your deploy to examine their "final state" via this tiny icon from any successful deploy logs page:
From a quick look at your site configuration, they appear to be deployed and working:
$ curl -v https://jekyll-comments.demo.ed.community/ -o /dev/null
* Connected to jekyll-comments.demo.ed.community (35.199.180.1) port 443 (#0)
[...]
< HTTP/1.1 301 Moved Permanently
[...]
< Location: https://jekyll-demo.talkyard.io/
So I guess the next question is...how are you testing?

Excluding a directory from Jekyll watch

I'm using Jekyll 3.1.1 to generate a blog and I recently introduced a Git hook to automatically publish changes pre-push.
After introducing this hook, I have started getting the following error when I run jekyll serve:
Configuration file: /Users/egillespie/Projects/blog.givingjar.org/_config.yml
Source: /Users/egillespie/Projects/blog.givingjar.org
Destination: /Users/egillespie/Projects/blog.givingjar.org/_site
Incremental build: disabled. Enable with --incremental
Generating...
done in 0.223 seconds.
** ERROR: directory is already being watched! **
Directory: /Users/egillespie/Projects/blog.givingjar.org/node_modules/git-scripts/bin/hooks
is already being watched through: /Users/egillespie/Projects/blog.givingjar.org/node_modules/git-scripts/bin/hooks
MORE INFO: https://github.com/guard/listen/wiki/Duplicate-directory-errors
Auto-regeneration: enabled for '/Users/egillespie/Projects/blog.givingjar.org'
Configuration file: /Users/egillespie/Projects/blog.givingjar.org/_config.yml
Server address: http://127.0.0.1:4000/
Server running... press ctrl-c to stop.
What's peculiar is that I am excluding node_modules in _config.yml:
exclude:
- Gemfile
- Gemfile.lock
- LICENSE
- README.md
- package.json
- Gruntfile.js
- node_modules
node_modules is correctly being excluded from building (i.e. there is no node_modules subdirectory in _site).
I'm also excluding node_modules in .gitignore:
# project
node_modules
_site*
.sass-cache
.jekyll-metadata
# general
.DS_Store
Thumbs.db
ehthumbs.db
Based on this GitHub issue and this commit it seems like node_modules should be excluded from the watch, but it's not. I can't decipher from the documentation if there's another way to exclude files from the watch.
What is the proper way for me to exclude a directory from the watch and avoid the error described above?
The value for exclude parameter in _config.yml should be an array i.e.
exclude: ['_site', 'node_modules', ...]
Source: Jekyll Documentation - Configuration
Judging by the paths displayed in your output, you're on macOS. The jekyll-watch gem is responsible for this area (watch/rebuild features), which itself depends on the 'listen' gem. The listen gem itself uses the rb-inotify gem as a dependency, which has several issues with macOS specifically and its filesystem. This results in several bugs in regeneration behaviour that aren't not easy to fix. Background and relevant bugs:
https://github.com/guard/listen/issues/274
https://github.com/guard/listen/pull/273
You can try using the 'polling' method: https://github.com/guard/listen#listen-adapters instead, but it's much slower.
Try this to your _config.yml:
keep_files: [node]
where node is a folder to exclude from the --watch. What this will do is keeping the folder node untouched by jekyll build. Then add all files that you want to keep in the site root but not rendered by Jekyll.

Adding Jekyll to an existing website

I have a simple website and tried to add a Jekyll blog in it in a new folder blog thus I have run jekyll new blog in the folder /path. However when I'm running the command jekyll build in /path I have these errors:
$ jekyll build
Configuration file: none
Source: /path
Destination: /path/_site
Generating...
Build Warning: Layout 'post' requested in blog/_posts/2015-06-14-welcome-to-jekyll.markdown does not exist.
Build Warning: Layout 'default' requested in blog/index.html does not exist.
Conversion error: Jekyll::Converters::Scss encountered an error converting 'blog/css/main.scss'.
Conversion error: File to import not found or unreadable: /blog/_sass/base.scss. Load paths: on line 47
I solved the first problem (Configuration file: none) by moving _config.ymlin the parent folder, however I still have problems when requesting layout using
---
layout: default
---
The imports in main.scssare also not working (last error).
If I'm doing the same command jekyll build in /path/blogafter moving again _config.yml, I have no errors. Does someone know how to be able to do a jekyll buildin the parent folder with the configuration I have? Do I have to entirely change the architecture of my website to include a Jekyll blog in it?
You config.yml is in /path with
source: /_jekyll
destination: /blog
baseurl: /blog
Your jekyll sources are in /path/_jekyll.
And you generated files will be in /path/blog.
Ready to deploy !

jekyll 3.0.0-beta error Is a directory # rb_sysopen

With jekyll-2.5.3 I'm able to run "jekyll serve --watch" to generate my site and preview it. However, since upgrading to jekyll-3.0.0.pre.beta1 I now see the following error
jekyll serve --watch
Configuration file: /wrk/git/blog/_config.yml
Deprecation: Auto-regeneration can no longer be set from your configuration file(s). Use the --[no-]watch/-w command-line option instead.
Deprecation: The 'pygments' configuration option has been renamed to 'highlighter'. Please update your config file accordingly. The allowed values are 'rouge', 'pygments' or null.
Source: /wrk/git/blog
Destination: /wrk/git/blog/_site
Incremental build: enabled
Generating...
Build Warning: Layout 'nil' requested in atom.xml does not exist.
Build Warning: Layout 'nil' requested in rss.xml does not exist.
jekyll 3.0.0-beta1 | Error: Is a directory # rb_sysopen - /wrk/git/blog/_site/tech/2013/04/24/blog
I've checked and I have read/write/execute permissions, so I don't think it's a permission error. If it helps, here's my source and layout (https://github.com/minhongrails/blog), which has directories like _includes, _layouts, _posts, index.html, etc in the root directory.
Does anyone have any ideas how to resolve this? Thanks!
Build Warning: Layout 'nil' requested in atom.xml does not exist.
Build Warning: Layout 'nil' requested in rss.xml does not exist.
I think the layout should be null, not nill.
For some reason I needed to move my source files into a "source" subdirectory as specified in the _config.yml. Here's some of the _config.yml that I had to modify
source: src
# needed to also update this b/c it was generating inside the "source" dir
destination: _site
In Jekyll 2 I didn't need to do this but I guess it's now necessary in Jekyll 3? Here's a Github issue with more details: https://github.com/jekyll/jekyll/issues/3248

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...)