jekyll / jekyll-sitemap

Jekyll plugin to silently generate a sitemaps.org compliant sitemap for your Jekyll site
http://rubygems.org/gems/jekyll-sitemap
MIT License
949 stars 134 forks source link

How do I generate this? #236

Closed GiacomoLaw closed 5 years ago

GiacomoLaw commented 5 years ago

I have it in config, but I see nothing added to my repo. How can I get a sitemap?

Thanks

PGScully commented 5 years ago

It should be generated automatically every time you do jekyll build or serve - that includes when you push to GitHub, etc. Look for it in _site after a local build.

DirtyF commented 5 years ago

It's here: https://giacomolaw.me/blog/sitemap.xml Generated files are not versioned, only source files.

GiacomoLaw commented 5 years ago

I manually made those. I cant find a _site folder.

PGScully commented 5 years ago

You've done all these steps?

  1. Edit Gemfile, adding gem "jekyll-sitemap"
  2. bundle install
  3. Edit _config.yml, adding jekyll to plugins or gems, depending on Jekyll version
  4. bundle exec jekyll build

That creates the _site directory (which may be called something else if you've overridden it) which contains all the generated pages, including the sitemap.xml.

PGScully commented 5 years ago

But also, see the note on GitHub Pages in the jekyll-sitemap README.md here: https://github.com/jekyll/jekyll-sitemap

GiacomoLaw commented 5 years ago

So I need to generate it locally, and once done it will generate automatically?

Okay, I’ll give it a go. Thanks!

DirtyF commented 5 years ago

@GiacomoLaw You don't need to. GitHub Pages will automatically build your site everytime you push a commit. You can build your site locally though to check your changes are OK before pushing to GitHub.

GiacomoLaw commented 5 years ago

@GiacomoLaw You don't need to. GitHub Pages will automatically build your site everytime you push a commit. ...

@DirtyF that’s where I’m having the issue. It’s not building the site map when I push to the repo.

DirtyF commented 5 years ago

GitHub Pages Help should help you find why: https://help.github.com/articles/viewing-jekyll-build-error-messages/

ashmaroli commented 5 years ago

@GiacomoLaw I took a peek into your site's repository. The repository contents are "generated HTML files", not source files for Jekyll. So there's nothing for GitHub Pages to build upon.

To continue in the same fashion, you have to generate the sitemap locally and push it to your repo.

GiacomoLaw commented 5 years ago

Ah, okay. Thanks!

GiacomoLaw commented 5 years ago

Hello, I have generated the sitemap locally however this is what I get in the sitemap under _site:

image

How can I get it to replace localhost with my domain?

The repo is: https://github.com/GiacomoLaw/blog

I have yet to push my changes, as _site is under .gitignore.

Thanks!

PGScully commented 5 years ago

When you push to GitHub, _site will be rebuilt by GitHub, and localhost will be replaced with whatever you've configured url to be in _config.yml.

ashmaroli commented 5 years ago

@GiacomoLaw To replace localhost with site.url setting, build with setting JEKYLL_ENV to 'production': If on Windows:

set JEKYLL_ENV=production
bundle exec jekyll build

Otherwise:

JEKYLL_ENV=production bundle exec jekyll build

This can get tedious at times. So, the better solution is to save the above in a BASH shell script if you have BASH installed:

#!/usr/bin/env bash
# jekyll production script
# filename: build-site

JEKYLL_ENV=production bundle exec jekyll build

Now, simply run the above script:

bash ./build-site
GiacomoLaw commented 5 years ago

@PGScully @ashmaroli Thank you both! I will give it a go. I'll first try just pushing it and seeing if Github rebuilds it.

How can I exclude a page from the sitemap?

Thank you!

ashmaroli commented 5 years ago

How can I exclude a page from the sitemap?

In the page's front matter:

---
sitemap: false
---
GiacomoLaw commented 5 years ago

Thank you!

GiacomoLaw commented 5 years ago

I have now pushed it with _site to Github.

https://github.com/GiacomoLaw/blog

Is everything okay here? Will all the links work fine?

https://github.com/GiacomoLaw/blog/blob/master/_site/sitemap.xml

Is the sitemap all good?

Thanks!

ashmaroli commented 5 years ago

Is the sitemap all good?

If it looks good to you, it is: https://giacomolaw.me/blog/sitemap.xml

GiacomoLaw commented 5 years ago

Thanks so much for your help! Adding bash to windows and going to use that script.

Thanks :D

ashmaroli commented 5 years ago

Are these scripts what people put in these dotfile repos?

Nope. And that discussion is outside the scope of this repository. Regarding the script above, you can swap jekyll build with jekyll serve if you want a production preview locally. :v:

GiacomoLaw commented 5 years ago

Yep, used jekyll serve. What does enabling --watch do? Will this update my sitemap even if I do not build the site?

image

Thanks, appreciate the help.

ashmaroli commented 5 years ago

When --watch is enabled with jekyll build, Jekyll will automatically update the contents of _site based on changes you make to the source files. It's the same as jekyll serve but lacks a preview server.

For continued discussion please register at https://talk.jekyllrb.com/ GitHub Repos in Jeyll org is only for bug reports.

GiacomoLaw commented 5 years ago

Okay, thanks. Final question, when I build do I do bundle exec jekyll build --watch, and then I won't need to build again?

Thanks and apologies for moving from the topic scope.

GiacomoLaw commented 5 years ago

My google verification file is being mapped:

image

How can I stop this?