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

Compatibility with URL rewriting #4466

Open
ChrisTucker2000 opened this issue Mar 1, 2018 · 3 comments
Open

Compatibility with URL rewriting #4466

ChrisTucker2000 opened this issue Mar 1, 2018 · 3 comments

Comments

@ChrisTucker2000
Copy link

Discourse thread: https://discourse.gohugo.io/t/compatibility-with-url-rewriting/10776

I'm using uglyURLs=true to generate nice, standard pages with an uncluttered file layout (beautiful, in my opinion), and I'm also using URL rewriting on the web server to achieve pretty URLs. In my opinion, this is a fairly standard web setup. The problem with this is that it completely breaks any URLs that Hugo generates.

I would therefore like to request a new feature in Hugo: compatibility with URL rewriting on the server.

I have three ideas for how this could be implemented.

Option 1:

Introduce a new configuration variable (e.g. for config.toml) called rewriteURLs, with true and false as valid values, and false as the default value.

When rewriteURLs and uglyURLs are both set to true, then functions such as ref and relref, and params such as .URL and .Permalink will always act as if uglyURLs is false, even though it isn't.

This seems like the simplest solution, but it is also the least flexible as it only supports one specific URL rewriting setup: removing the page's file extension. That might be acceptable though, as this is likely the most common setup anyway.

Option 2:

Introduce a new page front matter variable called rewrittenURL, which supports string values.

When a page has the rewrittenURL param set, then functions such as ref and relref, and params such as .URL and .Permalink will always use the rewrittenURL value; it overrides whatever URL would normally be used.

This approach would be similar to the current URL front matter param - the difference being that rewrittenURL would have absolutely no effect on the generated file path.

This is more flexible than Option 1, as any kind of URL would be supported. However, it's less maintainable for users of Hugo, as they would have to specify the URL on every single page.

Option 3:

Introduce new configuration variables (e.g. for config.toml) which support any number of "rewrite rules". These could be directly compatible with the .htaccess rewrite rule syntax, or they could just use a similar syntax. Users would be able to specify custom regular expression rules to rewrite URLs, and Hugo would then use these whenever a URL needs to be displayed.

This seems like the ideal solution, as it's very flexible and also very maintainable for the user. However, it's probably also the hardest solution to implement.


Thanks for reading. Do any of these changes seem reasonable to you?

@bep bep added the Proposal label Mar 1, 2018
@bep bep changed the title Feature request: compatibility with URL rewriting Compatibility with URL rewriting Mar 1, 2018
@stale
Copy link

stale bot commented Jun 29, 2018

This issue has been automatically marked as stale because it has not had recent activity. The resources of the Hugo team are limited, and so we are asking for your help.
If this is a bug and you can still reproduce this error on the master branch, please reply with all of the information you have about it in order to keep the issue open.
If this is a feature request, and you feel that it is still relevant and valuable, please tell us why.
This issue will automatically be closed in the near future if no further activity occurs. Thank you for all your contributions.

@stale stale bot added the Stale label Jun 29, 2018
@ChrisTucker2000
Copy link
Author

This is still relevant today, for the reasons stated earlier.

@stale stale bot removed the Stale label Jun 29, 2018
@jmooring jmooring removed the Keep label May 8, 2023
Copy link

github-actions bot commented May 8, 2024

This issue has been automatically marked as stale because it has not had recent activity. The resources of the Hugo team are limited, and so we are asking for your help.
If this is a bug and you can still reproduce this error on the master branch, please reply with all of the information you have about it in order to keep the issue open.
If this is a feature request, and you feel that it is still relevant and valuable, please tell us why.
This issue will automatically be closed in the near future if no further activity occurs. Thank you for all your contributions.

@github-actions github-actions bot added the Stale label May 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants