Hexo: [Q] Source folder.htaccess

Created on 4 Mar 2013  ·  20Comments  ·  Source: hexojs/hexo

Hi,

In my Sources folder, I have an .htaccess for my website.

It's possible to copy the .htaccess file automatically in the generate folder when I use hexo generate cmd ?

Thk a lot

question

Most helpful comment

@scorchio @fourpixels
Add to the _config.yml:

include:
  - .htaccess

All 20 comments

No. Hidden files won't be copied.

What's the best way to include a .htaccess file?

+1

+1 same problem.

+1

Why is this closed? A possible workaround is to copy the .htaccess to the public folder and then run hexo deploy. For this we added this line to our package.json:

"scripts":{
    "deploy" : "hexo generate && cp .htaccess public && hexo deploy"
}

Then you can run npm run deploy.

@moklick Even if it's copied to the public folder, it's completely ignored when pushing to the GitHub repo.

@Macxim I am using hexo-deployer-ssh and everything works fine. Are you using hexo-deployer-git to deploy your site?

@moklick Yes, indeed I am.

I don't understand what's the problem with that, as it's a pretty common issue? At least provide some workaround!

I've seen that there's a code for including/excluding files, but it works only for content (posts or pages) inside /source folder.
Also in themes, the source processor just uses:

if (common.isHiddenFile(path) || common.isTmpFile(path) || ~path.indexOf('node_modules'))
    return false;

Why is not similar as the asset processor:

if (common.isTmpFile(path) || common.isMatch(path, ctx.config.exclude))
    return;

if (common.isHiddenFile(path) && !common.isMatch(path, ctx.config.include)) {
    return;
}

Just saying "no" is not a professional open-source solution. It sounds like "I don't want to fix this"..

+1 for this. We really need to put htaccess files to deploy.
EDIT: See https://github.com/hexojs/hexo/issues/1705#issuecomment-170349924

+1 - it would be really nice if deploying htaccess files would be possible.

Unfortunately it seems like this is dead :(
@tommy351 @naokiy

This has been solved. See my comment!

@scorchio @fourpixels
Add to the _config.yml:

include:
  - .htaccess

@NoahDragon This does the trick, thanks!

@NoahDragon it works! thanks!

Just to mention that the .htaccess file must be in the source directory.

I tried several times unsuccessfully, so it might help anyone.

I added

include:
  - ".well-known/*"

in config.yaml and now when I do hexo clean && hexo deploy it even tells me that .well-known/keybase.txt has been found. But it seems deploy does still not upload it to GitHub?

Edit:

Yeah so when I do

include:
  - "keybase.txt"

the file is directly included. But when I use the hidden folder notation, it's not. Looks like a bug to me.

👋 It's me again. I had to do this again and I still notice that things are somewhere broken. I followed this thread and issue #2715 and I seem to not be able to make it work.

I'd really like to add a file to .well-known and simply use hexo deploy. If anyone points me to the source code, I can try to make an edit and send over a PR.

Was this page helpful?
0 / 5 - 0 ratings