Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get "_pages" referenced at the site root in Jekyll?

Tags:

yaml

jekyll

I have Jekyll site hosted on GitHub Pages. The file _config.yml has this content (excerpt):

# Defaults
defaults:
  # _pages
  - scope:
      path: "_pages"
      type: "pages"
    values:
      layout: "single"
      read_time: true

So when the site is built, I can open a page by its URL like this: https://repo.github.io/_pages/some-page/

I read all the docs for Jekyll but it is not clear to me how to turn this URL to be https://repo.github.io/some-page/ or maybe https://repo.github.io/pages/some-page/.

like image 587
v.karbovnichy Avatar asked Nov 19 '25 20:11

v.karbovnichy


2 Answers

_pages can be seen as collection directory. Therefore by simply having the following config:

collections:
  pages:
    output: true

will give you URLs like https://repo.github.io/pages/some-page.html

To get custom URLs you may add a permalink sub-config:

collections:
  pages:
    output: true
    permalink: /:collection/:path/

will give you URLs like https://repo.github.io/pages/some-page/

For more possibilities, refer the official docs

like image 57
ashmaroli Avatar answered Nov 21 '25 09:11

ashmaroli


For eg. https://repo.github.io/some-page, you can put in _pages and config as such:

collections:
  pages:
    output: true
    permalink: /:name
like image 29
samwize Avatar answered Nov 21 '25 09:11

samwize



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!