SNathJr / ghost-on-heroku

One-button Heroku deploy for the Ghost 3.2.0 blogging platform.
https://snathjr.github.io/ghost-on-heroku/
Other
232 stars 251 forks source link

Can't update theme, changes to *.hbs files do not render consistently #44

Closed codechair closed 4 years ago

codechair commented 4 years ago

Describe the bug I cannot update the theme (nothing at all, not even a simple removal of the link to Facebook on footer).

To Reproduce

  1. Fork this repo, let's call the fork "Ghostified"
  2. Fork the theme https://github.com/TryGhost/Lyra, let's call that fork "GhostifiedTheme"
  3. Do first changes like adjusting the footer removing the facebook link (just comment out line 35 in default.hbs) in "GhostifiedTheme"
  4. Commit changes to "GhostifiedTheme"
  5. Point to "GhostifiedTheme" inside package.json in "Ghostified" (look for dependencies --> lyra)
  6. run npm install --production to update package-lock.json
  7. Go to Heroku --> Manual deploy --> Deploy Branch
  8. Your changes will have successfully propagated to production, The Facebook link will have disappeared

This is when things NO longer propagate:

  1. Do additional changes to "GhostifiedTheme", like comment out line 36 in default.hbs to also remove the Twitter link
  2. like previously: Commit changes to "GhostifiedTheme"
  3. like previously: run npm install --production to update package-lock.json
  4. this won't make package-lock.json point to the latest commit on "GhostifiedTheme", so run npm update lyra, package-lock.json will now point to the latest commit on "GhostifiedTheme"
  5. Go to Heroku --> Manual deploy --> Deploy Branch
  6. Your changes will NO longer propagate to production, The Twitter link will not have disappeared (Please note: the Facebook link has not returned - from the top part of this "To Reproduce" -, it persisted )

Expected behavior Be able to change the theme via my forked theme of a supported Ghost Theme (i.e. Lyra). In other words, to be able to customise "GhostifiedTheme" and have the changes propagate

How are you deploying this? Deployment on Heroku from fork of this repo

SNathJr commented 4 years ago

Hey @codechair So, my first guess off the top of my head would be that, the deployment script is replacing your edited theme. Maybe you can try removing the theme's dependency from package.json and copy themes shell file as well. Let us know how it goes.

Cheers! SNathJr

codechair commented 4 years ago

Thanks a ton for reverting so quickly @SNathJr

I get removing the dependency from package.json

Can you clarify what you mean with "copy themes shell file as well" please?

SNathJr commented 4 years ago

Oh, I am sorry for not being specific. It's the copy-themes.sh file in bin folder.

Also, make sure you put your edited theme in content/themes folder.

codechair commented 4 years ago

Thanks and how do I make the contents in content/themes be readable?

Changes to them right now do not show up as changes in Github. So I can't commit them.

SNathJr commented 4 years ago

@codechair Try with the .gitignore file. There would be content/themes/*.

Also, if you would not want to do all that, you could simply create your own fork of the theme and point to that theme in the dependancy. That would be a better approach, as well.

codechair commented 4 years ago

Super ultra thanks @SNathJr ! Priceless help... 4h of my day ended up rescued by you :)

For others in the future going through the same (just as per suggestion from above from @SNathJr) The following worked:

  1. Remove "lyra": "github:myforkrepo/lyra-forked", from package.json (obs the path to your theme fork would be here)
  2. Remove "lyra" from copy-themes.sh file in bin folder.
  3. For the lyra theme have the following in your .gitignore file (as opposed to content/themes/*)
    content/themes/attila
    content/themes/bleak
    content/themes/casper
    content/themes/london
    content/themes/massively
    content/themes/pico 
    content/themes/the-shell
    content/themes/vapor

And to follow-up on your final note @SNathJr , sadly the fork only "worked" upon the first npm install --production all subsequent changes to the theme did not propagate. See the second part of "To reproduce" in https://github.com/SNathJr/ghost-on-heroku/issues/44#issue-554258437. I was working with a fork of the theme all along. This bit was the strangest of it all (only updating the markup the first time I've deployed a dependency - or changed the dependency - . I kept on moving between my fork and Ghost's original theme to confirm this and yes, the custom markup only changed/rendered if I'd move the dependency back to Ghost's theme repo and then back to my fork of the theme again).

Or did I misunderstand you with "fork of the theme"?

JaneJeon commented 4 years ago

the fork only "worked" upon the first npm install --production

@codechair well, that would be because, as we say time and time again, Heroku does NOT persist anything locally outside of what's already in your slug.

So the ONLY way to get this to persist every single time would be to just point Lyra (or whatever theme) to your own theme (e.g. "Lyra": "github:codechair/my-lyra-fork"), then copy-themes.sh will handle the rest.

Do you have at least one "release" in your forked theme repository?

@SNathJr we've had to repeat ourselves about Heroku not persisting any local file changes (including themes) again and again and again. We really should 1. update "bug" reports template to point anyone regarding this to #9, 2. add documentation, 3. aggressively close any issue about this. Maybe it might also be a good idea to explain in the README how heroku works (only the slug is persisted) and tell people to debug their own stuff (e.g. "if something only works the first time, chances are, it's not part of the slug")

codechair commented 4 years ago

Thanks for reverting @JaneJeon, I believe you misunderstood me.

I was pointing all dependencies to my own fork of the theme (See the second part of "To reproduce" in #https://github.com/SNathJr/ghost-on-heroku/issues/44#issue-554258437). So, unsure what you mean?

JaneJeon commented 4 years ago

@codechair

  1. You should only need to point only the dependency that you changed into your own fork, so when you say "I was pointing all dependencies" it tells me that you're doing something wrong.
  2. It's likely that your reference to your fork ("pointing") was wrong. Where is the forked theme repository and how did you "point" to it in your package.json (give links for both)? I don't believe that you did it correctly, so unless you can show me how exactly you did it I can't help you.
  3. You ignored the part where I asked if you had any "release" in your forked theme repository.
codechair commented 4 years ago

@JaneJeon

Just redid it all again and here it comes "all dependencies" was a typo as indeed this is about one dependency (this was also clear from my "To Reproduce" https://github.com/SNathJr/ghost-on-heroku/issues/44#issue-554258437):

Then the process to lock package-lock.json as per https://github.com/SNathJr/ghost-on-heroku/issues/44#issue-554258437 "To reproduce"

SNathJr commented 4 years ago

@JaneJeon I believe, @codechair needed help with how the repo works, and how github handles gitignore and gitkeep.

As far as I understand, @codechair wants to edit lyra theme in their fork and was not able to load it on deploy.

This was probably because of gitignore file ignoring content/themes and replacing it with original theme from tryghost. (@codechair correct me if I am wrong).

The solution was hence to create their own fork of theme with wanted changes and add it to dependencies. Or to add it in the folder manually and remove the code that replaces it.

The scope of this ticket should have been support (not bug).

codechair commented 4 years ago

This was probably because of gitignore file ignoring content/themes and replacing it with original theme from tryghost. (@codechair correct me if I am wrong).

@SNathJr the funny part of this is that the original content would not completely override the theme, the changes from the first part of "To reproduce" https://github.com/SNathJr/ghost-on-heroku/issues/44#issue-554258437 would persist on and on, but any new changes (second part of "To reproduce" https://github.com/SNathJr/ghost-on-heroku/issues/44#issue-554258437 ) would not propagate.

SNathJr commented 4 years ago

@JaneJeon Being at work, I believe I did not read that fully and assumed @codechair needed help with replacing the theme with their edited version. 😅

Also, closing this issue as it seems to have been solved by the OP.

JaneJeon commented 4 years ago

@SNathJr funny you should say that, I'm also at work xD

codechair commented 4 years ago

Getting back to this issue:

I had solved the issue by reading the theme files directly from my fork of this repo as per kind guidance from @SNathJr .

I'm however struggling with this approach now given I still need to do styling changes in the separate theme (Lyra) fork (in assets > css), then build the screen.css in assets > builtwith yarn, then manually copy those files over to the theme now living in my fork of this repo.

That is a lot of back and forth.

Any chance you'd have any idea on how to actually read from the separate theme fork without suffering from the inconsistencies I've referred to on the first comment to this issue?

I'm not opening a new issue since this history is very relevant to why I've moved to using the theme files in the repo.

And as a clean way to replicate what I've mentioned top of this thread, I'm prepared the repos so you can have a look at, clean:

Then the process to lock package-lock.json as per #44 (comment) "To reproduce"

SNathJr commented 4 years ago

Hey @codechair

I am not sure that I understand your question properly. Could you please be a little bit more specific? Maybe give a step by step procedure of what you were doing and what went wrong.

SNathJr

codechair commented 4 years ago

Sure @SNathJr , here it comes:

Describe the bug I cannot update the theme if:

To Reproduce

This is when things NO longer propagate:

Expected behavior Be able to change the theme via my forked theme of a supported Ghost Theme (i.e. Lyra). In other words, to be able to customise "GhostifiedTheme" and have the changes propagate

How are you deploying this? Deployment on Heroku from fork of this repo

Please let me know if you’d like any other details.

JaneJeon commented 4 years ago

Ignore what I said previously. @codechair I believe I have already mentioned to you above that a possible solution is to version your theme. However, you still not have tried it and AFAIK it is a surefire way to update the theme within heroku.

To version your theme, you MUST make a new GitHub release and update the specific version number.

As for @snathjr, I believe we need to explicitly say we do not support developing (or specifically, what this guy wants - “hot reposing”) on heroku. Your repo and theme must be prepped locally and then pushed up.