Change Jekyll site baseurl without breaking links to existing posts - url

I have a Jekyll blog using the Minimal Mistakes theme. It's hosted through GitHub Pages, with a custom domain name. The github repo is called eg me.github.io. Currently, the blog is at something like http://www.example.com, so each post comes up like http://www.example.com/trouble-with-urls/.
I want to change it so that it's all at http://www.example.com/blog instead. I have added baseurl: "/blog" to my _config.yml file and now the posts are at the right place, http://www.example.com/blog/trouble-with-urls/. However, I now have two problems: all my image links are broken, and more importantly the links to individual posts are also broken.
Is it possible to automatically redirect posts? I looked at the jekyll-redirect-from gem, but I don't really understand it. It looks like the baseurl is automatically included in the path for the redirect_from: and I can't work out how to ignore it. The readme for that gem says, for customising, "Simply create a layout in your site's _layouts directory called redirect.html." Is there something I can do with that?
Actually I would also like to change the permalinks as well, to add dates, but I'm trying to focus on one problem at a time! Eventually the final URL of each post should be like http://www.example.com/blog/2021/02/13/trouble-with-urls/.
For the images, they are currently all hardcoded like ![url trouble](/assets/images/2021-02/ugh.png). I can fix the path by adding in "/blog", to make it ![url trouble](/blog/assets/images/2021-02/ugh.png) but I think this might be a bad way to link images anyway. I saw that there are {% %} tags for links but can't find any resources about using them for images. Is it possible?

I managed to get this working, so here's what I did in case anyone else tries similar in future.
Adding a baseurl in _config.yml didn't work. Instead, I duplicated my repo, to take advantage of Github Pages' allowance for 1 User site but many Project sites.
One repo remained as me.github.io. I renamed the copy to blog, and added a gh-pages branch. This made GitHub automatically deploy it at me.github.io/blog.
Within the blog repo, I changed the permalinks to the style I wanted. The images were fine as the relative paths hadn't changed.
Within the original me.github.io repo, I first changed the home page (by editing the Minimal Mistakes html files) to hide all posts. Then I added a link at the top of the page to their new home, at me.github.io/blog. The blog is now successfully a subsidiary of the main site.
So that old links wouldn't break, I kept all the existing post files in the me.github.io repo. I used the jekyll-redirect-from gem to add redirects into each post for the new address. This was done by manually adding a line into the Front Matter of each, saying eg redirect_to: http://www.example.com/blog/2021/02/13/trouble-with-urls/. I also deleted all the post content of these posts, so only the Front Matter was left.
All future posts will be made within the blog repo, and so they will have the correct URLs.

Related

I want to produce Link with a path for sharing limages

I have a folder which have a construction below.
images_folder1/
├image01.png
├image02.png
images_folder2/
├image01.png
├image02.png
I want to upload these folders and get the link to access and I hope that the link has something like a relative path or absolute path.
(ex: https://〇〇//images_folder1/image01.png)
I already tried to use Github to accomplish this goal. Actually Github enables me to get the link with a path structure like "https://github.com/User/test_repo/blob/main/images_folder1/image01.png".
but the images should not be seen to other people except for those who know the link.(Github's private repository cannot do this. I have to get the repository "public") That's why Github is not suitable.
Also, I came up with the idea to get the link by using online storage services like "Box" but the link that I can get via Box seemed to be encrypted.(I mean there are no relationship between the folder structure and the link itself.)
Are there anyone who know the best websites or applications suitable for my requirements?
It is the first time to ask questions via stack overflow and I'm Japanese, so there might be some expressions hard to understand or sentences that don't contain sufficient explanations. Please let me know.
GitHub also gives you a relative or absolute path for your image other than url like https://github.com/User/test_repo/blob/main/images_folder1/image01.png. Just make sure, the url path you have given is correct. As:
If your GitHub pages site is publised at abc.github.io then type abc.github.io/images_folder1/image01.png.
If your GitHub pages site is publised at abc.github.io/repository then type abc.github.io/repository/images_folder1/image01.png.
Note: Make sure that no "/" is used at the end of the image, or page, url. Such that abc.github.io/images_folder1/image01.png/ should not be used instead of "abc.github.io/images_folder1/image01.png" , otherwise it will throw an error.
EDIT:
Suppose your GitHub username is "abc".
And you create a repository named "tiger", and turn GitHub pages on from the setting.(If your repository is private then you will need to upgrade to a premium account to active GitHub Pages)
Then your GitHub Pages will be published at "https://abc.github.io/tiger",i.e.,
("https://your-username.github.io/repository-name") by default and the "index.html" file will work as your homepage.
And if you repository name is "tiger.github.io" instead of only tiger, then your GitHub Pages will be published at "https://tiger.github.io",i.e.,
("https://repository-name.github.io").
But of you want to connect it to a custom top-level domain then you can do it from the settings.

Change domain without 404 error code?

I have changed all the URLs of my website. (Domain is the same. For example: http://www.example.com/category/sample ----> http://www.example.com/Category/Sample)
Now it seems to have lots of 404 pages that are effecting my SEO.
What should I do to solve this problem? Any suggestion?
Thank you
You can proceed with changing the Context root for your website. Context roots determine the URL of any web-application.
Click here for a short article for making changes to context-roots.
The process may change based on the Server you are using.
Just create sitemap.xml file. There are many online sites available that will create free sitemap.xml file. Just you have to submit your website url and within few seconds they will generate sitemap.xml file. Download this sitemap.xml file and place it into your root directory. When crawler run through your website it will automatically update your all links and within few days you will see all updated links are present in search resulting page like google search engine.
Note: Also, dont forget to update sitemap.xml file path in robot.txt file.

Transferred site doesn't show content with PMWiki

A relatively simple pmwiki site has been copied to a new server. All of the formatting (non-wiki) code works however the wiki content comes up as blank.
If I add a new page, that page shows up just fine.
I have checked the permissions and ownership of the files in wiki.d folder. All files (new and old) look identical.
I have eliminated the search optimization file in hopes that the old would be treated like the new.
Is there another file that references older files that might be keeping them from being seen? Any ideas would be welcome.
I've never had this problem before in copying a pmwiki site.
Here is the site http://pecarru.mobilify.pw/
Here is the new page http://pecarru.mobilify.pw/index.php?n=Main.NewPage
All pages should have text in the white box
The page-source is available by appending &action=source, so that tells us there is no problem accessing the content.
Additionally, the content looks normal -- no weird characters that I can see (which sometime cause trouble on a new server).
However, I do see "smart quotes" in several pages; try changing changing them to dumb-quotes and see if the page will now render.
I see that the WikiSandbox page and content in the PmWiki group renders, so it's not every page that has a problem.
If editing doesn't resolve the issue, try disabling recipes in \local\config.php until the content appears.
Something is choking on render.

Wordpress URL change

I have recently moved my wordpress site from "test.xxxxxx.com" to "xxxxxx.com" They are both identical except I just want to get rid of the "test" portion of my url on my index page and all my links. They are both on the same FTP and server. I transferred my site and have the homepage url working correctly but when I click on any of the links it still says "test" in front of the url. I have tried a couple different search and replace plugins with no luck. Is there a better way to go about this?
Wordpress has a problem that it doesn't update the permalinks easily. So, maybe you will have to change the permalinks manually in the wordpress database.
Use Better Search Replace plugin in order to fix old urls in your database.
After downloading and activating the plugin, you juste have to type old url to find and by which url to replace it, in your case you have to do it twice :
test.xxxxxx.com to xxxxxx.com
and
test.xxxxxx.com/ to xxxxxx.com/
I advice to do it twice because sometimes the plugin make difference between these two (strict string comparison I think) and wil not modifiy everything with only one command

How do I link to a PDF file in Silex?

I've looked around a bit and can't seem to figure out how to link to a static file while using Silex. I've seen some similar questions/answers in regards to Symfony, but they involved YML routing files, which I don't use with Silex.
My Situation
I have some files in a /docs folder. Logged in users can upload new pdf files (so, I don't know ahead of time what all of the filenames will be; they're constantly changing).
My Intent
I need to be able to link to these PDF files, so that a click on a link somewhere will open www.myurl.com/docs/myfile.pdf.
The Problem
Due to the routing system in silex, it treats the url as a route (obviously) and throws a Page Not Found error.
Thanks in advance for any feedback!
You need to configure your web server in a way that it does not forward existing files to the front controller. The web servers section of the silex documentation has examples of such configurations for the most popular web servers.
As for the link itself, just link to the file directly, something along these lines:
{{ filename }}

Resources