Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to disable sidebar for a folder or single page? [solved] #92

Closed
3 tasks done
xu-song opened this issue Jan 28, 2018 · 28 comments
Closed
3 tasks done

How to disable sidebar for a folder or single page? [solved] #92

xu-song opened this issue Jan 28, 2018 · 28 comments

Comments

@xu-song
Copy link
Contributor

xu-song commented Jan 28, 2018

I agree and want to create new issue


Expected behavior

disable sidebar in some folder or single page

Actual behavior

sidebar is enable in all pages

Steps to reproduce the behavior

  1. setup hexo and next
  2. enable sidebar

Node.js and NPM Information


v8.9.4
5.6.0


Hexo Information

Hexo version

hexo: 3.4.4
hexo-cli: 1.0.4

NexT Information

NexT Version:

[x] Latest Master branch.
[] Latest Release version.
[] Old version -

NexT Scheme:

[] All schemes
[x] Muse
[] Mist
[] Pisces
[] Gemini

NexT Configuration:

# Redefine custom file paths. Introduced in NexT v6.0.2.
# If commented, will be used default custom file paths.

# For example, you want to put your custom styles file
# outside theme directory in root `source/_data`, set
# `styles: source/_data/styles.styl`
#custom_file_path:
  # Default paths: layout/_custom/*
  #head: source/_data/head.swig
  #header: source/_data/header.swig
  #sidebar: source/_data/sidebar.swig

  # Default path: source/css/_variables/custom.styl
  #variables: source/_data/variables.styl
  # Default path: source/css/_mixins/custom.styl
  #mixins: source/_data/mixins.styl
  # Default path: source/css/_custom/custom.styl
  #styles: source/_data/styles.styl


sidebar:
  # Sidebar Position, available value: left | right (only for Pisces | Gemini).
  position: left
  #position: right

  # Sidebar Display, available value (only for Muse | Mist):
  #  - post    expand on posts automatically. Default.
  #  - always  expand for all pages automatically
  #  - hide    expand only when click on the sidebar toggle icon.
  #  - remove  Totally remove sidebar including sidebar toggle.
  display: post
  #display: always
  #display: hide
  #display: remove

Other Information

aa

@ivan-nginx
Copy link
Member

Don't underatand u: how to disable sidebar from data?

@xu-song
Copy link
Contributor Author

xu-song commented Jan 28, 2018

@ivan-nginx Disable sidebar for a single folder or page, such as source/data/, source/games/.

In this case http://blog.eson.org/games/2048/ . I want to disable sidebar for all pages under source/games/.

@sli1989
Copy link
Collaborator

sli1989 commented Jan 28, 2018

how about hexo clean before hexo d.
or use comments: false in your added menu page?
i have no bug in my added menu page.

@xu-song
Copy link
Contributor Author

xu-song commented Jan 29, 2018

@sli1989 comments: false only disable the comments, not the sidebar

@sli1989
Copy link
Collaborator

sli1989 commented Jan 29, 2018

@xu-song sorry for the misleading. you can see the above PR.
not suggest to use heading in your custom page for now.
after the PR, you can update the latest theme and add sidebar: false in front matter of your post and cumtom page.

@xu-song xu-song changed the title How to disable sidebar for some folder? such as source/data How to disable sidebar for a folder or page? Jan 29, 2018
@xu-song
Copy link
Contributor Author

xu-song commented Jan 29, 2018

sorry, what PR stands for? @sli1989

The following is my heading config in source\games\2048\index.html. But it doesn't work. The rendered page is http://blog.eson.org/games/2048/

---
sidebar: false
---

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>2048</title>

@sli1989 My Hexo and NexT are Latest Master branch.

@sli1989
Copy link
Collaborator

sli1989 commented Jan 29, 2018

Pull Request, you can try to know it using google search.
such as http://www.ruanyifeng.com/blog/2017/07/pull_request.html

@tsanie
Copy link
Contributor

tsanie commented Jan 29, 2018

@xu-song It has not been merged into the latest branch yet, please take a wait.

@tsanie
Copy link
Contributor

tsanie commented Jan 29, 2018

Add a feature in PR #93 , please have a try. @xu-song

@xu-song xu-song changed the title How to disable sidebar for a folder or page? How to disable sidebar for a folder or single page? Jan 29, 2018
@xu-song
Copy link
Contributor Author

xu-song commented Jan 29, 2018

@tsanie Thanks for your prompt reply. Your commit truly works for markdown file. But it does not work for html. Can u take another commit if possible.

source/games/2048/index.html

---
sidebar: false
---

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>2048</title>

@tsanie
Copy link
Contributor

tsanie commented Jan 29, 2018

Wait, which html, do you mean that you've written the html file in the hexo/source folder? It is not the right way to build a page, and that would lead the hexo to generate a strange html page.

Please use the .md files, and of course you can insert some html tags into the .md file, then you can generate the whatever page you want.


And you can surround the html tags by using {% raw %}...{% endraw %}, if you worried about some words maybe processed by the markdown render.

@xu-song
Copy link
Contributor Author

xu-song commented Jan 29, 2018

Is there a special render for html? Or .html and .md share the same render engine?

It works now. Just the same config as .md. Thanks for your help.
title date sidebar comments all work for html as heading config.

@tsanie
Copy link
Contributor

tsanie commented Jan 29, 2018

If there is no more problem, please close this issue.

@xu-song
Copy link
Contributor Author

xu-song commented Jan 30, 2018

Is there a god way to customize subfolder configuration? like .gitignore does, Can we set multiple .yml in different (sub)directories? @ivan-nginx @tsanie

----update
for example. can we define multiple theme_config like the following schema?

blog/─┬─_config.yml    # hexo config
      ├─theme───next
      │          ├──_config.yml   # theme config  -- main
      │ 
      ├─source/
          ├── _post/ 
          ├── folderA
          │     ├── _config.yml    # theme config  -- overwrite main_config
          │     ├── a.md
          │     ├── folderB
          │           └── b.md
          │       
          ├── folderB
          │     ├── _config.yml    # theme config  -- overwrite main_config

We can put the following config in source/folderA/_config.yml , which works for all the subdirectory.

sidebar: false
comments: false

Maybe it is a bit complicated.
Or it should be a feature of Hexo instead of Theme? Maybe not. I don't know

@tsanie
Copy link
Contributor

tsanie commented Jan 30, 2018

Sorry, I cannot quite understand what's your meaning. Could you give some detail examples?

@tsanie
Copy link
Contributor

tsanie commented Jan 30, 2018

@xu-song Yeah, it is a bit complicated, and it should be a feature of Hexo. Maybe you can ask Hexo for the question.

@ivan-nginx
Copy link
Member

ivan-nginx commented Jan 30, 2018

@xu-song can u explain why u need this? In short words.

For example: i want this feature because i need to...

@xu-song
Copy link
Contributor Author

xu-song commented Jan 30, 2018

customization @ivan-nginx

@ivan-nginx
Copy link
Member

Customize what?

@xu-song
Copy link
Contributor Author

xu-song commented Jan 30, 2018

just like you cusomize a single file with heading config. This feature can cusomize a batch of files by less config.

If you ask me why need customization. I don't know how to reply. Theme is born for customization. @ivan-nginx And this feature is doable in Theme level. Not belong to Hexo.

The above schema is just one choice of batch_configuration, surely not the best. But batch_config is better than config one by one.

@ivan-nginx
Copy link
Member

I asking u because i think there are all already can be customized. I just don't understand what exactly u need to customize.

For example, i want 2 different sites with 2 different Hexo & NexT configs to work under 1 Hexo node_modules, i create:

  1. In main Hexo dir file called site1.yml and add here all configs from Hexo & NexT in accoriance with Hexo data files guide.
  2. I do the same, but only difference in config filename, called now site2.yml — this will absolute another site with another source and public directories.
  3. I use hexo clean --config site1.yml && hexo g --config site1.yml — to generate site 1.
  4. I use hexo clean --config site2.yml && hexo g --config site2.yml — to generate site 2.

@xu-song
Copy link
Contributor Author

xu-song commented Jan 30, 2018

I think I have express my need clearly. If not , you can read again. And I don't like your style @ivan-nginx
We never talk about two sites.

If user's desired pattern conflicts with your roadmap, u can argue.
If you have another way to make user get what he expected, the lost user will be appreciated if u can help him.
Reply with a single word "why" or "what" makes me confusing about your point.

@ivan-nginx
Copy link
Member

ivan-nginx commented Jan 30, 2018

We can put the following config in source/folderA/_config.yml, which works for all the subdirectory.

sidebar: false
comments: false

No, we not put the following into theme config because it must be write in post's front-matter which must generate Hexo.

Maybe it is a bit complicated.

Maybe. Or maybe not.
Let's suppose we have ~500 posts. And u want to create ~100 configs in many subdirectories for that? Really? This is big waste of resources i think.
It's can be maked if strongly needed, but for now i don't see in what cases it can be implemented. If u want to customize each post — front-matter for this already exists.

U firstly ask for hide sidebar feature (and i still in shocked why it can be need) and this feature was added.
For now u want feature what will bring bigger problem for maintenance and less for useful. This is a little bit boldly.
If u lazy for add vars in front-matter and want to use some automatization with batch files, u can add same strings in front-matter also (at least -1 addition created _config.yml will be).


Issue will be closed due already implemented feature in the head.

@xu-song
Copy link
Contributor Author

xu-song commented Jan 30, 2018

You prefer 500 posts with 500 heading. Okay

comments: false

or

sidebar: false

or

category:
- web

....

@ivan-nginx
Copy link
Member

And u prefer 500 posts with 500 configs?)

@ivan-nginx ivan-nginx changed the title How to disable sidebar for a folder or single page? How to disable sidebar for a folder or single page? [feature added] Jan 30, 2018
@xu-song
Copy link
Contributor Author

xu-song commented Jan 30, 2018

In many cases, 1-5 batch_configuration works.
Batch is better than one by one, Undoubtedly.

@ivan-nginx
Copy link
Member

ivan-nginx commented Jan 30, 2018

In most case, we 1-5 batch_configuration works.

Wow! I see now. Let explain situation:

  1. U want to set in main NexT config sidebar: false, for example.
  2. Not to put in each front-matter post this var, but
  3. Want to use something like template by inherit to set sidebar: true again?

I don't see any logic. Go as another corner:

U want to see sidebar or not want? U need sidebar? If u need, turn it on and all be done.
If no need, turn it off.

And u just now talking something about: i want sidebar, but don't need it on 25% in my site pages, right? So, u can disable sidebar for pages and use pages as this 25% of your posts. And else exists some plugins to customize (add) other types insted of post and page, if u did't know about that.


I think I have express my need clearly. If not , you can read again. And I don't like your style @ivan-nginx
We never talk about two sites.

Yeah, i write this comment while u just added your 1 explain, something like «Is there a god way to customize subfolder configuration?». You know, God customization can do only by God, because he's God, i think. We are not Gods here and can't to do special for u all of u need and wish, for free.


Again: this feature in this key hard to implement right now. But i see what u mean and in generally this good (not god) idea and will be backloged in our simple peoples heads. 😄

@xu-song
Copy link
Contributor Author

xu-song commented Jan 30, 2018

thanks

@ivan-nginx ivan-nginx changed the title How to disable sidebar for a folder or single page? [feature added] How to disable sidebar for a folder or single page? [solved] Mar 4, 2019
@theme-next theme-next locked as resolved and limited conversation to collaborators Apr 1, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants