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

Possible to change URLs of posts, tags, etc, from a Script (plugin)? #3849

Open
krausekai opened this issue Nov 9, 2019 · 2 comments
Open

Possible to change URLs of posts, tags, etc, from a Script (plugin)? #3849

krausekai opened this issue Nov 9, 2019 · 2 comments

Comments

@krausekai
Copy link

@krausekai krausekai commented Nov 9, 2019

I would like to know, is it possible to re-route or modify an item's path from a Script?

Although I can change default paths in the config.yml file such as tag_dir, archive_dir, and category_dir, I cannot use dynamic variables. In source files, I can use a helper or a tag, or after rendering I can use a filter script to find-replace URLs, but this will not change the routes where Hexo generates files to.

Note, I am not talking about hexo-pagination or generating a new page.

I only want to change URLs of items (e.g. posts), return them, and allow Hexo to continue.

Any ideas would be much appreciated.

@tomap

This comment has been minimized.

Copy link
Contributor

@tomap tomap commented Nov 11, 2019

Not sure it is possible.
The only possibility I know is to change the config.yml with the value you want.
In what context do you want to do that?

@krausekai

This comment has been minimized.

Copy link
Author

@krausekai krausekai commented Nov 11, 2019

For example, I have custom pagination for pages, posts, and tags based on categories and localization.

But the URLs for the tag pages do not change. Pagination and model paths are separate.

So, when I embed tag URLs into a page (<a href='...'></a>), I need to change the URLs of tags with a helper variable in the Theme Source code. But, I need to do this for every page, or layout.

It would be correct and proper to be able to change the path of tag items with a Plugin Script.

It might be possible to allow this by overriding the ctx (context) of a model at initialization, but I need dynamic variables based on page routing that may not always be known at initialization.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.