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

Resource and Course collections URLs use a mix of underscores and dashes #947

Open
1 task
pdpinch opened this issue Jan 30, 2022 · 7 comments
Open
1 task
Labels

Comments

@pdpinch
Copy link
Member

pdpinch commented Jan 30, 2022

The path for Resource collections is /resource_collections/ but the slug for Resource Collection pages substitutes spaces with dashes. This leads to confusing URLs like https://ocw-draft-qa.global.ssl.fastly.net/resource_collections/open-textbooks/ and https://ocw-draft-qa.global.ssl.fastly.net/course_collections/open-learning-library/

Acceptance Criteria:

  • pick one slugging method, or remove the space from resource collections and course collections
@alicewriteswrongs
Copy link
Contributor

I think resource_collections in that URL comes from the name property of the collection (see https://github.com/mitodl/ocw-hugo-projects/blob/main/ocw-www/ocw-studio.yaml#L21) so I think we could change that to resource-collections but I'm not sure what precisely all the consequences would be of changing that right now

I think definitely good to do this before we go live and links need to be final, if we're going to do it

@gumaerc might have some thoughts about changing the name on a collection and what consequences that would have downstream

@alicewriteswrongs
Copy link
Contributor

I have been meaning to ask if there's a better name we want in the URL, like whether course collections should be under collections or learning-paths or something like that

@gumaerc
Copy link
Contributor

gumaerc commented Feb 2, 2022

The name on a collection determines the content_type key stored in the front matter of the published content. This used to affect the type property in the front matter, which would change Hugo rendering behavior but it was moved to content_type specifically to avoid that. When importing, content_type is brought into the WebsiteContent objects as type. What will determine how Hugo outputs the content and thus the final URL of the content is the folder setting. For instance, resource collections has folder: content/resource_collections. The part of the path beyond content is what determines the folder it will go into in the Hugo content and subsequently the folder Hugo will output HTML into.

@alicewriteswrongs
Copy link
Contributor

right folder!

Am I right in thinking that if we changed the folder props to be resource-collections and course-collections on the ocw-www configs, then all we would need to do is rename the folders from resource_collections to resource-collections (and similarly course_collections -> course-collections) in the theme before republishing?

@alicewriteswrongs
Copy link
Contributor

by folders in the theme, I mean doing something like the following:

mv www/layouts/course_collections www/layouts/course-collections

@gumaerc
Copy link
Contributor

gumaerc commented Feb 3, 2022

In theory that would work, yea. Keep in mind that in some scenarios Hugo has trouble with hypens in filenames and / or metadata keys though. For instance, this code would not work:

{{ $courseCollections := $.Site.Data.course.course-collections }}

It would give you an error about - being an illegal character. In your example though, I think it would work because we're not calling out course-collections anywhere explicitly within the template, we're just setting up a layout and as long as the folder in the given site's content folder matches then you should be good. I would test it out though, obviously.

@alicewriteswrongs
Copy link
Contributor

Ok, that all makes sense to me. If we want to go forward with this rename it would need to happen in ocw-hugo-themes and in ocw-hugo-projects (and then we could have some corresponding changes in our checked in files in this repo)

@pdpinch pdpinch added the on hold label Feb 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants