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

Deprecate and then rename/remove Page.URL #4117

Closed
bep opened this issue Nov 24, 2017 · 8 comments · Fixed by #9419
Closed

Deprecate and then rename/remove Page.URL #4117

bep opened this issue Nov 24, 2017 · 8 comments · Fixed by #9419
Assignees
Labels
Milestone

Comments

@bep
Copy link
Member

bep commented Nov 24, 2017

I cannot think of one valid use case for it, and I see it used in the wild all the time when RelPermalik or Permalink is the correct choice.

URL returns the front matter value for regular pages, if set, else it return the RelPermalink.

@bep bep self-assigned this Nov 24, 2017
@bep bep added this to the v0.32 milestone Nov 24, 2017
@bep bep modified the milestones: v0.32, v0.33 Dec 16, 2017
@bep bep modified the milestones: v0.33, v0.34 Jan 11, 2018
@onedrawingperday
Copy link
Contributor

onedrawingperday commented Jan 18, 2018

I am not in favor of removing Page.URL.

For example
if eq .URL "/some-url/" provides an easy way to add an active class to page links that live outside Hugo's menu configuration (for various reasons) Also this is handy in cases where it's difficult to do a .Permalink or .RelPermalink check, like in Nested Sections list pages.

But if you really think these are not valid use cases. Go ahead and remove it. I'll look into what can be done to replace its functionality... like I always do...

@Jos512
Copy link

Jos512 commented Jan 19, 2018

.URL and .Permalink are indeed much the same, although the first returns a string value and the second a template.HTML value. So even though they return the same data, they behave differently:

{{ if in .URL "hugo" }}
...
{{ end }}

{{ if in (.Permalink | string) "hugo" }}
...
{{ end }}

I agree there's some redundancy. And on one hand I think Hugo template code might become easier when there's no two variables that return the same data. But on the other hand the required conversion to string of .Permalink might be more odd to newcomers than two variables are.

That latter might also make explaining how people can update from .URL to .Permalink somewhat confusing. Assuming we use a terminal message for this like Hugo did with previous depreciations. Would a terminal message like this be something people with little knowledge of Go/Hugo understand?

WARN: .URL has been deprecated. Replace .URL with 
.Permalink, but when comparing .Permalink against a 
string, first translate .Permalink to a string value
with the 'string' function.

Even though I wrote this without using programming lingo (like 'casting' or 'type incompatibility'), I still doubt if this is clear enough. (Or should we assume people read the release notes, where this can be explained more fully?)

So to summarise: I don't know what wisdom is for this issue. 😆

@onedrawingperday
Copy link
Contributor

onedrawingperday commented Jan 19, 2018

Or should we assume people read the release notes, where this can be explained more fully?

If the recent release of Hugo 0.32 is any indication I would say that people don't bother with the release notes. The forum is full of posts regarding index.md

A Warn like @Jos512 proposes is the way to go.

And possibly an example of the .Permalink translation to a string value, in the Release notes.

You cannot assume that every user of Hugo has used every one of its functions or that he/she knows what to do in advance. Not all of us are from a Dev background.

@bep bep modified the milestones: v0.34, v0.35, v0.36 Jan 22, 2018
@bep bep modified the milestones: v0.36, v0.37 Feb 3, 2018
@bep bep modified the milestones: v0.37, v0.38 Feb 11, 2018
@bep bep modified the milestones: v0.38, v0.39 Feb 21, 2018
@bep bep modified the milestones: v0.39, v0.40 Apr 9, 2018
@bep bep modified the milestones: v0.40, v0.41 Apr 20, 2018
@bep bep modified the milestones: v0.41, v0.42 May 4, 2018
@bep bep modified the milestones: v0.42, v0.43 Jun 5, 2018
@bep bep modified the milestones: v0.43, v0.44 Jun 30, 2018
@bep bep removed this from the v0.44 milestone Jul 10, 2018
@bep bep modified the milestones: v0.83, v0.84 May 1, 2021
@bep bep modified the milestones: v0.84, v0.85 Jun 18, 2021
@bep bep modified the milestones: v0.85, v0.86 Jul 5, 2021
@bep bep modified the milestones: v0.86, v0.87, v0.88 Jul 26, 2021
@bep bep modified the milestones: v0.88, v0.89 Sep 2, 2021
@bep bep modified the milestones: v0.89, v0.90 Nov 2, 2021
@bep bep modified the milestones: v0.90, v0.91.0 Dec 8, 2021
@bep bep modified the milestones: v0.91.0, v0.92.0 Dec 20, 2021
@bep bep modified the milestones: v0.92.0, v0.93.0 Jan 12, 2022
@onedrawingperday
Copy link
Contributor

@bep

Please consider removing .Page.URL in the next Hugo release. I think that it's about time.

There are out-of-date themes and perhaps tutorials floating around and some users keep on encountering the .Page.URL deprecation notice and having questions about it, as shown here.

It's better to break some old projects rather than wasting time explaining a deprecation message that was added in 2017, five years later, in 2022.

@bep
Copy link
Member Author

bep commented Jan 24, 2022

@onedrawingperday hmm... I was sure I removed that in the previous release. O well, thanks for the heads up.

EDIT: OK, I see I bump the WARNING level to ERROR ... Yes, I will remove.

bep added a commit to bep/hugo that referenced this issue Jan 24, 2022
They have been deprecated for a very long time, first with a warning, then with an ERROR. Now they are removed.

Closes gohugoio#4117
bep added a commit to bep/hugo that referenced this issue Jan 28, 2022
They have been deprecated for a very long time, first with a warning, then with an ERROR. Now they are removed.

Closes gohugoio#4117
@bep bep closed this as completed in #9419 Feb 14, 2022
bep added a commit that referenced this issue Feb 14, 2022
They have been deprecated for a very long time, first with a warning, then with an ERROR. Now they are removed.

Closes #4117
@github-actions
Copy link

github-actions bot commented Mar 8, 2022

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 8, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants